cookutils view modules/mk_pkg_receipt @ rev 1078

cook: allow multi-set & no-src receipts (sources may be downloaded inside compile_rules() individually for each set), allow change SHORT_DESC & WEB_SITE in genpkg_rules() (for differents sets);
lighttpd/cooker.css: add style for log line "Switching to the set...";
lighttpd/index.cgi: remove false-positive coloring with word "fatal", mark line "Switching to the set...", don't hide "Logs" button (fresh log initially empty and it may lasts for many seconds due to buffered "lazy write";
modules/compressor: better remove unwanted Perl files;
modules/mk_pkg_receipt: follow changed SHORT_DESC & WEB_SITE, improve condition speed (from 10 sec to 0.01 sec) when SPLIT is relatively long - looks like ${A/ $B /} is slow.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jun 21 12:57:52 2018 +0300 (2018-06-21)
parents 96366a824c1e
children 64c16be1dda4
line source
1 #!/bin/sh
2 #
3 # mk_pkg_receipt - module of the SliTaz Cook
4 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
5 #
7 # Receipt used for cooking the package is redundant to be included into package.
8 # This script will strip the original receipt to bare minimum: variables,
9 # {pre,post}_{install,remove} functions.
11 . /usr/lib/slitaz/libcook.sh
13 orig_receipt="$1"
15 # 1. Main package.
16 # By default it has no dependencies.
17 # You can write or omit DEPENDS="" for indicating package have no dependencies.
18 # 2. Split package (excluding *-dev).
19 # By default every split package depends on the main package.
20 # Unfortunately, in the shell script (receipt is the shell script too),
21 # every undeclared variable has empty value, so there's no difference if you
22 # wrote DEPENDS="" or omit it - result will be the same empty value.
23 # If you want to define the split package has no dependencies - you need to
24 # to put single space between the quotes: DEPENDS=" ".
25 # 3. Development split package.
26 # Installing *-dev package should install all the files produced during
27 # compilation and then were separated to the different packages, so
28 # by default (if you wrote DEPENDS="" or omit it) *-dev package depends on
29 # the main package and all the split packages (excluding the itself).
30 [ "$DEPENDS" == ' ' ] && DEPENDS='@EMPTY@'
32 # Receipt's signature is important, although some receipts may miss it
33 signature=$(head -n1 "$orig_receipt")
34 [ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.'
36 save="$(mktemp)"
37 # `$(echo ...)`: normalize whitespace (space, tab, newline and their combinations and repeats)
38 cat > $save <<EOT
39 PACKAGE="$PACKAGE"; DEPENDS="$(echo $DEPENDS)"; PROVIDE="$(echo $PROVIDE)"
40 SUGGESTED="$(echo $SUGGESTED)"; TAZPANEL_DAEMON="$TAZPANEL_DAEMON"
41 TAGS="$(echo $TAGS)"; VERSION="$VERSION"; SHORT_DESC="$SHORT_DESC"
42 WEB_SITE="$WEB_SITE"
43 EOT
44 unset_receipt
45 . "$orig_receipt"
46 MAIN_PACKAGE="$PACKAGE"
47 . $save; rm $save # restore values
49 # Manage split packages
50 SPLIT=" $SPLIT "
51 if [ "$PACKAGE" != "$MAIN_PACKAGE" -a "$SPLIT" != ' ' ] &&
52 echo "$SPLIT" | fgrep -q " $PACKAGE "; then
53 # For packages with empty $DEPENDS
54 if [ -z "$DEPENDS" ]; then
55 case $PACKAGE in
56 *-dev)
57 # main package and all the split packages but this *-dev itself
58 DEPENDS=$(echo "$MAIN_PACKAGE $SPLIT " | sed "s| $PACKAGE | |; s| *$||");;
59 *)
60 DEPENDS="$MAIN_PACKAGE";;
61 esac
62 fi
64 # Default $CAT
65 [ -z "$CAT" ] &&
66 case $PACKAGE in
67 *-dev) CAT="development|development files" ;;
68 esac
69 fi
71 # Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION"
72 if [ -n "$CAT" ]; then
73 CATEGORY="${CAT%|*}"
74 SHORT_DESC="$SHORT_DESC (${CAT#*|})"
75 fi
77 # escape quotes for receipt
78 SHORT_DESC="${SHORT_DESC//\"/\\\"}"
80 # Mandatory variables
81 cat <<EOF
82 $signature
84 PACKAGE="$PACKAGE"
85 VERSION="$VERSION"
86 EOF
87 [ -n "$EXTRAVERSION" ] && echo "EXTRAVERSION=\"$EXTRAVERSION\""
88 cat <<EOF
89 CATEGORY="$CATEGORY"
90 SHORT_DESC="$SHORT_DESC"
91 MAINTAINER="$MAINTAINER"
92 LICENSE="$LICENSE"
93 WEB_SITE="$WEB_SITE"
94 EOF
96 # Optional variables
97 [ -n "$TAGS" ] && echo "TAGS=\"$TAGS\"" | tr -ds '\t' ' '
98 case "x$DEPENDS" in
99 x|x@EMPTY@) ;;
100 *) echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' ';;
101 esac
102 [ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" | tr -ds '\t' ' '
103 [ -n "$CONFIG_FILES" ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
104 [ -n "$SUGGESTED" ] && echo "SUGGESTED=\"$SUGGESTED\"" | tr -ds '\t' ' '
105 [ -n "$DATABASE_FILES" ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
106 [ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
108 # Extract {pre,post}_{install,remove} functions;
109 # post_install() will be copied for both main and all the split packages
110 # post_install_gtk_() will be copied as post_install() for gtk+ package only
111 #
112 # restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
113 rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
114 for i in pre post; do
115 for j in install remove; do
116 sed "/^${i}_${j}()/,/^}/!d" "$orig_receipt"
117 sed "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" \
118 | sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
119 done
120 done