Commit 0aa44339 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm pack: refactoring, move script runnning to a seprate func

parent 3ab97a11
......@@ -23,9 +23,9 @@ load_helper epm-repack
[ -n "$EPM_PACK_SCRIPTS_DIR" ] || EPM_PACK_SCRIPTS_DIR="$CONFIGDIR/pack.d"
# we run this function in a tmpdir
__epm_pack()
# <packname> <abstarname> [packversion]
# fills returntarname with returned tar name or empty
__epm_pack_run_handler()
{
local packname="$1"
local tarname="$2"
......@@ -33,7 +33,7 @@ __epm_pack()
returntarname=''
local repackcode="$EPM_PACK_SCRIPTS_DIR/$packname.sh"
[ -x "$repackcode" ] || fatal "Can't find script $repackcode for packname $packname"
[ -x "$repackcode" ] || return
[ -f "$repackcode.rpmnew" ] && warning "There is .rpmnew file(s) in $EPM_PACK_SCRIPTS_DIR dir. The pack script can be outdated."
# a file to keep filename of generated tarball
......@@ -43,10 +43,19 @@ __epm_pack()
local bashopt=''
[ -n "$debug" ] && bashopt='-x'
#info "Running $($script --description 2>/dev/null) ..."
( unset EPMCURDIR ; export PATH=$SCPATH ;docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" "$packversion" ) || fatal
( unset EPMCURDIR ; export PATH=$SCPATH ; docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" "$packversion" ) || fatal
returntarname="$(cat "$filefortarname")" || fatal "pack script $repackcode didn't set tarname"
[ -s "$returntarname" ] || fatal "pack script for $packname return unexist $returntarname file"
return 0
}
[ -s "$returntarname" ] || fatal "pack script $repackcode return unexist $returntarname file"
# we run this function in a tmpdir
__epm_pack()
{
local packname="$1"
# fills returntarname with packed tar
__epm_pack_run_handler "$@" || fatal "Can't find pack script for packname $packname"
if [ -n "$download_only" ] ; then
mv $returntarname $EPMCURDIR
......@@ -64,6 +73,7 @@ __epm_pack()
[ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname"
fi
local pkgname
if [ -n "$repacked_pkgs" ] ; then
# remove packed file if we have repacked one
rm -v "$returntarname"
......@@ -128,16 +138,15 @@ epm_pack()
tarname="$(realpath "$pkg_files")"
elif [ -d "$tarname" ] ; then
tarname="$(realpath "$tarname")"
cd $tmpdir || fatal
elif [ -s "$tarname" ] ; then
# get full path for real name
tarname="$(realpath "$tarname")"
cd $tmpdir || fatal
else
# just pass name
true
fi
cd $tmpdir || fatal
__epm_pack "$packname" "$tarname" "$packversion"
}
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