From 57d1ff05487bd9661985a6afdedd5c4692aa0fee Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Thu, 7 Nov 2024 21:47:06 +0100 Subject: [PATCH] pck-extract.in: use rpm2archive instead of rpm2cpio and /var/tmp instead of /tmp to overcome 4GB size limit --- plugins/pck-extract.in | 56 ++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/plugins/pck-extract.in b/plugins/pck-extract.in index e93bb87..25f2050 100644 --- a/plugins/pck-extract.in +++ b/plugins/pck-extract.in @@ -1,6 +1,7 @@ #!/bin/bash # pck-extract -- plugin for @package@ # Copyright (C) 2004-2010 Davide Madrisan +# Copyright (C) 2024 Silvan Calarco [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 3 ] && { echo $"this script requires bash version 3 or better" >&2 && exit 1; } @@ -173,16 +174,16 @@ notify.enable_colors "$color_scheme" notify.note "[${NOTE}$s_rpm_pck${NORM}]" # check if all the needed tools are available -for tool in bunzip2 cpio gunzip mktemp rpm2cpio; do +for tool in bunzip2 tar gunzip mktemp rpm2archive; do [ "$(type -p $tool)" ] || notify.error $"utility not found"": \`$tool'" done -tmpcpiodir=$(mktemp -q -d -t $me.XXXXXXXX) +tmparchivedir=$(mktemp -q -d -p /var/tmp -t $me.XXXXXXXX) [ $? -eq 0 ] && - trap "rm -fr $tmpcpiodir" 0 1 2 3 6 7 9 13 15 || + trap "rm -fr $tmparchivedir" 0 1 2 3 6 7 9 13 15 || notify.error $"can't create temporary files" -notify.debug "$FUNCNAME: tmpcpiodir = $tmpcpiodir" +notify.debug "$FUNCNAME: tmparchivedir = $tmparchivedir" #local s_rpm_pck_name case "$s_rpm_pck" in @@ -193,9 +194,9 @@ http://*\.src\.*|http://*\.nosrc\.*|ftp://*\.src\.*|ftp://*\.nosrc\.*) curl.download \ --options "$curl_options" \ ${proxy:+--proxy $proxy} ${proxy_user:+--proxy-user $proxy_user} \ ---exit-on-err --destdir="$tmpcpiodir" "$s_rpm_pck" +--exit-on-err --destdir="$tmparchivedir" "$s_rpm_pck" - s_rpm_pck="$tmpcpiodir/$s_rpm_pck_name" + s_rpm_pck="$tmparchivedir/$s_rpm_pck_name" ;; *\.src\.*|*\.nosrc\.*) s_rpm_pck_name="$s_rpm_pck" @@ -212,46 +213,37 @@ mkdir -p $destdir 2>/dev/null || notify.error $"cannot create \`$destdir'" #local errcode #local \ -tmpcpiopck="srpm_pck.cpio" +tmparchivepck="srpm_pck.tar.gz" notify.debug "\ -$FUNCNAME: converting the rpm package into a cpio archive..." +$FUNCNAME: converting the rpm package into a tar.gz archive..." -rpm2cpio $s_rpm_pck > $tmpcpiodir/$tmpcpiopck +rpm2archive $s_rpm_pck > $tmparchivedir/$tmparchivepck let "errcode = $?" [ "$errcode" = 0 ] || - { rm -fr $tmpcpiodir - notify.debug "$FUNCNAME: exit code of rpm2cpio = \`$errcode'" + { rm -fr $tmparchivedir + notify.debug "$FUNCNAME: exit code of rpm2archive = \`$errcode'" notify.error $"can't save extracted files to \`$destdir'"; } notify.debug "\ -$FUNCNAME: extracting files from the cpio archive..." +$FUNCNAME: extracting files from the tar.gz archive..." -pushd $tmpcpiodir &>/dev/null +pushd $tmparchivedir &>/dev/null + +tar xzf $tmparchivedir/$tmparchivepck -cpio --quiet --extract --preserve-modification-time \ - < $tmpcpiodir/$tmpcpiopck let "errcode = $?" [ "$errcode" = 0 ] || - { rm -fr $tmpcpiodir - notify.debug "$FUNCNAME: exit code of cpio = \`$errcode'" + { rm -fr $tmparchivedir + notify.debug "$FUNCNAME: exit code of tar = \`$errcode'" notify.error $"can't save extracted files to \`$destdir'"; } -rm -f $tmpcpiodir/$tmpcpiopck - -#notify.debug "\ -#$FUNCNAME: extracting files from the srpm archive..." -# -#rpm2cpio $s_rpm_pck 2>/dev/null | \ -#cpio --quiet --extract $filelst &>/dev/null -#[ $? -ne 0 ] && -# { popd &>/dev/null -# notify.error $"can't save extracted files to \`$destdir'"; } +rm -f $tmparchivedir/$tmparchivepck popd &>/dev/null #local fname -for f in $tmpcpiodir/${filelst:-*}; do +for f in $tmparchivedir/${filelst:-*}; do fname=${f##*/} notify.debug "$FUNCNAME: fname = \"$fname\"" case $fname in @@ -261,7 +253,7 @@ for f in $tmpcpiodir/${filelst:-*}; do notify.debug "$FUNCNAME: decompressing the patch..." bunzip2 $f &>/dev/null [ $? -eq 0 ] || - { rm -fr $tmpcpiodir + { rm -fr $tmparchivedir notify.warning $"can't decompress the file"" \`$f'"; } notify.note " * ${NOTE}$destdir/${fname/\.bz2/}${NORM}" @@ -271,7 +263,7 @@ for f in $tmpcpiodir/${filelst:-*}; do notify.debug "$FUNCNAME: decompressing the patch..." gunzip $f &>/dev/null [ $? -eq 0 ] || - { rm -fr $tmpcpiodir + { rm -fr $tmparchivedir notify.warning $"can't decompress the file"" \`$f'"; } notify.note " * ${NOTE}$destdir/${fname/\.gz/}${NORM}" @@ -283,8 +275,8 @@ for f in $tmpcpiodir/${filelst:-*}; do ;; esac [ $? -eq 0 ] || - { rm -fr $tmpcpiodir + { rm -fr $tmparchivedir notify.error $"can't save files to \`$destdir'"; } done -rm -fr $tmpcpiodir +rm -fr $tmparchivedir