Commit 6d6a2a01 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm repack: rewrite __epm_repack() via __epm_repack_single(), fix repack rule detection

parent 9387be94
......@@ -132,31 +132,26 @@ __prepare_source_package()
# FIXME: Нужно как-то обеспечить непродолжение выполнения.
# used in epm install
# fill repacked_pkgs
__epm_repack()
__epm_repack_single()
{
repacked_pkgs=''
local pkg="$1"
case $PKGFORMAT in
rpm)
load_helper epm-repack-rpm
__epm_repack_to_rpm "$@" || return
__epm_repack_to_rpm "$pkg" || return
;;
deb)
# FIXME: only one package in $@ is supported
#local pkgname="$(epm print name from "$@")"
#__set_version_pkgname "$1"
local repackcode="$EPM_REPACK_SCRIPTS_DIR/$PKGNAME.sh"
if [ -x "$repackcode" ] ; then
if __epm_have_repack_rule "$pkg" ; then
# we have repack rules only for rpm, so use rpm step in any case
load_helper epm-repack-rpm
load_helper epm-repack-deb
__epm_repack_to_rpm "$@" || return
[ -n "$repacked_pkgs" ] || return
__epm_repack_to_deb $repacked_pkgs
__epm_repack_to_rpm "$pkg" || return
[ -n "$repacked_pkg" ] || return
__epm_repack_to_deb $repacked_pkg || return
else
load_helper epm-repack-deb
__epm_repack_to_deb "$@" || return
__epm_repack_to_deb "$pkg" || return
fi
;;
*)
......@@ -167,6 +162,18 @@ __epm_repack()
return 0
}
# fill repacked_pkgs
__epm_repack()
{
local pkg
repacked_pkgs=''
for pkg in $* ; do
__epm_repack_single "$pkg" || fatal "Error with $pkg repacking."
[ -n "$repacked_pkgs" ] && repacked_pkgs="$repacked_pkgs $repacked_pkg" || repacked_pkgs="$repacked_pkg"
done
}
__epm_repack_if_needed()
{
# return 1 if there is a package in host package format
......
......@@ -18,17 +18,16 @@
#
# fills repacked_pkgs
# fills repacked_pkg
__epm_repack_to_deb()
{
local pkg
local pkgs="$*"
local pkg="$1"
assure_exists alien
assure_exists fakeroot
assure_exists rpm
repacked_pkgs=''
repacked_pkg=''
local TDIR
TDIR="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal
......@@ -36,7 +35,10 @@ __epm_repack_to_deb()
umask 022
for pkg in $pkgs ; do
if echo "$pkg" | grep -q "\.deb" ; then
warning "Repack deb to deb is not supported yet."
fi
abspkg="$(realpath "$pkg")"
info "Repacking $abspkg to local deb format (inside $TDIR) ..."
......@@ -47,15 +49,16 @@ __epm_repack_to_deb()
cd $TDIR || fatal
__prepare_source_package "$pkg"
showcmd_store_output fakeroot alien -d -k $scripts "$alpkg"
showcmd_store_output fakeroot alien -d -k $verbose $scripts "$alpkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
if [ -n "$DEBCONVERTED" ] ; then
repacked_pkgs="$repacked_pkgs $(realpath $DEBCONVERTED)"
repacked_pkg="$repacked_pkg $(realpath $DEBCONVERTED)"
remove_on_exit "$(realpath $DEBCONVERTED)"
else
warning "Can't find converted deb for source binary package '$pkg'"
fi
clean_store_output
cd - >/dev/null
done
return 0
}
......
......@@ -124,10 +124,10 @@ __try_install_eepm_rpmbuild()
RPMBUILD=/usr/bin/rpmbuild
}
# will fill repacked_pkgs var
# will fill repacked_pkg var
__epm_repack_to_rpm()
{
local pkgs="$*"
local pkg="$1"
# Note: install epm-repack for static (package based) dependencies
assure_exists alien || fatal
......@@ -151,18 +151,18 @@ __epm_repack_to_rpm()
umask 022
# TODO: improve
if echo "$pkgs" | grep -q "\.deb" ; then
if echo "$pkg" | grep -q "\.deb" ; then
assure_exists dpkg || fatal
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf
fi
local pkg
local alpkg
local abspkg
local tmpbuilddir
repacked_pkgs=''
for pkg in $pkgs ; do
repacked_pkg=''
# TODO: keep home?
HOME="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal
remove_on_exit $HOME
......@@ -236,12 +236,11 @@ __epm_repack_to_rpm()
local repacked_rpm="$(realpath $tmpbuilddir/../*.rpm)"
if [ -s "$repacked_rpm" ] ; then
remove_on_exit "$repacked_rpm"
[ -n "$repacked_pkgs" ] && repacked_pkgs="$repacked_pkgs $repacked_rpm" || repacked_pkgs="$repacked_rpm"
repacked_pkg="$repacked_rpm"
else
warning "Can't find converted rpm for source binary package '$pkg' (got $repacked_rpm)"
fi
cd $EPMCURDIR >/dev/null
done
true
}
......
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