summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Shadura <andrew.shadura@collabora.co.uk>2016-10-05 14:24:02 +0200
committerAlejandro del Castillo <alejandro.delcastillo@ni.com>2016-10-05 13:33:24 -0500
commit1eddbee4b2a9a80e1eba36bf56b0f64c25ec973e (patch)
treeb26468dd991a343aadf39c32a57d4d329961cb29
parent4eaaf9f9328f098e13a11603cf26042a961d7d5b (diff)
downloadopkg-utils-1eddbee4b2a9a80e1eba36bf56b0f64c25ec973e.tar.gz
opkg-utils-1eddbee4b2a9a80e1eba36bf56b0f64c25ec973e.tar.bz2
opkg-utils-1eddbee4b2a9a80e1eba36bf56b0f64c25ec973e.zip
opkg-build: Add support for alternative compression schemes.
Add -Z with the same semantics as dpkg-deb -Z: Specify which compression type to use for data.tar member when building the package. Allowed values are gzip, bzip2 and xz. The default value is gzip. Signed-off-by: Andrew Shadura <andrew.shadura@collabora.co.uk> Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
-rwxr-xr-xopkg-build34
1 files changed, 28 insertions, 6 deletions
diff --git a/opkg-build b/opkg-build
index 9150d0b..792aef9 100755
--- a/opkg-build
+++ b/opkg-build
@@ -167,6 +167,7 @@ ogargs=""
outer=ar
noclean=0
opkext=0
+compressor=gzip
# Determine if tar supports the --format argument by checking the help output.
#
@@ -184,8 +185,26 @@ then
tarformat="--format=gnu"
fi
-usage="Usage: $0 [-c] [-C] [-O] [-o owner] [-g group] <pkg_directory> [<destination_directory>]"
-while getopts "cCg:ho:vO" opt; do
+compressor_ext() {
+ case $1 in
+ gzip)
+ echo gz
+ ;;
+ bzip2)
+ echo bz2
+ ;;
+ xz)
+ echo xz
+ ;;
+ *)
+ echo "*** Error: unsupported compression scheme: $1" >&2
+ exit 1
+ ;;
+ esac
+}
+
+usage="Usage: $0 [-c] [-C] [-Z compressor] [-O] [-o owner] [-g group] <pkg_directory> [<destination_directory>]"
+while getopts "cCg:ho:vOZ:" opt; do
case $opt in
o ) owner=$OPTARG
ogargs="--owner=$owner"
@@ -199,6 +218,8 @@ while getopts "cCg:ho:vO" opt; do
;;
C ) noclean=1
;;
+ Z ) compressor=$OPTARG
+ ;;
v ) echo $version
exit 0
;;
@@ -211,6 +232,7 @@ while getopts "cCg:ho:vO" opt; do
esac
done
+cext=$(compressor_ext $compressor)
shift $(($OPTIND - 1))
@@ -258,7 +280,7 @@ tmp_dir=$dest_dir/IPKG_BUILD.$$
mkdir $tmp_dir
echo $CONTROL > $tmp_dir/tarX
-( cd $pkg_dir && tar $ogargs -X $tmp_dir/tarX -cz $tarformat -f $tmp_dir/data.tar.gz . )
+( cd $pkg_dir && tar $ogargs -X $tmp_dir/tarX -c --$compressor $tarformat -f $tmp_dir/data.tar.$cext . )
( cd $pkg_dir/$CONTROL && tar $ogargs -cz $tarformat -f $tmp_dir/control.tar.gz . )
rm $tmp_dir/tarX
@@ -272,12 +294,12 @@ fi
rm -f $pkg_file
if [ "$outer" = "ar" ] ; then
- ( cd $tmp_dir && ar -crf $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
+ ( cd $tmp_dir && ar -crf $pkg_file ./debian-binary ./control.tar.gz ./data.tar.$cext )
else
- ( cd $tmp_dir && tar -cz $tarformat -f $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
+ ( cd $tmp_dir && tar -cz $tarformat -f $pkg_file ./debian-binary ./control.tar.gz ./data.tar.$cext )
fi
-rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
+rm $tmp_dir/debian-binary $tmp_dir/data.tar.$cext $tmp_dir/control.tar.gz
rmdir $tmp_dir
echo "Packaged contents of $pkg_dir into $pkg_file"