pck-extract.in: use rpm2archive instead of rpm2cpio and /var/tmp instead of /tmp to overcome 4GB size limit
This commit is contained in:
parent
afaac46997
commit
57d1ff0548
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# pck-extract -- plugin for @package@
|
# pck-extract -- plugin for @package@
|
||||||
# Copyright (C) 2004-2010 Davide Madrisan <davide.madrisan@gmail.com>
|
# Copyright (C) 2004-2010 Davide Madrisan <davide.madrisan@gmail.com>
|
||||||
|
# Copyright (C) 2024 Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||||
|
|
||||||
[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 3 ] &&
|
[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 3 ] &&
|
||||||
{ echo $"this script requires bash version 3 or better" >&2 && exit 1; }
|
{ 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}]"
|
notify.note "[${NOTE}$s_rpm_pck${NORM}]"
|
||||||
|
|
||||||
# check if all the needed tools are available
|
# 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)" ] ||
|
[ "$(type -p $tool)" ] ||
|
||||||
notify.error $"utility not found"": \`$tool'"
|
notify.error $"utility not found"": \`$tool'"
|
||||||
done
|
done
|
||||||
|
|
||||||
tmpcpiodir=$(mktemp -q -d -t $me.XXXXXXXX)
|
tmparchivedir=$(mktemp -q -d -p /var/tmp -t $me.XXXXXXXX)
|
||||||
[ $? -eq 0 ] &&
|
[ $? -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.error $"can't create temporary files"
|
||||||
notify.debug "$FUNCNAME: tmpcpiodir = $tmpcpiodir"
|
notify.debug "$FUNCNAME: tmparchivedir = $tmparchivedir"
|
||||||
|
|
||||||
#local s_rpm_pck_name
|
#local s_rpm_pck_name
|
||||||
case "$s_rpm_pck" in
|
case "$s_rpm_pck" in
|
||||||
@ -193,9 +194,9 @@ http://*\.src\.*|http://*\.nosrc\.*|ftp://*\.src\.*|ftp://*\.nosrc\.*)
|
|||||||
curl.download \
|
curl.download \
|
||||||
--options "$curl_options" \
|
--options "$curl_options" \
|
||||||
${proxy:+--proxy $proxy} ${proxy_user:+--proxy-user $proxy_user} \
|
${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\.*)
|
*\.src\.*|*\.nosrc\.*)
|
||||||
s_rpm_pck_name="$s_rpm_pck"
|
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 errcode
|
||||||
#local \
|
#local \
|
||||||
tmpcpiopck="srpm_pck.cpio"
|
tmparchivepck="srpm_pck.tar.gz"
|
||||||
|
|
||||||
notify.debug "\
|
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 = $?"
|
let "errcode = $?"
|
||||||
[ "$errcode" = 0 ] ||
|
[ "$errcode" = 0 ] ||
|
||||||
{ rm -fr $tmpcpiodir
|
{ rm -fr $tmparchivedir
|
||||||
notify.debug "$FUNCNAME: exit code of rpm2cpio = \`$errcode'"
|
notify.debug "$FUNCNAME: exit code of rpm2archive = \`$errcode'"
|
||||||
notify.error $"can't save extracted files to \`$destdir'"; }
|
notify.error $"can't save extracted files to \`$destdir'"; }
|
||||||
|
|
||||||
notify.debug "\
|
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 = $?"
|
let "errcode = $?"
|
||||||
[ "$errcode" = 0 ] ||
|
[ "$errcode" = 0 ] ||
|
||||||
{ rm -fr $tmpcpiodir
|
{ rm -fr $tmparchivedir
|
||||||
notify.debug "$FUNCNAME: exit code of cpio = \`$errcode'"
|
notify.debug "$FUNCNAME: exit code of tar = \`$errcode'"
|
||||||
notify.error $"can't save extracted files to \`$destdir'"; }
|
notify.error $"can't save extracted files to \`$destdir'"; }
|
||||||
|
|
||||||
rm -f $tmpcpiodir/$tmpcpiopck
|
rm -f $tmparchivedir/$tmparchivepck
|
||||||
|
|
||||||
#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'"; }
|
|
||||||
|
|
||||||
popd &>/dev/null
|
popd &>/dev/null
|
||||||
|
|
||||||
#local fname
|
#local fname
|
||||||
for f in $tmpcpiodir/${filelst:-*}; do
|
for f in $tmparchivedir/${filelst:-*}; do
|
||||||
fname=${f##*/}
|
fname=${f##*/}
|
||||||
notify.debug "$FUNCNAME: fname = \"$fname\""
|
notify.debug "$FUNCNAME: fname = \"$fname\""
|
||||||
case $fname in
|
case $fname in
|
||||||
@ -261,7 +253,7 @@ for f in $tmpcpiodir/${filelst:-*}; do
|
|||||||
notify.debug "$FUNCNAME: decompressing the patch..."
|
notify.debug "$FUNCNAME: decompressing the patch..."
|
||||||
bunzip2 $f &>/dev/null
|
bunzip2 $f &>/dev/null
|
||||||
[ $? -eq 0 ] ||
|
[ $? -eq 0 ] ||
|
||||||
{ rm -fr $tmpcpiodir
|
{ rm -fr $tmparchivedir
|
||||||
notify.warning $"can't decompress the file"" \`$f'"; }
|
notify.warning $"can't decompress the file"" \`$f'"; }
|
||||||
|
|
||||||
notify.note " * ${NOTE}$destdir/${fname/\.bz2/}${NORM}"
|
notify.note " * ${NOTE}$destdir/${fname/\.bz2/}${NORM}"
|
||||||
@ -271,7 +263,7 @@ for f in $tmpcpiodir/${filelst:-*}; do
|
|||||||
notify.debug "$FUNCNAME: decompressing the patch..."
|
notify.debug "$FUNCNAME: decompressing the patch..."
|
||||||
gunzip $f &>/dev/null
|
gunzip $f &>/dev/null
|
||||||
[ $? -eq 0 ] ||
|
[ $? -eq 0 ] ||
|
||||||
{ rm -fr $tmpcpiodir
|
{ rm -fr $tmparchivedir
|
||||||
notify.warning $"can't decompress the file"" \`$f'"; }
|
notify.warning $"can't decompress the file"" \`$f'"; }
|
||||||
|
|
||||||
notify.note " * ${NOTE}$destdir/${fname/\.gz/}${NORM}"
|
notify.note " * ${NOTE}$destdir/${fname/\.gz/}${NORM}"
|
||||||
@ -283,8 +275,8 @@ for f in $tmpcpiodir/${filelst:-*}; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
[ $? -eq 0 ] ||
|
[ $? -eq 0 ] ||
|
||||||
{ rm -fr $tmpcpiodir
|
{ rm -fr $tmparchivedir
|
||||||
notify.error $"can't save files to \`$destdir'"; }
|
notify.error $"can't save files to \`$destdir'"; }
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -fr $tmpcpiodir
|
rm -fr $tmparchivedir
|
||||||
|
Loading…
Reference in New Issue
Block a user