Commit 9bbfbb8e authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm pack: improve working with tmpdir, simplify

parent 5aaba82e
......@@ -24,6 +24,7 @@ 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()
{
local packname="$1"
......@@ -35,9 +36,8 @@ __epm_pack()
[ -x "$repackcode" ] || fatal "Can't find script $repackcode for packname $packname"
[ -f "$repackcode.rpmnew" ] && warning "There is .rpmnew file(s) in $EPM_PACK_SCRIPTS_DIR dir. The pack script can be outdated."
tmpdir="$(mktemp -d)"
filefortarname="$tmpdir/filefortarname"
trap "rm -rf $tmpdir" EXIT
# a file to keep filename of generated tarball
filefortarname="$(pwd)/filefortarname"
set_sudo
export SUDO
......@@ -50,25 +50,15 @@ __epm_pack()
#info "Running $($script --description 2>/dev/null) ..."
( unset EPMCURDIR ; docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" "$packversion" ) || fatal
returntarname="$(cat "$filefortarname")" || fatal "pack script $repackcode didn't set tarname"
rm -rf $tmpdir
[ -s "$returntarname" ] || fatal "pack script $repackcode didn't return tarname"
#local newname="$(basename "$returntarname")"
# now it is by default in the current dir
#if [ "$returntarname" != "$(realpath $newname)" ; then
# # repack put its result to the current dir
# mv -v $returntarname . || fatal
#fi
[ -s "$returntarname" ] || fatal "pack script $repackcode return unexist $returntarname file"
if [ -n "$download_only" ] ; then
mv $returntarname $EPMCURDIR
return
fi
trap "rm -v $returntarname" EXIT
# FIXME: __epm_repack will drop trap
# repack if needed
repacked_pkgs=''
# repack to our target
if __epm_repack_if_needed $returntarname ; then
......@@ -80,20 +70,21 @@ __epm_pack()
fi
if [ -n "$repacked_pkgs" ] ; then
rm -v $returntarname
mv -v $repacked_pkgs . || fatal
pkgname=$(pwd)/"$(basename $repacked_pkgs)"
# remove packed file if we have repacked one
rm -v "$returntarname"
# also drop spaces
pkgname="$(echo $repacked_pkgs)"
else
pkgname="$returntarname"
fi
if [ -n "$install" ] ; then
trap "rm -v $pkgname" EXIT
docmd epm install $pkgname
docmd epm install "$pkgname"
return
fi
trap "" EXIT
# we need put result in the cur dir
mv -v "$pkgname" $EPMCURDIR || fatal
}
......@@ -123,8 +114,9 @@ epm_pack()
exit
fi
#TODO
trap "__epm_remove_tmp_files" EXIT
local tmpdir="$(mktemp -d --tmpdir=$BIGTMPDIR)"
to_clean_tmp_dirs="$to_clean_tmp_dirs $tmpdir"
local packname="$1"
local tarname="$2"
......@@ -135,15 +127,17 @@ epm_pack()
if is_url "$tarname"; then
pkg_urls="$tarname"
load_helper epm-download
cd $tmpdir || fatal
__handle_pkg_urls_to_install
# drop spaces and get full path
tarname="$(realpath $pkg_files)"
elif [ -d "$tarname" ] ; then
fatal "FIXME: implement packing of the dir $tarname?"
tarname=''
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
......
......@@ -6,12 +6,6 @@ FPRODUCT="Telegram"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
erc $TAR || fatal
# use version from tarball
......@@ -23,6 +17,6 @@ f=$FPRODUCT
mkdir -p opt/$PRODUCT || fatal
cp $f opt/$PRODUCT/$PRODUCT || fatal
erc pack $CURDIR/$PKGNAME.tar opt/$PRODUCT
erc pack $PKGNAME.tar opt/$PRODUCT
return_tar $PKGNAME.tar
......@@ -7,12 +7,6 @@ TPRODUCT="Telegram"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
erc $TAR || fatal
# use version from tarball
......@@ -25,6 +19,6 @@ f=$FPRODUCT
mkdir -p opt/$TPRODUCT || fatal
cp $f opt/$TPRODUCT/$TPRODUCT || fatal
erc pack $CURDIR/$PKGNAME.tar opt/$TPRODUCT
erc pack $PKGNAME.tar opt/$TPRODUCT
return_tar $PKGNAME.tar
......@@ -5,12 +5,6 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
if echo "$TAR" | grep "Sentinel_LDK_Linux_Run-time_Installer_script.tar.gz" ; then
erc $TAR || fatal
TAR="Sentinel_LDK_Linux_Run-time_Installer_script/aksusbd-*.tar.gz"
......@@ -35,6 +29,6 @@ case $pkgtype in
;;
esac
cp -v $PRODUCT*/pkg/$pkg $CURDIR || fatal
mv -v $PRODUCT*/pkg/$pkg . || fatal
return_tar $CURDIR/$pkg
return_tar $pkg
......@@ -7,9 +7,8 @@ RETURNTARNAME="$2"
[ -s "$FFMPEGDEB" ] || fatal "$FFMPEGDEB is missed"
CURDIR=$(pwd)
# TODO: set via args?
CURDIR=$(pwd)
PRODUCTDIR=/opt/chromium-browser
PKGNAME=chromium-codecs-ffmpeg-extra
BASEPKGNAME="chromium"
......@@ -29,9 +28,7 @@ pack_ffmpeg() {
exit
}
DDIR=$(mktemp -d)
trap "rm -fr $DDIR" EXIT
cd $DDIR || fatal
# TODO: use erc
# direct unpack deb
a='' ar -x $FFMPEGDEB
a='' tar xf "data.tar.xz"
......
......@@ -5,12 +5,6 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
if ! echo "$TAR" | grep "linux-UFRII-drv" ; then
fatal "How no idea how to handle $TAR"
fi
......@@ -42,7 +36,4 @@ case "$(epm print info -p)" in
;;
esac
PKG="$(echo $PKG)"
cp $PKG $CURDIR || fatal
return_tar $(basename $PKG)
return_tar $PKG
......@@ -69,7 +69,7 @@ has_wildcard()
return_tar()
{
[ -n "$RETURNTARNAME" ] || fatal "RETURNTARNAME is empty"
echo $1 >$RETURNTARNAME || fatal "Can't save tar name $1 to file $RETURNTARNAME"
realpath $1 >$RETURNTARNAME || fatal "Can't save tar name $1 to file $RETURNTARNAME"
}
[ -n "$PRODUCT" ] || PRODUCT="$(basename $0 .sh)"
......@@ -5,15 +5,9 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
PKGNAME="$(basename $TAR .run | tr "[A-Z_]" "[a-z-]")"
install -D $TAR opt/$PRODUCT/$PRODUCT || fatal
erc pack $CURDIR/$PKGNAME.tar opt/$PRODUCT
erc pack $PKGNAME.tar opt/$PRODUCT
return_tar $PKGNAME.tar
......@@ -8,29 +8,22 @@ PRODUCTCUR=far2l
. $(dirname $0)/common.sh
[ -n "$VERSION" ] || fatal "Missed archive version"
CURDIR=$(pwd)
PKGNAME=$CURDIR/$PRODUCT-$VERSION.tar
tdir=$(mktemp -d)
trap "rm -fr $tdir" EXIT
cd $tdir || fatal
PKGNAME=$PRODUCT-$VERSION.tar
if echo "$TAR" | grep -q "far2l_portable.*.tar.gz" ; then
erc $TAR || fatal
RUNFILE="$(echo $tdir/far2l*.run)"
RUNFILE="$(echo far2l*.run)"
elif echo "$TAR" | grep -q "far2l_portable.*.run" ; then
RUNFILE="$TAR"
fi
[ -s "$RUNFILE" ] || fatal "Missed $RUNFILE"
mkdir -p $tdir/opt/$PRODUCT/
mkdir -p opt/$PRODUCT/
sh $RUNFILE --noexec --target $tdir/opt/$PRODUCT || fatal
sh $RUNFILE --noexec --target opt/$PRODUCT || fatal
#mkdir -p $tdir/usr/bin/
#ln -s /opt/$PRODUCT/$PRODUCTCUR $tdir/usr/bin/$PRODUCTCUR
......
......@@ -5,17 +5,11 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
# use version from tarball
PKGNAME="$(basename $TAR .tar.gz)"
erc $TAR || fatal
cd $PKGNAME || fatal
cp $PRODUCT $CURDIR/$PKGNAME.AppImage || fatal
cp $PRODUCT $PKGNAME.AppImage || fatal
return_tar $PKGNAME.AppImage
......@@ -5,12 +5,6 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
erc unpack $TAR && cd kubo || fatal
mkdir -p usr/bin
mv ipfs usr/bin
......@@ -21,6 +15,6 @@ mv LICENSE* usr/share/doc/$PRODUCT
VERSION="$(echo "$TAR" | sed -e 's|.*kubo_v||' -e 's|[-_].*||')"
PKGNAME=$PRODUCT-$VERSION
erc pack $CURDIR/$PKGNAME.tar usr || fatal
erc pack $PKGNAME.tar usr || fatal
return_tar $PKGNAME.tar
......@@ -5,12 +5,6 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
if echo "$TAR" | grep Linux_Universal_Driver.zip ; then
erc $TAR || fatal
TAR=$(echo KyoceraLinuxPackages-*.tar.gz)
......@@ -35,6 +29,4 @@ case "$(epm print info -p)" in
# Debian/Global/kyodialog_i386 kyodialog_9.2-0_i386.deb
esac
cp $PKG $CURDIR || fatal
return_tar $PKG
......@@ -5,12 +5,6 @@ RETURNTARNAME="$2"
. $(dirname $0)/common.sh
CURDIR="$(pwd)"
PKGDIR="$(mktemp -d)"
trap "rm -fr $PKGDIR" EXIT
cd $PKGDIR || fatal
erc unpack $TAR && cd libsane* || fatal
mkdir -vp usr/share/doc/$PRODUCT
......@@ -39,6 +33,6 @@ done
PKGNAME="$(basename $TAR | sed -e "s|libsane-panakvs|$PRODUCT|")"
erc pack $CURDIR/$PKGNAME.tar etc usr
erc pack $PKGNAME.tar etc usr
return_tar $PKGNAME.tar
......@@ -27,20 +27,17 @@ pack_ffmpeg() {
DEST="$PRODUCTDIR"
mkdir -p .$DEST
cp $SOURCE .$DEST/libffmpeg.so.${VIVALDI_VERSION%\.*\.*}
CNAME=$CURDIR/"$(echo "$(basename $SUITABLE_URLS)" | sed -e "s|chromium|$BASEPKGNAME|" -e "s|-0ubuntu.*|-1.tar|")" #"
CNAME="$CURDIR/$(echo "$(basename $SUITABLE_URLS)" | sed -e "s|chromium|$BASEPKGNAME|" -e "s|-0ubuntu.*|-1.tar|")" #"
a='' tar cf $CNAME .$(dirname $DEST)
return_tar $CNAME
exit
}
SC=$(mktemp)
DDIR=$(mktemp -d)
trap "rm -fr $SC $DDIR" EXIT
SC=tmp_updateffmpeg
a='' awk 'BEGIN{desk=0}{ if(/^.*--system.*/&&desk==0){desk++} ; if (desk==0) {print} }' < $UPDATEFFMPEG > $SC
. $SC
cd $DDIR || fatal
epm tool eget $FFMPEG_URL_DEB || exit
SUITABLE_URLS=$FFMPEG_URL_DEB
a='' ar -x *.deb || exit
......
......@@ -7,7 +7,7 @@ RETURNTARNAME="$2"
[ -x "$UPDATEFFMPEG" ] || fatal "$UPDATEFFMPEG is missed"
CURDIR="$(pwd)"
CURDIR=$(pwd)
PRODUCTDIR="$(dirname "$UPDATEFFMPEG")"
BASEPKGNAME=yandex-browser-stable
......@@ -34,8 +34,7 @@ pack_ffmpeg() {
URL="https://browser-resources.s3.yandex.net/linux/codecs.json"
# download ffmpeg with upstream script update-ffmpeg but with our pack_ffmpeg function
SC=$(mktemp)
trap "rm -f $SC" EXIT
SC=tmp_updateffmpeg
sed -e 's|install_ffmpeg &&|pack_ffmpeg \&\&|' \
-e 's|wget -q-O|epm tool eget -q -O|' \
-e 's|wget -O|epm tool eget -O |' \
......
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