tazpkg rev 698

tazpkg-convert: add voidlinux support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Dec 03 19:00:15 2014 +0100 (2014-12-03)
parents bd0e2ed0e601
children 1b791f0f9239
files tazpkg-convert
line diff
     1.1 --- a/tazpkg-convert	Tue Dec 02 09:14:09 2014 +0100
     1.2 +++ b/tazpkg-convert	Wed Dec 03 19:00:15 2014 +0100
     1.3 @@ -553,6 +553,80 @@
     1.4  	rm -rf $TMP_DIR
     1.5  }
     1.6  
     1.7 +# convert a .xbps package to .tazpkg (http://repo.voidlinux.eu/current/)
     1.8 +xbpstag()
     1.9 +{
    1.10 +	sed "/<key>$1<\/key>/!d{n;s/.*>\\(.*\\)<.*/\\1/}" \
    1.11 +		< fs/props.plist | sed \$!d
    1.12 +}
    1.13 +
    1.14 +convert_xbps()
    1.15 +{
    1.16 +	mkdir -p $TMP_DIR/fs
    1.17 +	( xzcat $PACKAGE_FILE || bzcat $PACKAGE_FILE || zcat $PACKAGE_FILE ) | \
    1.18 +		tar xf - -C $TMP_DIR/fs
    1.19 +
    1.20 +	cd $TMP_DIR
    1.21 +	HOST_ARCH="$(xbpstag architecture)"
    1.22 +	case "$HOST_ARCH" in
    1.23 +	i686)	HOST_ARCH="i486" ;;
    1.24 +	*)	echo "Arch $HOST_ARCH not supported."
    1.25 +		HOST_ARCH=
    1.26 +	esac
    1.27 +
    1.28 +	if [ "$HOST_ARCH" ]; then
    1.29 +		package="$(xbpstag pkgname)"
    1.30 +		version="$(xbpstag version)"
    1.31 +		file=$package-$version
    1.32 +		mkdir $file
    1.33 +		cat > $file/receipt <<EOT
    1.34 +# SliTaz package receipt.
    1.35 +# generated by tazpkg from package $(basename $PACKAGE_FILE)
    1.36 +PACKAGE="$package"
    1.37 +VERSION="$version"
    1.38 +CATEGORY="misc"
    1.39 +SHORT_DESC="$(xbpstag short_desc)"
    1.40 +WEB_SITE="$(xbpstag homepage)"
    1.41 +MAINTAINER="$(xbpstag maintainer | sed 's/&gt;/>/;s/&lt;/</')"
    1.42 +LICENSE="$(xbpstag license | sed 's/-//g')"
    1.43 +HOST_ARCH="$HOST_ARCH"
    1.44 +CONFIG_FILES="$(sed '/<key>conf_files<\/key>/,/<key>/!d;/array>/d;/<key>/d;s/.*>\(.*\)<.*/\1/' fs/props.plist)"
    1.45 +
    1.46 +DEPENDS="$(find_depends)"
    1.47 +
    1.48 +EOT
    1.49 +		while read script func ; do
    1.50 +			[ -s fs/$script  ] && cat >> $file/receipt <<EOT
    1.51 +xbps_$func()
    1.52 +{
    1.53 +set +e
    1.54 +$(cat fs/$script)
    1.55 +}
    1.56 +
    1.57 +pre_$func()
    1.58 +{
    1.59 +	xbps_$func pre $package $version yes /etc/xbps.conf $HOST_ARCH
    1.60 +}
    1.61 +
    1.62 +post_$func()
    1.63 +{
    1.64 +	xbps_$func post $package $version yes /etc/xbps.conf $HOST_ARCH
    1.65 +}
    1.66 +
    1.67 +EOT
    1.68 +			rm -f fs/$script
    1.69 +		done << EOT
    1.70 +INSTALL		install
    1.71 +REMOVE		remove
    1.72 +EOT
    1.73 +		rm -f fs/*.plist
    1.74 +		mv fs $package-$version
    1.75 +		tazpkg pack $package-$version
    1.76 +		mv $package-$version.tazpkg $TOP_DIR
    1.77 +	fi
    1.78 +	cd $TOP_DIR
    1.79 +	rm -rf $TMP_DIR
    1.80 +}
    1.81  
    1.82  
    1.83  
    1.84 @@ -580,6 +654,8 @@
    1.85  			convert_spack;;
    1.86  		*.tar.bz2)
    1.87  			convert_upkg;;
    1.88 +		*.xbps)
    1.89 +			convert_xbps;;
    1.90  		*)
    1.91  			_ 'Unsupported format' ;;
    1.92  	esac