tazpkg rev 892

Module 'convert': fix working in general and with .pet packages in particular (thanks xaropebr)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Dec 19 13:50:01 2015 +0200 (2015-12-19)
parents 879df9728956
children 92d8376cbf06
files modules/convert
line diff
     1.1 --- a/modules/convert	Fri Dec 18 11:39:34 2015 +0200
     1.2 +++ b/modules/convert	Sat Dec 19 13:50:01 2015 +0200
     1.3 @@ -59,7 +59,7 @@
     1.4  SHORT_DESC="$descrip"
     1.5  WEB_SITE="$url"
     1.6  MAINTAINER="$maintainer"
     1.7 -DEPENDS="$(find_depends)"
     1.8 +DEPENDS="$(find_depends .)"
     1.9  EOT
    1.10  		[ -s $file/var/lib/upkg/files/*.config.bz2 ] &&
    1.11  			cat >> "$file/receipt" <<EOT
    1.12 @@ -111,7 +111,7 @@
    1.13  SHORT_DESC="$descrip"
    1.14  WEB_SITE="$url"
    1.15  MAINTAINER="$maintainer"
    1.16 -DEPENDS="$(find_depends)"
    1.17 +DEPENDS="$(find_depends .)"
    1.18  EOT
    1.19  	[ -s 'pre-install.sh' ] && cat >> "$file/receipt" <<EOT
    1.20  
    1.21 @@ -163,7 +163,7 @@
    1.22  SHORT_DESC="$descrip"
    1.23  WEB_SITE="${homepage:-$url}"
    1.24  MAINTAINER="$maintainer"
    1.25 -DEPENDS="$(find_depends)"
    1.26 +DEPENDS="$(find_depends .)"
    1.27  EOT
    1.28  		show_unresolved_lib "$file/receipt"
    1.29  		[ -s 'conffiles' ] && cat >> "$file/receipt" <<EOT
    1.30 @@ -228,7 +228,7 @@
    1.31  SHORT_DESC="$descrip"
    1.32  WEB_SITE="http://www.nutyx.org/"
    1.33  MAINTAINER="nobody@slitaz.org"
    1.34 -DEPENDS="$(find_depends)"
    1.35 +DEPENDS="$(find_depends .)"
    1.36  EOT
    1.37  		show_unresolved_lib "$file/receipt"
    1.38  		rm -f $file/fs/.[A-Z]*
    1.39 @@ -266,7 +266,7 @@
    1.40  SHORT_DESC="$descrip"
    1.41  WEB_SITE="$url"
    1.42  MAINTAINER="$maintainer"
    1.43 -DEPENDS="$(find_depends)"
    1.44 +DEPENDS="$(find_depends .)"
    1.45  EOT
    1.46  		show_unresolved_lib "$file/receipt"
    1.47  		rm -f $file/fs/.[A-Z]*
    1.48 @@ -283,6 +283,7 @@
    1.49  # get package and version from PACKAGE_FILE
    1.50  
    1.51  parse_pkgname() {
    1.52 +	debug "parse_pkgname('$1', '$2')"
    1.53  	package=$(basename "${2:-$PACKAGE_FILE}" "$1")
    1.54  	IFS='-'
    1.55  	set -- "$package"
    1.56 @@ -290,17 +291,18 @@
    1.57  	package="$1"
    1.58  	version="$2"
    1.59  	if [ -z "$version" ]; then
    1.60 -		package=${1%%[0-9\.]*}
    1.61 -		version=${1#$package}
    1.62 +		package=${1%%-[0-9\.]*}
    1.63 +		version=${1#$package-}
    1.64  	fi
    1.65  	file="$package-$version"
    1.66  	mkdir "$file"
    1.67 +	debug "  package='$package' version='$version' file='$file'"
    1.68  }
    1.69  
    1.70  
    1.71  finish_convert_puppy() {
    1.72  	rm -f fs/*.specs
    1.73 -	mv fs "$file"
    1.74 +	mkdir "$file"; mv fs "$file"
    1.75  	cat > "$file/receipt" <<EOT
    1.76  # SliTaz package receipt.
    1.77  # generated by tazpkg from puppy package $(basename "$PACKAGE_FILE")
    1.78 @@ -310,20 +312,23 @@
    1.79  SHORT_DESC="$desc"
    1.80  WEB_SITE="http://puppylinux.org/"
    1.81  MAINTAINER="nobody@slitaz.org"
    1.82 -DEPENDS="$(find_depends)"
    1.83 +DEPENDS="$(find_depends .)"
    1.84  EOT
    1.85  	show_unresolved_lib "$file/receipt"
    1.86  	for i in install uninstall; do
    1.87 -		[ -f "$file/fs/p$i.sh" ] && cat >> "$file/receipt" <<EOM
    1.88 +		if [ -f "$file/fs/p$i.sh" ]; then
    1.89 +			SEPARATOR="EOT$RANDOM"
    1.90 +			cat >> "$file/receipt" <<EOT
    1.91  
    1.92  post_$i()
    1.93  {
    1.94 -chroot \$1/ sh - << EOT
    1.95 -cd /
    1.96 -$(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < "$file/fs/p$i.sh" ; rm -f "$file/fs/p$i.sh")
    1.97 +chroot \$1/ sh - <<$SEPARATOR
    1.98 +	cd /
    1.99 +	$(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < "$file/fs/p$i.sh" ; rm -f "$file/fs/p$i.sh")
   1.100 +$SEPARATOR
   1.101 +}
   1.102  EOT
   1.103 -}
   1.104 -EOM
   1.105 +		fi
   1.106  	done
   1.107  	sed -i 's/post_uninstall/post_remove/' "$file/receipt"
   1.108  	tazpkg pack "$file"
   1.109 @@ -355,12 +360,22 @@
   1.110  # convert a .pet package to .tazpkg
   1.111  
   1.112  convert_pet() {
   1.113 +	debug "convert_pet()"
   1.114  	mkdir -p "$TMP_DIR"
   1.115  	cd "$TMP_DIR"
   1.116  	parse_pkgname .pet
   1.117 -	tar -xzf "$PACKAGE_FILE" 2>/dev/null
   1.118 -	. $package*/*.specs
   1.119 -	desc="$PETMENUDESCR"
   1.120 +	busybox tar -xzf "$PACKAGE_FILE"
   1.121 +
   1.122 +	PET_SPECS="$(find $TMP_DIR -maxdepth 2 -name 'pet.specs')"
   1.123 +	if [ -e "$PET_SPECS" ]; then
   1.124 +		debug "pet.specs with '|'"
   1.125 +		desc="$(awk -F'|' '{print $10}' $PET_SPECS)"
   1.126 +		debug "desc='$desc'"
   1.127 +	else
   1.128 +		# TODO: I need to have '.pet' file that will work this way!
   1.129 +		. $package*/*.specs
   1.130 +		desc="$PETMENUDESCR"
   1.131 +	fi
   1.132  	mv $package*/ fs
   1.133  	finish_convert_puppy
   1.134  }
   1.135 @@ -391,7 +406,7 @@
   1.136  SHORT_DESC="$desc"
   1.137  WEB_SITE="http://www.slax.org/"
   1.138  MAINTAINER="nobody@slitaz.org"
   1.139 -DEPENDS="$(find_depends)"
   1.140 +DEPENDS="$(find_depends .)"
   1.141  EOT
   1.142  	show_unresolved_lib "$file/receipt"
   1.143  	[ -f $file/fs/var/log/scripts/$package* ] && cat >> "$file/receipt" <<EOM
   1.144 @@ -433,7 +448,7 @@
   1.145  SHORT_DESC="$descrip"
   1.146  WEB_SITE="http://www.slackware.com/packages/"
   1.147  MAINTAINER="nobody@slitaz.org"
   1.148 -DEPENDS="$(find_depends)"
   1.149 +DEPENDS="$(find_depends .)"
   1.150  EOT
   1.151  		show_unresolved_lib "$file/receipt"
   1.152  		[ -f "$file/fs/install/doinst.sh" ] && cat >> "$file/receipt" <<EOM
   1.153 @@ -490,7 +505,7 @@
   1.154  		  "$PACKAGE_FILE" $TMP_DIR/$file/fs/usr/share/doc/*/copyright | \
   1.155  		  sed 's|.*common-licenses/\([-\.A-Za-z0-9]*\).*|\1|;s|[-\.]$||;q')
   1.156  		[ -n "$LICENSE" ] && echo "LICENSE=\"$LICENSE\"" >> "$file/receipt"
   1.157 -		echo "DEPENDS=\"$(find_depends)\"" >> "$file/receipt"
   1.158 +		echo "DEPENDS=\"$(find_depends .)\"" >> "$file/receipt"
   1.159  		[ -s 'conffiles' ] && cat >> "$file/receipt" <<EOT
   1.160  CONFIG_FILES="$(cat conffiles)"
   1.161  EOT
   1.162 @@ -575,7 +590,7 @@
   1.163  		fi
   1.164  	fi
   1.165  	cd ../..
   1.166 -	echo "DEPENDS=\"$(find_depends)\"" >> "$TMP_DIR/$file/receipt"
   1.167 +	echo "DEPENDS=\"$(find_depends .)\"" >> "$TMP_DIR/$file/receipt"
   1.168  	show_unresolved_lib "$TMP_DIR/$file/receipt"
   1.169  	tazpkg pack "$file"
   1.170  	mv "$file.tazpkg" "$TOP_DIR"
   1.171 @@ -622,7 +637,7 @@
   1.172  HOST_ARCH="$HOST_ARCH"
   1.173  CONFIG_FILES="$(sed '/<key>conf_files<\/key>/,/<key>/!d;/array>/d;/<key>/d;s/.*>\(.*\)<.*/\1/' fs/props.plist)"
   1.174  
   1.175 -DEPENDS="$(find_depends)"
   1.176 +DEPENDS="$(find_depends .)"
   1.177  
   1.178  EOT
   1.179  		while read script func ; do
   1.180 @@ -669,7 +684,7 @@
   1.181  SHORT_DESC="tinycore package $(basename "$PACKAGE_FILE")"
   1.182  WEB_SITE="http://tinycorelinux.net/"
   1.183  MAINTAINER="nobody@slitaz.org"
   1.184 -DEPENDS="$(find_depends)"
   1.185 +DEPENDS="$(find_depends .)"
   1.186  EOT
   1.187  	show_unresolved_lib "$file/receipt"
   1.188  	script="$file/fs/usr/local/tce.installed/$PACKAGE"
   1.189 @@ -729,6 +744,9 @@
   1.190  }
   1.191  
   1.192  
   1.193 +
   1.194 +PACKAGE_FILE="$(realpath "$PACKAGE_FILE")"
   1.195 +debug "PACKAGE_FILE='$PACKAGE_FILE'"
   1.196  if [ "$(dd if="$PACKAGE_FILE" bs=8 count=1 skip=1 2>/dev/null)" == 'debian-b' ]; then
   1.197  	convert_deb
   1.198  else