Commit 5fc10205 authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed

parent 3b3cff86
...@@ -375,7 +375,8 @@ disabled_eget() ...@@ -375,7 +375,8 @@ disabled_eget()
return return
fi fi
assure_exists eget # FIXME: we need disable output here, eget can be used for get output
assure_exists eget >/dev/null
# run external command, not the function # run external command, not the function
EGET=$(which eget) || fatal "Missed command eget from installed package eget" EGET=$(which eget) || fatal "Missed command eget from installed package eget"
$EGET "$@" $EGET "$@"
...@@ -3085,7 +3086,7 @@ epm_Install() ...@@ -3085,7 +3086,7 @@ epm_Install()
[ -z "$files$names" ] && info "Install: Skip empty install list." && return 22 [ -z "$files$names" ] && info "Install: Skip empty install list." && return 22
(pkg_filenames='' epm_update) || return (pkg_filenames='' epm_update) || { [ -n "$force" ] || return ; }
epm_install_names $names || return epm_install_names $names || return
...@@ -5195,44 +5196,6 @@ __epm_split_by_pkg_type() ...@@ -5195,44 +5196,6 @@ __epm_split_by_pkg_type()
[ -n "$split_replaced_pkgs" ] [ -n "$split_replaced_pkgs" ]
} }
__epm_repack_deb_to_rpm()
{
local pkg
assure_exists alien
assure_exists dpkg
assure_exists rpmbuild rpm-build || fatal
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf
repacked_rpms=''
local TDIR=$(mktemp -d)
cd $TDIR || fatal
for pkg in "$@" ; do
# TODO: fakeroot for non ALT?
showcmd_store_output alien -r -k $scripts "$pkg" || fatal
local RPMCONVERTED=$(grep "rpm generated" $RC_STDOUT | sed -e "s| generated||g")
repacked_rpms="$repacked_rpms $(realpath $RPMCONVERTED)"
to_remove_pkg_files="$to_remove_pkg_files $(realpath $RPMCONVERTED)"
clean_store_output
done
cd - >/dev/null
return 0
}
__epm_check_if_try_install_deb()
{
__epm_split_by_pkg_type deb "$@" || return 1
__epm_repack_deb_to_rpm $split_replaced_pkgs
# TODO: move to install
docmd epm install $force $nodeps $repacked_rpms
return 0
}
__epm_repack_rpm_to_deb() __epm_repack_rpm_to_deb()
{ {
local pkg local pkg
...@@ -5254,6 +5217,14 @@ __epm_repack_rpm_to_deb() ...@@ -5254,6 +5217,14 @@ __epm_repack_rpm_to_deb()
clean_store_output clean_store_output
done done
# TODO: move it to exit handler
if [ -z "$DEBUG" ] ; then
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -f $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
[ -n "$to_remove_pkg_dirs" ] && rmdir $to_remove_pkg_dirs
fi
cd - >/dev/null cd - >/dev/null
return 0 return 0
} }
...@@ -5276,11 +5247,23 @@ __fix_spec() ...@@ -5276,11 +5247,23 @@ __fix_spec()
local buildroot="$1" local buildroot="$1"
local spec="$2" local spec="$2"
local i local i
for i in $(grep '^"/' $spec | sed -e 's|^"\(.*\)"$|\1|') ; do
#' hack for highlight # drop forbidded paths
# add %dir to dir in list # https://bugzilla.altlinux.org/show_bug.cgi?id=38842
for i in / /etc /etc/init.d /etc/systemd /bin /opt /usr /usr/bin /usr/share /usr/share/doc /var /var/log /var/run; do
sed -i -e "s|^%dir \"$i/*\"$||" \
-e "s|^\"$i/*\"$||" \
-e "s|^$i/*$||" \
$spec
done
# replace dir "/path/dir" -> %dir /path/dir
for i in $(grep '^"/' $spec | sed -e 's|^"\(/.*\)"$|\1|') ; do #" hack for highlight
# add dir as %dir in the filelist
if [ -d "$buildroot$i" ] ; then if [ -d "$buildroot$i" ] ; then
subst 's|^\("'$i'"\)$|%dir \1|' $spec subst 's|^\("'$i'"\)$|%dir \1|' $spec
#else
# subst 's|^\("'$i'"\)$|\1|' $spec
fi fi
done done
subst "s|^Release: |Release: alt1.repacked.with.epm.|" $spec subst "s|^Release: |Release: alt1.repacked.with.epm.|" $spec
...@@ -5305,6 +5288,7 @@ __create_rpmmacros() ...@@ -5305,6 +5288,7 @@ __create_rpmmacros()
%packager EPM <support@etersoft.ru> %packager EPM <support@etersoft.ru>
%_gpg_name support@etersoft.ru %_gpg_name support@etersoft.ru
EOF EOF
to_remove_pkg_files="$to_remove_pkg_files $HOME/.rpmmacros"
} }
__epm_repack_rpm() __epm_repack_rpm()
...@@ -5315,16 +5299,24 @@ __epm_repack_rpm() ...@@ -5315,16 +5299,24 @@ __epm_repack_rpm()
assure_exists alien || fatal assure_exists alien || fatal
assure_exists rpmbuild rpm-build || fatal assure_exists rpmbuild rpm-build || fatal
# TODO: improve
if echo "$*" | grep "\.deb" ; then
assure_exists dpkg || fatal
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf
fi
local pkg local pkg
export HOME=$(mktemp -d) export HOME=$(mktemp -d)
local tmpbuilddir=$HOME/repack
mkdir $tmpbuilddir
__create_rpmmacros __create_rpmmacros
local abspkg local abspkg
repacked_rpms='' repacked_rpms=''
for pkg in $* ; do for pkg in $* ; do
local tmpbuilddir=$HOME/repack-$(basename $pkg)
mkdir $tmpbuilddir
abspkg=$(realpath $pkg) abspkg=$(realpath $pkg)
info ""
info "Repacking $abspkg to local rpm format ..." info "Repacking $abspkg to local rpm format ..."
cd $tmpbuilddir || fatal cd $tmpbuilddir || fatal
docmd fakeroot alien --generate --to-rpm $verbose $scripts $abspkg || fatal docmd fakeroot alien --generate --to-rpm $verbose $scripts $abspkg || fatal
...@@ -5340,13 +5332,16 @@ __epm_repack_rpm() ...@@ -5340,13 +5332,16 @@ __epm_repack_rpm()
__fix_spec $tmpbuilddir/$subdir $spec __fix_spec $tmpbuilddir/$subdir $spec
local pkgname="$(grep "^Name: " $spec | sed -e "s|Name: ||g" | head -n1)" local pkgname="$(grep "^Name: " $spec | sed -e "s|Name: ||g" | head -n1)"
__apply_fix_code $pkgname $tmpbuilddir/$subdir $spec __apply_fix_code $pkgname $tmpbuilddir/$subdir $spec
# TODO: we need these dirs to be created
to_remove_pkg_dirs="$to_remove_pkg_dirs $HOME/RPM/BUILD $HOME/RPM"
showcmd fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec showcmd fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec
if [ -n "$verbose" ] ; then if [ -n "$verbose" ] ; then
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec || fatal a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec || fatal
else else
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec >/dev/null || fatal a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec >/dev/null || fatal
fi fi
local repacked_rpm="$(realpath $tmpbuilddir/../*.rpm)" mv $tmpbuilddir/../*.rpm $tmpbuilddir/
local repacked_rpm="$(realpath $tmpbuilddir/*.rpm)"
if [ -s "$repacked_rpm" ] ; then if [ -s "$repacked_rpm" ] ; then
repacked_rpms="$repacked_rpms $repacked_rpm" repacked_rpms="$repacked_rpms $repacked_rpm"
to_remove_pkg_files="$to_remove_pkg_files $repacked_rpm" to_remove_pkg_files="$to_remove_pkg_files $repacked_rpm"
...@@ -5358,11 +5353,33 @@ __epm_repack_rpm() ...@@ -5358,11 +5353,33 @@ __epm_repack_rpm()
#rm -rf $tmpbuilddir/../*.rpm #rm -rf $tmpbuilddir/../*.rpm
rm -rf $spec rm -rf $spec
done done
to_remove_pkg_dirs="$to_remove_pkg_dirs $HOME"
rmdir $tmpbuilddir rmdir $tmpbuilddir
#rmdir $tmpbuilddir/.. #rmdir $tmpbuilddir/..
true true
} }
__epm_check_if_try_install_deb()
{
__epm_split_by_pkg_type deb "$@" || return 1
__epm_repack_rpm $split_replaced_pkgs || fatal
# TODO: move to install
docmd epm install $force $nodeps $repacked_rpms
# TODO: move it to exit handler
if [ -z "$DEBUG" ] ; then
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -f $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
[ -n "$to_remove_pkg_dirs" ] && rmdir $to_remove_pkg_dirs 2>/dev/null
fi
return 0
}
epm_repack() epm_repack()
{ {
# if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames # if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames
...@@ -5376,22 +5393,13 @@ epm_repack() ...@@ -5376,22 +5393,13 @@ epm_repack()
# TODO: если у нас rpm, а пакет - deb и наоборот # TODO: если у нас rpm, а пакет - deb и наоборот
case $PKGFORMAT in case $PKGFORMAT in
rpm) rpm)
if __epm_split_by_pkg_type deb $pkg_files ; then __epm_repack_rpm $pkg_files || fatal
__epm_repack_deb_to_rpm $split_replaced_pkgs echo
echo echo "Adapted packages:"
echo "Adopted packages:" cp $repacked_rpms .
estrlist list $repacked_rpms for i in $repacked_rpms ; do
cp $repacked_rpms . echo " $(pwd)/$(basename "$i")"
pkg_files="$(estrlist exclude $split_replaced_pkgs $pkg_files)" done
fi
if [ -n "$pkg_files" ] ; then
__epm_repack_rpm $pkg_files || fatal
echo
echo "Adopted packages:"
estrlist list $repacked_rpms
cp $repacked_rpms .
fi
;; ;;
deb) deb)
if __epm_split_by_pkg_type rpm $pkg_files ; then if __epm_split_by_pkg_type rpm $pkg_files ; then
...@@ -5406,12 +5414,13 @@ epm_repack() ...@@ -5406,12 +5414,13 @@ epm_repack()
;; ;;
esac esac
# TODO: move it to exit handler # TODO: move it to exit handler
if [ -z "$DEBUG" ] ; then if [ -z "$DEBUG" ] ; then
# TODO: reinvent # TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -f $to_remove_pkg_files [ -n "$to_remove_pkg_files" ] && rm -f $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null # hack??
[ -n "$to_remove_pkg_files" ] && rmdir $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
[ -n "$to_remove_pkg_dirs" ] && rmdir $to_remove_pkg_dirs 2>/dev/null
fi fi
} }
...@@ -6766,14 +6775,14 @@ epm_upgrade() ...@@ -6766,14 +6775,14 @@ epm_upgrade()
if [ "$DISTRNAME" = "ALTLinux" ] ; then if [ "$DISTRNAME" = "ALTLinux" ] ; then
if tasknumber "$pkg_names" >/dev/null ; then if tasknumber "$pkg_names" >/dev/null ; then
epm_addrepo epm_addrepo "$pkg_names"
local installlist="$(get_task_packages $pkg_names)" local installlist="$(get_task_packages $pkg_names)"
[ -n "$verbose" ] && info "Packages from task(s): $installlist" [ -n "$verbose" ] && info "Packages from task(s): $installlist"
# install only installed packages (simulate upgrade packages) # install only installed packages (simulate upgrade packages)
installlist="$(estrlist exclude "$(echo "$installlist" | (skip_installed='yes' filter_out_installed_packages))" "$installlist")" #" installlist="$(estrlist exclude "$(echo "$installlist" | (skip_installed='yes' filter_out_installed_packages))" "$installlist")" #"
[ -n "$verbose" ] && info "Packages to upgrade: $installlist" [ -n "$verbose" ] && info "Packages to upgrade: $installlist"
(pkg_names="$installlist" epm_Install) (pkg_names="$installlist" epm_Install)
epm_removerepo epm_removerepo "$pkg_names"
return return
fi fi
fi fi
...@@ -8174,7 +8183,7 @@ Examples: ...@@ -8174,7 +8183,7 @@ Examples:
print_version() print_version()
{ {
echo "EPM package manager version 3.2.2 https://wiki.etersoft.ru/Epm" echo "EPM package manager version 3.2.5 https://wiki.etersoft.ru/Epm"
echo "Running on $($DISTRVENDOR -e) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)" echo "Running on $($DISTRVENDOR -e) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012-2020" echo "Copyright (c) Etersoft 2012-2020"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
...@@ -8184,7 +8193,7 @@ print_version() ...@@ -8184,7 +8193,7 @@ print_version()
Usage="Usage: epm [options] <command> [package name(s), package files]..." Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager" Descr="epm - EPM package manager"
EPMVERSION=3.2.2 EPMVERSION=3.2.5
verbose= verbose=
quiet= quiet=
nodeps= nodeps=
......
...@@ -366,7 +366,8 @@ disabled_eget() ...@@ -366,7 +366,8 @@ disabled_eget()
return return
fi fi
assure_exists eget # FIXME: we need disable output here, eget can be used for get output
assure_exists eget >/dev/null
# run external command, not the function # run external command, not the function
EGET=$(which eget) || fatal "Missed command eget from installed package eget" EGET=$(which eget) || fatal "Missed command eget from installed package eget"
$EGET "$@" $EGET "$@"
...@@ -2382,7 +2383,7 @@ print_version() ...@@ -2382,7 +2383,7 @@ print_version()
local on_text="(host system)" local on_text="(host system)"
local virt="$($DISTRVENDOR -i)" local virt="$($DISTRVENDOR -i)"
[ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)" [ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)"
echo "Service manager version 3.2.2 https://wiki.etersoft.ru/Epm" echo "Service manager version 3.2.5 https://wiki.etersoft.ru/Epm"
echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE" echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012-2019" echo "Copyright (c) Etersoft 2012-2019"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment