cookutils rev 999

cook: move mk_pkg_receipt() into module. Fix bug here: when main package was listed in $SPLIT, it was dependent on itself.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Nov 04 05:07:30 2017 +0200 (2017-11-04)
parents ae3975981d3f
children d807a30eadfe
files Makefile cook modules/mk_pkg_receipt
line diff
     1.1 --- a/Makefile	Sat Nov 04 04:02:57 2017 +0200
     1.2 +++ b/Makefile	Sat Nov 04 05:07:30 2017 +0200
     1.3 @@ -31,6 +31,7 @@
     1.4  	install -m 0755 modules/pkgdb \
     1.5  					modules/compressor \
     1.6  					modules/deps \
     1.7 +					modules/mk_pkg_receipt \
     1.8  									 $(DESTDIR)$(PREFIX)/libexec/cookutils
     1.9  	install -m 0644 cook.conf        $(DESTDIR)/etc/slitaz
    1.10  	install -m 0644 cook.site        $(DESTDIR)/etc/slitaz
     2.1 --- a/cook	Sat Nov 04 04:02:57 2017 +0200
     2.2 +++ b/cook	Sat Nov 04 05:07:30 2017 +0200
     2.3 @@ -856,95 +856,6 @@
     2.4  }
     2.5  
     2.6  
     2.7 -# Receipt used for cooking the package is redundant to be included into package.
     2.8 -# This script will strip the original receipt to bare minimum: variables,
     2.9 -# {pre,post}_{install,remove} functions.
    2.10 -
    2.11 -mk_pkg_receipt() {
    2.12 -	orig_receipt="$1"
    2.13 -
    2.14 -	# Receipt's signature is important, although some receipts may miss it
    2.15 -	signature=$(head -n1 "$orig_receipt")
    2.16 -	[ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.'
    2.17 -
    2.18 -	save_PACKAGE="$PACKAGE"; save_DEPENDS="$DEPENDS"; save_PROVIDE="$PROVIDE"
    2.19 -	save_SUGGESTED="$SUGGESTED"; save_TAZPANEL_DAEMON="$TAZPANEL_DAEMON"
    2.20 -	save_TAGS="$TAGS"
    2.21 -	unset_receipt
    2.22 -	. "$orig_receipt"
    2.23 -	PACKAGE="$save_PACKAGE"; DEPENDS="$save_DEPENDS"; PROVIDE="$save_PROVIDE"
    2.24 -	SUGGESTED="$save_SUGGESTED"; TAZPANEL_DAEMON="$save_TAZPANEL_DAEMON"
    2.25 -	TAGS="$save_TAGS"
    2.26 -
    2.27 -	# Manage split packages
    2.28 -	SPLIT=" $SPLIT "
    2.29 -	if [ "$SPLIT" != '  ' -a "${SPLIT/ $PACKAGE /}" != "$SPLIT" ]; then
    2.30 -		# For packages with empty $DEPENDS
    2.31 -		if [ -z "$DEPENDS" ]; then
    2.32 -			case $PACKAGE in
    2.33 -				*-dev)
    2.34 -					# main package and all the split packages but this *-dev itself
    2.35 -					DEPENDS=$(echo "$pkg $SPLIT " | sed "s| $PACKAGE | |; s| *$||") ;;
    2.36 -				*)
    2.37 -					# main package
    2.38 -					DEPENDS="$pkg" ;;
    2.39 -			esac
    2.40 -		fi
    2.41 -
    2.42 -		# Default $CAT
    2.43 -		[ -z "$CAT" ] &&
    2.44 -		case $PACKAGE in
    2.45 -			*-dev) CAT="development|development files" ;;
    2.46 -		esac
    2.47 -	fi
    2.48 -
    2.49 -	# Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION"
    2.50 -	if [ -n "$CAT" ]; then
    2.51 -		CATEGORY="${CAT%|*}"
    2.52 -		SHORT_DESC="$SHORT_DESC (${CAT#*|})"
    2.53 -	fi
    2.54 -
    2.55 -	# escape quotes for receipt
    2.56 -	SHORT_DESC="${SHORT_DESC//\"/\\\"}"
    2.57 -
    2.58 -	# Mandatory variables
    2.59 -	cat <<EOF
    2.60 -$signature
    2.61 -
    2.62 -PACKAGE="$PACKAGE"
    2.63 -VERSION="$VERSION"
    2.64 -CATEGORY="$CATEGORY"
    2.65 -SHORT_DESC="$SHORT_DESC"
    2.66 -MAINTAINER="$MAINTAINER"
    2.67 -LICENSE="$LICENSE"
    2.68 -WEB_SITE="$WEB_SITE"
    2.69 -EOF
    2.70 -
    2.71 -	# Optional variables
    2.72 -	[ -n "$TAGS" ]    && echo "TAGS=\"$TAGS\"" | tr -ds '\t' ' '
    2.73 -	[ -n "${DEPENDS# }" ] && echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' '
    2.74 -	[ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" | tr -ds '\t' ' '
    2.75 -	[ -n "$CONFIG_FILES" ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
    2.76 -	[ -n "$SUGGESTED" ] && echo "SUGGESTED=\"$SUGGESTED\"" | tr -ds '\t' ' '
    2.77 -	[ -n "$DATABASE_FILES" ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
    2.78 -	[ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
    2.79 -
    2.80 -	# Extract {pre,post}_{install,remove} functions;
    2.81 -	# post_install()      will be copied for both main and all the split packages
    2.82 -	# post_install_gtk_() will be copied as post_install() for gtk+ package only
    2.83 -	#
    2.84 -	# restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
    2.85 -	rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
    2.86 -	for i in pre post; do
    2.87 -		for j in install remove; do
    2.88 -			sed "/^${i}_${j}()/,/^}/!d" "$orig_receipt"
    2.89 -			sed "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" | \
    2.90 -				sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
    2.91 -		done
    2.92 -	done
    2.93 -}
    2.94 -
    2.95 -
    2.96  # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
    2.97  # but it doesn't handle EXTRAVERSION.
    2.98  
    2.99 @@ -990,7 +901,7 @@
   2.100  
   2.101  	cd $taz
   2.102  	action 'Copying "%s"...' 'receipt'
   2.103 -	mk_pkg_receipt ../receipt > $pack/receipt
   2.104 +	@@PREFIX@@/libexec/cookutils/mk_pkg_receipt ../receipt > $pack/receipt
   2.105  	chown 0.0 $pack/receipt; status
   2.106  
   2.107  	unset desc
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/modules/mk_pkg_receipt	Sat Nov 04 05:07:30 2017 +0200
     3.3 @@ -0,0 +1,96 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# mk_pkg_receipt - module of the SliTaz Cook
     3.7 +# Copyright (C) SliTaz GNU/Linux - GNU GPL v3
     3.8 +#
     3.9 +
    3.10 +# Receipt used for cooking the package is redundant to be included into package.
    3.11 +# This script will strip the original receipt to bare minimum: variables,
    3.12 +# {pre,post}_{install,remove} functions.
    3.13 +
    3.14 +. /usr/lib/slitaz/libcook.sh
    3.15 +
    3.16 +orig_receipt="$1"
    3.17 +
    3.18 +# Receipt's signature is important, although some receipts may miss it
    3.19 +signature=$(head -n1 "$orig_receipt")
    3.20 +[ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.'
    3.21 +
    3.22 +save="$(mktemp)"
    3.23 +cat > $save <<EOT
    3.24 +PACKAGE="$PACKAGE"; DEPENDS="$DEPENDS"; PROVIDE="$PROVIDE"
    3.25 +SUGGESTED="$SUGGESTED"; TAZPANEL_DAEMON="$TAZPANEL_DAEMON"
    3.26 +TAGS="$TAGS"
    3.27 +EOT
    3.28 +unset_receipt
    3.29 +. "$orig_receipt"
    3.30 +MAIN_PACKAGE="$PACKAGE"
    3.31 +. $save; rm $save # restore values
    3.32 +
    3.33 +# Manage split packages
    3.34 +SPLIT=" $SPLIT "
    3.35 +if [ "$PACKAGE"             != "$MAIN_PACKAGE" -a \
    3.36 +	 "$SPLIT"               != '  '            -a \
    3.37 +	 "${SPLIT/ $PACKAGE /}" != "$SPLIT" ]; then
    3.38 +	# For packages with empty $DEPENDS
    3.39 +	if [ -z "$DEPENDS" ]; then
    3.40 +		case $PACKAGE in
    3.41 +			*-dev)
    3.42 +				# main package and all the split packages but this *-dev itself
    3.43 +				DEPENDS=$(echo "$MAIN_PACKAGE $SPLIT " | sed "s| $PACKAGE | |; s| *$||");;
    3.44 +			*)
    3.45 +				DEPENDS="$MAIN_PACKAGE";;
    3.46 +		esac
    3.47 +	fi
    3.48 +
    3.49 +	# Default $CAT
    3.50 +	[ -z "$CAT" ] &&
    3.51 +	case $PACKAGE in
    3.52 +		*-dev) CAT="development|development files" ;;
    3.53 +	esac
    3.54 +fi
    3.55 +
    3.56 +# Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION"
    3.57 +if [ -n "$CAT" ]; then
    3.58 +	CATEGORY="${CAT%|*}"
    3.59 +	SHORT_DESC="$SHORT_DESC (${CAT#*|})"
    3.60 +fi
    3.61 +
    3.62 +# escape quotes for receipt
    3.63 +SHORT_DESC="${SHORT_DESC//\"/\\\"}"
    3.64 +
    3.65 +# Mandatory variables
    3.66 +cat <<EOF
    3.67 +$signature
    3.68 +
    3.69 +PACKAGE="$PACKAGE"
    3.70 +VERSION="$VERSION"
    3.71 +CATEGORY="$CATEGORY"
    3.72 +SHORT_DESC="$SHORT_DESC"
    3.73 +MAINTAINER="$MAINTAINER"
    3.74 +LICENSE="$LICENSE"
    3.75 +WEB_SITE="$WEB_SITE"
    3.76 +EOF
    3.77 +
    3.78 +# Optional variables
    3.79 +[ -n "$TAGS"            ] && echo "TAGS=\"$TAGS\""                 | tr -ds '\t' ' '
    3.80 +[ -n "${DEPENDS# }"     ] && echo "DEPENDS=\"$DEPENDS\""           | tr -ds '\t' ' '
    3.81 +[ -n "$PROVIDE"         ] && echo "PROVIDE=\"$PROVIDE\""           | tr -ds '\t' ' '
    3.82 +[ -n "$CONFIG_FILES"    ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
    3.83 +[ -n "$SUGGESTED"       ] && echo "SUGGESTED=\"$SUGGESTED\""       | tr -ds '\t' ' '
    3.84 +[ -n "$DATABASE_FILES"  ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
    3.85 +[ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
    3.86 +
    3.87 +# Extract {pre,post}_{install,remove} functions;
    3.88 +# post_install()      will be copied for both main and all the split packages
    3.89 +# post_install_gtk_() will be copied as post_install() for gtk+ package only
    3.90 +#
    3.91 +# restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
    3.92 +rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
    3.93 +for i in pre post; do
    3.94 +	for j in install remove; do
    3.95 +		sed    "/^${i}_${j}()/,/^}/!d"        "$orig_receipt"
    3.96 +		sed    "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" \
    3.97 +		| sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
    3.98 +	done
    3.99 +done