cookutils rev 1012

Separate modules/precheck from cook (next will be modules/getsrc); cook: fix bug preventing meta-packages to be included in receipt v2; lighttpd/index.cgi: show cooker state in the title (web browser show special icon if background page title has changed).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Nov 24 14:39:52 2017 +0200 (2017-11-24)
parents 46fe75e9b709
children 47059b5d1648
files Makefile cook lighttpd/index.cgi modules/precheck
line diff
     1.1 --- a/Makefile	Wed Nov 22 20:06:06 2017 +0200
     1.2 +++ b/Makefile	Fri Nov 24 14:39:52 2017 +0200
     1.3 @@ -32,6 +32,7 @@
     1.4  					modules/compressor \
     1.5  					modules/deps \
     1.6  					modules/mk_pkg_receipt \
     1.7 +					modules/precheck \
     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	Wed Nov 22 20:06:06 2017 +0200
     2.2 +++ b/cook	Fri Nov 24 14:39:52 2017 +0200
     2.3 @@ -96,38 +96,6 @@
     2.4  }
     2.5  
     2.6  
     2.7 -# QA: check a receipt consistency before building.
     2.8 -
     2.9 -receipt_quality() {
    2.10 -	_ 'QA: checking package receipt...'
    2.11 -
    2.12 -	for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do
    2.13 -		unset value
    2.14 -		value="$(. $receipt; eval echo \$$var)"
    2.15 -		# L10n: QA is quality assurance
    2.16 -		[ -n "$value" ] || die 'QA: empty variable: %s' "$var=\"\""
    2.17 -
    2.18 -		case "$var" in
    2.19 -			CATEGORY)
    2.20 -				valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
    2.21 -				if ! echo " $valid " | grep -q " $value "; then
    2.22 -					_ 'QA: unknown category "%s"' "$value"
    2.23 -					die 'Please, use one of: %s' "$valid"
    2.24 -				fi
    2.25 -				;;
    2.26 -			WEB_SITE)
    2.27 -				# We don't check WGET_URL since if dl is needed it will fail.
    2.28 -				# Break also if we're not online. Here error is not fatal.
    2.29 -				if ifconfig | grep -A1 '^[a-z]*[0-9]' | fgrep -q 'addr:' && \
    2.30 -				! busybox wget -T 12 --spider $value 2>/dev/null; then
    2.31 -					_ 'QA: unable to reach "%s"' "$value"
    2.32 -				fi
    2.33 -				;;
    2.34 -		esac
    2.35 -	done
    2.36 -}
    2.37 -
    2.38 -
    2.39  # Paths used in receipt and by cook itself.
    2.40  
    2.41  set_paths() {
    2.42 @@ -603,7 +571,7 @@
    2.43  			;;
    2.44  	esac
    2.45  
    2.46 -	[ -n "$QA" ] && receipt_quality
    2.47 +	[ -n "$QA" ] && @@PREFIX@@/libexec/cookutils/precheck $receipt # former receipt_quality()
    2.48  
    2.49  	cd $pkgdir
    2.50  	[ -z "$continue" ] && rm -rf source 2>/dev/null
    2.51 @@ -1048,6 +1016,8 @@
    2.52  		fi
    2.53  	fi
    2.54  
    2.55 +	[ -n "$CAT" ] && CATEGORY="${CAT%|*}"	# allow meta-packages in v2 receipts
    2.56 +
    2.57  	if [ "${COOKOPTS/empty-pkg/}" == "$COOKOPTS" ]; then
    2.58  		action 'QA: checking for empty package...'
    2.59  		if [ ! -s "$pack/files.list" -a "$CATEGORY" != 'meta' ]; then
     3.1 --- a/lighttpd/index.cgi	Wed Nov 22 20:06:06 2017 +0200
     3.2 +++ b/lighttpd/index.cgi	Fri Nov 24 14:39:52 2017 +0200
     3.3 @@ -78,19 +78,26 @@
     3.4  # HTML page header
     3.5  
     3.6  page_header() {
     3.7 -	local theme t='' css
     3.8 +	local theme t='' css pretitle='' cmd
     3.9  	theme=$(COOKIE theme)
    3.10  	[ "$theme" == 'default' ] && theme=''
    3.11  	[ -n "$theme" ] && theme="-$theme"
    3.12  	css="cooker$theme.css"
    3.13  
    3.14 +	if [ -n "$pkg" ]; then
    3.15 +		pretitle="$pkg - "
    3.16 +	else
    3.17 +		cmd="$(cat $command)"
    3.18 +		[ -n "$cmd" ] && pretitle="$cmd - "
    3.19 +	fi
    3.20 +
    3.21  	echo -e 'Content-Type: text/html; charset=UTF-8\n'
    3.22  
    3.23  	cat <<EOT
    3.24  <!DOCTYPE html>
    3.25  <html lang="en">
    3.26  <head>
    3.27 -	<title>$([ -n "$pkg" ] && echo "$pkg - ")$title</title>
    3.28 +	<title>$pretitle$title</title>
    3.29  	<link rel="stylesheet" href="/$css">
    3.30  	<link rel="icon" type="image/png" href="/slitaz-cooker.png">
    3.31  	<link rel="search" href="$base/os.xml" title="$title" type="application/opensearchdescription+xml">
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/modules/precheck	Fri Nov 24 14:39:52 2017 +0200
     4.3 @@ -0,0 +1,38 @@
     4.4 +#!/bin/sh
     4.5 +#
     4.6 +# precheck - module of the SliTaz Cook
     4.7 +# Preliminary checks of the receipt, made before the beginning of work.
     4.8 +# Copyright (C) SliTaz GNU/Linux - GNU GPL v3
     4.9 +#
    4.10 +
    4.11 +. /usr/lib/slitaz/libcook.sh
    4.12 +
    4.13 +
    4.14 +receipt="$(realpath $1)"
    4.15 +
    4.16 +_ 'QA: checking package receipt...'
    4.17 +
    4.18 +for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do
    4.19 +	unset value
    4.20 +	value="$(. $receipt; eval echo \$$var)"
    4.21 +	# L10n: QA is quality assurance
    4.22 +	[ -n "$value" ] || die 'QA: empty variable: %s' "$var=\"\""
    4.23 +
    4.24 +	case "$var" in
    4.25 +		CATEGORY)
    4.26 +			valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
    4.27 +			if ! echo " $valid " | grep -q " $value "; then
    4.28 +				_ 'QA: unknown category "%s"' "$value"
    4.29 +				die 'Please, use one of: %s' "$valid"
    4.30 +			fi
    4.31 +			;;
    4.32 +		WEB_SITE)
    4.33 +			# We don't check WGET_URL since if dl is needed it will fail.
    4.34 +			# Break also if we're not online. Here error is not fatal.
    4.35 +			if ifconfig | grep -A1 '^[a-z]*[0-9]' | fgrep -q 'addr:' &&
    4.36 +			! busybox wget -T 12 --spider $value 2>/dev/null; then
    4.37 +				_ 'QA: unable to reach "%s"' "$value"
    4.38 +			fi
    4.39 +			;;
    4.40 +	esac
    4.41 +done