From f8d4ce3d0e9b384a66286901f6680c835af76284 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 23 Aug 2017 16:05:40 -0700 Subject: Implement a script for checking packages Then use this script to check that all packages can be extracted and patched. Signed-off-by: Alexey Neyman --- maintainer/kconfig-versions.template | 6 ++ maintainer/package-versions.template | 13 +++ maintainer/test-packages.sh | 190 +++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 maintainer/package-versions.template create mode 100755 maintainer/test-packages.sh (limited to 'maintainer') diff --git a/maintainer/kconfig-versions.template b/maintainer/kconfig-versions.template index 4692a254..c16bb772 100644 --- a/maintainer/kconfig-versions.template +++ b/maintainer/kconfig-versions.template @@ -252,10 +252,16 @@ config @@pfx@@_MIRRORS config @@pfx@@_ARCHIVE_FILENAME string +#!foreach version + default "@@archive_filename@@" if @@pfx@@_V_@@kcfg@@ +#!end-foreach default "@@archive_filename@@" config @@pfx@@_ARCHIVE_DIRNAME string +#!foreach version + default "@@archive_dirname@@" if @@pfx@@_V_@@kcfg@@ +#!end-foreach default "@@archive_dirname@@" config @@pfx@@_ARCHIVE_FORMATS diff --git a/maintainer/package-versions.template b/maintainer/package-versions.template new file mode 100644 index 00000000..36451620 --- /dev/null +++ b/maintainer/package-versions.template @@ -0,0 +1,13 @@ +#!foreach fork +#!foreach version +run_pkgversion \ + master=@@master@@ \ + masterpfx=@@masterpfx@@ \ + originpfx=@@originpfx@@ \ + pkg_name=@@pkg_name@@ \ + pfx=@@pfx@@ \ + versionlocked=@@versionlocked@@ \ + ver=@@ver@@ \ + kcfg=@@kcfg@@ +#!end-foreach +#!end-foreach diff --git a/maintainer/test-packages.sh b/maintainer/test-packages.sh new file mode 100755 index 00000000..7a19651d --- /dev/null +++ b/maintainer/test-packages.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +selected= + +usage() +{ + cat <&2; exit 1; } + selected="${1}" + ;; + --help|-?) + usage + exit 0 + ;; + *) + echo "Unknown option ${1}" >&2 + exit 1 + ;; + esac + shift +done + +CT_LIB_DIR=`pwd` +CT_TOP_DIR=`pwd` +CT_TARBALLS_DIR=`pwd`/temp.tarballs +CT_COMMON_SRC_DIR=`pwd`/temp.src +CT_SRC_DIR=`pwd`/temp.src +CT_LOG_LEVEL_MAX=EXTRA +mkdir -p ${CT_TARBALLS_DIR} + +# Does not matter, just to make the scripts load +CT_ARCH=arm +CT_KERNEL=bare-metal +CT_BINUTILS=binutils +CT_LIBC=none +CT_CC=gcc + +. paths.sh +. scripts/functions + +rm -f build.log +CT_LogEnable + +check_pkg_urls() +{ + local e m mh url + + for e in ${archive_formats}; do + local -A mirror_status=( ) + + CT_DoStep EXTRA "Looking for ${archive_filename}${e}" + for m in ${mirrors}; do + url="${m}/${archive_filename}${e}" + mh="${m#*://}" + mh="${mh%%[:/]*}" + if [ -n "${mirror_status[${mh}]}" ]; then + CT_DoLog DEBUG "Skipping '${url}': already found on this host at '${mirror_status[${mh}]}'" + continue + fi + if CT_DoExecLog ALL wget --spider "${url}"; then + mirror_status[${mh}]="${url}" + else + mirror_status[${mh}]= + fi + done + for mh in "${!mirror_status[@]}"; do + if [ -n "${mirror_status[${mh}]}" ]; then + CT_DoLog EXTRA "OK ${mh} [${archive_filename}${e}]" + else + CT_DoLog ERROR "FAIL ${mh} [${archive_filename}${e}]" + fi + done + CT_EndStep + done +} + +run_pkgversion() +{ + while [ -n "${1}" ]; do + eval "local ${1}" + shift + done + + if [ -n "${selected}" ]; then + case "${selected}" in + ${pkg_name}|${pkg_name}-${ver}) + ;; + *) + return + ;; + esac + fi + + CT_DoStep INFO "Handling ${pkg_name}-${ver}" + + # Create a temporary configuration head file + cat >temp.in <temp.defconfig </dev/null + + CT_LoadConfig + rm -f .config .config.old temp.defconfig temp.in + if [ -n "${verify_urls}" ]; then + CT_DoLog EXTRA "Verifying URLs for ${pkg_name}-${ver}" + CT_PackageRun "${masterpfx}" check_pkg_urls + fi + if [ -n "${download_pkgs}" ]; then + CT_DoLog EXTRA "Downloading ${pkg_name}-${ver}" + CT_Fetch "${masterpfx}" + fi + if [ -n "${apply_patches}" ]; then + rm -rf ${CT_COMMON_SRC_DIR} + mkdir -p ${CT_COMMON_SRC_DIR} + CT_ExtractPatch "${masterpfx}" + fi + + CT_EndStep +} + +. maintainer/package-versions + +rm -rf ${CT_TARBALLS_DIR} ${CT_COMMON_SRC_DIR} -- cgit v1.2.3 From 373f22648f3013a7b7bc1e601faf2878c03ce42f Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 23 Aug 2017 23:56:40 -0700 Subject: Skip ftp:// URLs, wget cannot verify them Signed-off-by: Alexey Neyman --- TODO | 6 ++++++ maintainer/test-packages.sh | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'maintainer') diff --git a/TODO b/TODO index e75103cd..0653f76a 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,12 @@ A (slightly) ordered set of tasks for crosstool-NG. Written in a cryptic languag -- Alexey Neyman (@stilor) +[ ] test-packages.sh + [ ] FTP URLs always succeed in verification (wget bug) - how to work around? + [ ] new function - refresh/renumber patches +[ ] templates (bootstrap) + [ ] #!foreach xxx if-changed yyy to avoid unnecessary 'default' lines + [ ] relevant pattern for Linaro releases - tie to the major version [ ] new packages [ ] config.guess [ ] gnulib diff --git a/maintainer/test-packages.sh b/maintainer/test-packages.sh index 7a19651d..26caaf8e 100755 --- a/maintainer/test-packages.sh +++ b/maintainer/test-packages.sh @@ -92,7 +92,11 @@ check_pkg_urls() CT_DoStep EXTRA "Looking for ${archive_filename}${e}" for m in ${mirrors}; do url="${m}/${archive_filename}${e}" - mh="${m#*://}" + case "${url}" in + # WGET always returns success for FTP URLs in spider mode :( + ftp://*) CT_DoLog DEBUG "Skipping '${url}': FTP not supported"; continue;; + esac + mh="${url#*://}" mh="${mh%%[:/]*}" if [ -n "${mirror_status[${mh}]}" ]; then CT_DoLog DEBUG "Skipping '${url}': already found on this host at '${mirror_status[${mh}]}'" -- cgit v1.2.3 From b2e2771f853e9fe340d6fbf0813c0615d88c9de7 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 24 Aug 2017 00:23:36 -0700 Subject: MPC: older releases are only on master site Also, Linux stopped making .bz2 tarballs on recent 3.x branches. Signed-off-by: Alexey Neyman --- maintainer/kconfig-versions.template | 3 +++ packages/linux/3.10.107/version.desc | 1 - packages/linux/3.12.74/version.desc | 1 - packages/linux/3.13.11/version.desc | 1 - packages/linux/3.14.79/version.desc | 1 - packages/linux/3.15.10/version.desc | 1 - packages/linux/3.16.46/version.desc | 1 - packages/linux/3.17.8/version.desc | 1 - packages/linux/3.18.66/version.desc | 1 - packages/linux/3.19.8/version.desc | 1 - packages/linux/3.2.91/version.desc | 1 - packages/linux/3.4.113/version.desc | 1 - packages/mpc/0.7/version.desc | 1 + packages/mpc/0.8.2/version.desc | 1 + packages/mpc/0.9/version.desc | 1 + packages/mpc/package.desc | 1 - 16 files changed, 6 insertions(+), 12 deletions(-) (limited to 'maintainer') diff --git a/maintainer/kconfig-versions.template b/maintainer/kconfig-versions.template index c16bb772..01126b00 100644 --- a/maintainer/kconfig-versions.template +++ b/maintainer/kconfig-versions.template @@ -248,6 +248,9 @@ config @@pfx@@_VERSION #!if [ -n "@@all_versions@@" ] config @@pfx@@_MIRRORS string +#!foreach version + default "@@mirrors@@" if @@pfx@@_V_@@kcfg@@ +#!end-foreach default "@@mirrors@@" config @@pfx@@_ARCHIVE_FILENAME diff --git a/packages/linux/3.10.107/version.desc b/packages/linux/3.10.107/version.desc index 19c9b2ee..7c0a082a 100644 --- a/packages/linux/3.10.107/version.desc +++ b/packages/linux/3.10.107/version.desc @@ -1,2 +1 @@ # Not obsolete: used by CentOS7.x, EOL 06/2024 -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.12.74/version.desc b/packages/linux/3.12.74/version.desc index 6d5245de..e69de29b 100644 --- a/packages/linux/3.12.74/version.desc +++ b/packages/linux/3.12.74/version.desc @@ -1 +0,0 @@ -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.13.11/version.desc b/packages/linux/3.13.11/version.desc index 64b2fdfe..89c1908b 100644 --- a/packages/linux/3.13.11/version.desc +++ b/packages/linux/3.13.11/version.desc @@ -1,2 +1 @@ # Not obsolete: used by Ubuntu14.04, EOL 04/2019 -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.14.79/version.desc b/packages/linux/3.14.79/version.desc index 40f81bc2..fcfe3891 100644 --- a/packages/linux/3.14.79/version.desc +++ b/packages/linux/3.14.79/version.desc @@ -1,2 +1 @@ obsolete='yes' -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.15.10/version.desc b/packages/linux/3.15.10/version.desc index 40f81bc2..fcfe3891 100644 --- a/packages/linux/3.15.10/version.desc +++ b/packages/linux/3.15.10/version.desc @@ -1,2 +1 @@ obsolete='yes' -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.16.46/version.desc b/packages/linux/3.16.46/version.desc index 6d5245de..e69de29b 100644 --- a/packages/linux/3.16.46/version.desc +++ b/packages/linux/3.16.46/version.desc @@ -1 +0,0 @@ -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.17.8/version.desc b/packages/linux/3.17.8/version.desc index 40f81bc2..fcfe3891 100644 --- a/packages/linux/3.17.8/version.desc +++ b/packages/linux/3.17.8/version.desc @@ -1,2 +1 @@ obsolete='yes' -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.18.66/version.desc b/packages/linux/3.18.66/version.desc index 40f81bc2..fcfe3891 100644 --- a/packages/linux/3.18.66/version.desc +++ b/packages/linux/3.18.66/version.desc @@ -1,2 +1 @@ obsolete='yes' -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.19.8/version.desc b/packages/linux/3.19.8/version.desc index 40f81bc2..fcfe3891 100644 --- a/packages/linux/3.19.8/version.desc +++ b/packages/linux/3.19.8/version.desc @@ -1,2 +1 @@ obsolete='yes' -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.2.91/version.desc b/packages/linux/3.2.91/version.desc index 6d5245de..e69de29b 100644 --- a/packages/linux/3.2.91/version.desc +++ b/packages/linux/3.2.91/version.desc @@ -1 +0,0 @@ -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/linux/3.4.113/version.desc b/packages/linux/3.4.113/version.desc index 6d5245de..e69de29b 100644 --- a/packages/linux/3.4.113/version.desc +++ b/packages/linux/3.4.113/version.desc @@ -1 +0,0 @@ -archive_formats='.tar.xz .tar.bz2 .tar.gz' diff --git a/packages/mpc/0.7/version.desc b/packages/mpc/0.7/version.desc index fcfe3891..a5298469 100644 --- a/packages/mpc/0.7/version.desc +++ b/packages/mpc/0.7/version.desc @@ -1 +1,2 @@ obsolete='yes' +mirrors='http://www.multiprecision.org/mpc/download' diff --git a/packages/mpc/0.8.2/version.desc b/packages/mpc/0.8.2/version.desc index fcfe3891..a5298469 100644 --- a/packages/mpc/0.8.2/version.desc +++ b/packages/mpc/0.8.2/version.desc @@ -1 +1,2 @@ obsolete='yes' +mirrors='http://www.multiprecision.org/mpc/download' diff --git a/packages/mpc/0.9/version.desc b/packages/mpc/0.9/version.desc index fcfe3891..a5298469 100644 --- a/packages/mpc/0.9/version.desc +++ b/packages/mpc/0.9/version.desc @@ -1 +1,2 @@ obsolete='yes' +mirrors='http://www.multiprecision.org/mpc/download' diff --git a/packages/mpc/package.desc b/packages/mpc/package.desc index d7165773..04c2ac28 100644 --- a/packages/mpc/package.desc +++ b/packages/mpc/package.desc @@ -1,7 +1,6 @@ repository='git https://scm.gforge.inria.fr/anonscm/git/mpc/mpc.git' bootstrap='autoreconf -i' -# TBD older releases (0.x) missing on GNU mirrors, retire them? mirrors='http://www.multiprecision.org/mpc/download $(CT_Mirrors GNU mpc)' archive_formats='.tar.gz' -- cgit v1.2.3 From 4c1a12f5ddaaf418cea4ca41bac3f5d6f822ee6d Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 24 Aug 2017 14:58:14 -0700 Subject: Add "postprocessing" to substituted variables ... and reduce the number of variables defined explicitly. Signed-off-by: Alexey Neyman --- bootstrap | 63 +++++++++++------- maintainer/kconfig-choice.template | 10 +-- maintainer/kconfig-menu.template | 4 +- maintainer/kconfig-versions.template | 120 +++++++++++++++++------------------ maintainer/package-versions.template | 10 +-- 5 files changed, 111 insertions(+), 96 deletions(-) (limited to 'maintainer') diff --git a/bootstrap b/bootstrap index 8882a6e0..e702dbbc 100755 --- a/bootstrap +++ b/bootstrap @@ -77,13 +77,16 @@ find_end() set_iter() { local name="${1}" + local -a temp if [ "${info[iter_${name}]+set}" = "set" ]; then error "Iterator over '${name}' is already set up" fi shift debug "Setting iterator over '${name}' to '$*'" + temp=("$@") info[iter_${name}]="$*" + info[#${name}]=${#temp[@]} } run_if() @@ -150,7 +153,7 @@ run_lines() { local start="${1}" local end="${2}" - local l lnext s s1 v + local l lnext s s1 v vp pp p val debug "Running lines ${start}..${end}" l=${start} @@ -166,8 +169,34 @@ run_lines() *@@*@@*) v="${s#*@@}" v="${v%%@@*}" + # $v now includes variable name + any postprocessing + vp="${v%%[|?]*}" + pp="${v#${vp}}" + # $vp is name of the variable proper, $pp is any postprocessing + if [ "${info[${vp}]+set}" != "set" ]; then + error "line ${l}: reference to undefined variable '${vp}'" + fi if [ "${info[${v}]+set}" != "set" ]; then - error "line ${l}: reference to undefined variable '${v}'" + # We know the base variable, need to cache postprocessed value + val="${info[${vp}]}" + # Apply postprocessing(s) + while [ -n "${pp}" ]; do + case "${pp}" in + "|"*) + # Kconfigize + pp="${pp#|}" + val=${val//[^0-9A-Za-z_]/_} + val=${val^^} + ;; + "?"*) + pp="${pp#?}" + p="${pp%%[|?]*}" + pp="${pp#${p}}" + val="${val:+${p}}" + ;; + esac + done + info[${v}]="${val}" fi s1="${s1}${s%%@@*}\${info[${v}]}" s="${s#*@@*@@}" @@ -221,15 +250,14 @@ run_template() ######################################## -# Convert the argument to a Kconfig-style macro -kconfigize() +# Leave only relevant portion of the string +relevantize() { - local v="${1}" local p pb pa vx + local v="${1}" shift - # If optional patterns are provided, find the first match - # and contract to the matching portion. + # Find the first match and contract to the matching portion. for p in "$@"; do pb=${p%|*} pa=${p#*|} @@ -239,9 +267,7 @@ kconfigize() break fi done - - v=${v//[^0-9A-Za-z_]/_} - echo "${v^^}" + echo "${v}" } # Helper for cmp_versions: compare an upstream/debian portion of @@ -484,11 +510,11 @@ enter_fork() info[mirrors]= info[archive_filename]='@{pkg_name}-@{version}' info[archive_dirname]='@{pkg_name}-@{version}' + info[versionlocked]= + info[origin]= eval `read_package_desc ${fork}` - info[pfx]=`kconfigize ${fork}` - info[originpfx]=`kconfigize ${info[origin]}` if [ -r "packages/${info[origin]}.help" ]; then info[originhelp]=`sed 's/^/ /' "packages/${info[origin]}.help"` else @@ -499,7 +525,6 @@ enter_fork() info[vcs]=${info[repository]%% *} info[repository_url]=${info[repository]#* } fi - info[versionlocked]=`kconfigize "${info[versionlocked]}"` versions=`cd packages/${fork} && \ for f in */version.desc; do [ -r "${f}" ] && echo "${f%/version.desc}"; done` @@ -525,16 +550,11 @@ enter_fork() enter_version() { - local -A ver_postfix=( \ - [,yes,,]=" (OBSOLETE)" \ - [,,yes,]=" (EXPERIMENTAL)" \ - [,yes,yes,]=" (OBSOLETE,EXPERIMENTAL)" ) local version="${1}" eval `read_version_desc ${info[fork]} ${version}` info[ver]=${version} - info[kcfg]=`kconfigize ${version} ${info[relevantpattern]}` - info[ver_postfix]=${ver_postfix[,${info[obsolete]},${info[experimental]},]} + info[ver_sel]=`relevantize ${version} ${info[relevantpattern]}` } enter_milestone() @@ -543,7 +563,6 @@ enter_milestone() local cmp info[ms]=${ms} - info[ms_kcfg]=`kconfigize ${ms}` if [ -n "${info[ver]}" ]; then info[version_cmp_milestone]=`cmp_versions ${info[ver]} ${info[ms]}` fi @@ -579,9 +598,7 @@ gen_packages() # Base definitions for the whole config file info=( \ [master]=${p} \ - [masterpfx]=`kconfigize ${p}` \ [nforks]=${pkg_nforks[${p}]} \ - [all_milestones]=${pkg_milestones[${p}]} \ [relevantpattern]=${pkg_relevantpattern[${p}]} \ ) set_iter fork ${pkg_forks[${p}]} @@ -615,7 +632,6 @@ enter_choice() local l info[choice]="${choice}" - info[kcfg_choice]=`kconfigize "${choice}"` # Not local, we need these arrays be set in enter_dependency/enter_help deplines=( ) @@ -653,7 +669,6 @@ gen_selection() msg "Generating ${dir}.in" exec >"${config_gen_dir}/${dir}.in" info=( \ - [prefix]=`kconfigize ${dir}` \ [dir]=${dir} \ [label]="${label}" \ ) diff --git a/maintainer/kconfig-choice.template b/maintainer/kconfig-choice.template index 12ea12ca..b2ca2176 100644 --- a/maintainer/kconfig-choice.template +++ b/maintainer/kconfig-choice.template @@ -2,11 +2,11 @@ # DO NOT EDIT! This file is automatically generated. # -choice GEN_CHOICE_@@prefix@@ +choice GEN_CHOICE_@@dir|@@ bool "@@label@@" #!foreach choice -config @@prefix@@_@@kcfg_choice@@ +config @@dir|@@_@@choice|@@ bool "@@choice@@" #!foreach dependency @@depline@@ @@ -19,14 +19,14 @@ config @@prefix@@_@@kcfg_choice@@ #!end-foreach endchoice -config @@prefix@@ +config @@dir|@@ string #!foreach choice - default "@@choice@@" if @@prefix@@_@@kcfg_choice@@ + default "@@choice@@" if @@dir|@@_@@choice|@@ #!end-foreach #!foreach choice -if @@prefix@@_@@kcfg_choice@@ +if @@dir|@@_@@choice|@@ source "config/@@dir@@/@@choice@@.in" endif #!end-foreach diff --git a/maintainer/kconfig-menu.template b/maintainer/kconfig-menu.template index 12b9f2b3..1a7daa5f 100644 --- a/maintainer/kconfig-menu.template +++ b/maintainer/kconfig-menu.template @@ -3,7 +3,7 @@ # #!foreach choice -menuconfig @@prefix@@_@@kcfg_choice@@ +menuconfig @@dir|@@_@@choice|@@ bool "@@choice@@" #!foreach dependency @@depline@@ @@ -13,7 +13,7 @@ menuconfig @@prefix@@_@@kcfg_choice@@ @@helpline@@ #!end-foreach -if @@prefix@@_@@kcfg_choice@@ +if @@dir|@@_@@choice|@@ source "config/@@dir@@/@@choice@@.in" endif diff --git a/maintainer/kconfig-versions.template b/maintainer/kconfig-versions.template index 01126b00..8bf4affe 100644 --- a/maintainer/kconfig-versions.template +++ b/maintainer/kconfig-versions.template @@ -3,7 +3,7 @@ # # The component directory name -config @@masterpfx@@_DIR_NAME +config @@master|@@_DIR_NAME string default "@@master@@" @@ -13,7 +13,7 @@ choice bool "Show @@master@@ versions from" #!foreach fork -config @@masterpfx@@_USE_@@originpfx@@ +config @@master|@@_USE_@@origin|@@ bool "@@origin@@" #!if [ -n "@@only_obsolete@@" ] depends on OBSOLETE @@ -27,20 +27,20 @@ config @@masterpfx@@_USE_@@originpfx@@ #!end-foreach endchoice -config @@masterpfx@@_USE +config @@master|@@_USE string #!foreach fork - default "@@pfx@@" if @@masterpfx@@_USE_@@originpfx@@ + default "@@fork|@@" if @@master|@@_USE_@@origin|@@ #!end-foreach #!end-if #!foreach fork #!if [ "@@nforks@@" -ge 2 ] -if @@masterpfx@@_USE_@@originpfx@@ +if @@master|@@_USE_@@origin|@@ #!end-if -config @@pfx@@_PKG_NAME +config @@fork|@@_PKG_NAME string default "@@pkg_name@@" @@ -51,16 +51,16 @@ config @@pfx@@_PKG_NAME choice bool "Source of @@pkg_label@@" -#!if [ -n "@@all_versions@@" ] -config @@pfx@@_SRC_RELEASE +#!if [ "@@#version@@" -gt 0 ] +config @@fork|@@_SRC_RELEASE bool "Released tarball" help Download a released tarball. #!end-if -config @@pfx@@_SRC_DEVEL +config @@fork|@@_SRC_DEVEL bool "Vendor/custom repository" -#!if [ -n "@@all_versions@@" ] +#!if [ "@@#version@@" -gt 0 ] depends on EXPERIMENTAL #!end-if help @@ -69,39 +69,39 @@ config @@pfx@@_SRC_DEVEL Default is the vendor repository at @@repository_url@@ #!end-if -if @@pfx@@_SRC_DEVEL +if @@fork|@@_SRC_DEVEL choice bool "VCS type" #!if [ -n "@@repository@@" ] - default @@pfx@@_DEVEL_VCS_@@vcs@@ + default @@fork|@@_DEVEL_VCS_@@vcs@@ #!end-if help Version control system from which the sources will be checked out. The default value points to the development repository for @@pkg_label@@. -config @@pfx@@_DEVEL_VCS_git +config @@fork|@@_DEVEL_VCS_git bool "Git" -config @@pfx@@_DEVEL_VCS_svn +config @@fork|@@_DEVEL_VCS_svn bool "Subversion" -config @@pfx@@_DEVEL_VCS_hg +config @@fork|@@_DEVEL_VCS_hg bool "Mercurial" -config @@pfx@@_DEVEL_VCS_cvs +config @@fork|@@_DEVEL_VCS_cvs bool "CVS" endchoice -config @@pfx@@_DEVEL_VCS +config @@fork|@@_DEVEL_VCS string - default "git" if @@pfx@@_DEVEL_VCS_git - default "svn" if @@pfx@@_DEVEL_VCS_svn - default "hg" if @@pfx@@_DEVEL_VCS_hg - default "cvs" if @@pfx@@_DEVEL_VCS_cvs + default "git" if @@fork|@@_DEVEL_VCS_git + default "svn" if @@fork|@@_DEVEL_VCS_svn + default "hg" if @@fork|@@_DEVEL_VCS_hg + default "cvs" if @@fork|@@_DEVEL_VCS_cvs -config @@pfx@@_DEVEL_URL +config @@fork|@@_DEVEL_URL string "Repository URL" #!if [ -n "@@repository@@" ] default "@@repository_url@@" @@ -112,7 +112,7 @@ config @@pfx@@_DEVEL_URL For CVS, enter both the value of CVS root and the module name, separated by a space. -config @@pfx@@_DEVEL_BRANCH +config @@fork|@@_DEVEL_BRANCH string "Branch/tag to check out" default "@@repository_branch@@" help @@ -122,7 +122,7 @@ config @@pfx@@_DEVEL_BRANCH stable branches. You likely need to change the repository URL, rather than enter anything here. -config @@pfx@@_DEVEL_REVISION +config @@fork|@@_DEVEL_REVISION string "Revision/changeset" default "@@repository_cset@@" help @@ -131,7 +131,7 @@ config @@pfx@@_DEVEL_REVISION CVS: enter the date in "YYYY/MM/DD HH:MM:SS" format (UTC) to check out certain date. Subversion: enter the revision. -config @@pfx@@_DEVEL_SUBDIR +config @@fork|@@_DEVEL_SUBDIR string "Subdirectory in the repository" default "@@repository_subdir@@" help @@ -139,7 +139,7 @@ config @@pfx@@_DEVEL_SUBDIR repository, but rather from some subdirectory. If it is the case, specify this subdirectory here. -config @@pfx@@_DEVEL_BOOTSTRAP +config @@fork|@@_DEVEL_BOOTSTRAP string "Bootstrap command" default "@@bootstrap@@" help @@ -150,15 +150,15 @@ config @@pfx@@_DEVEL_BOOTSTRAP endif -config @@pfx@@_SRC_CUSTOM +config @@fork|@@_SRC_CUSTOM bool "Custom location" depends on EXPERIMENTAL help Custom directory or tarball. -if @@pfx@@_SRC_CUSTOM +if @@fork|@@_SRC_CUSTOM -config @@pfx@@_CUSTOM_LOCATION +config @@fork|@@_CUSTOM_LOCATION string "Custom source location" help Path to the directory or tarball with the sources. @@ -174,7 +174,7 @@ endchoice #!// where we need to identify a range of releases on a branch, for example, #!// "all FOO releases after 4.9.1 but before 4.9.3". #!// -#!if [ -n "@@all_versions@@" -a -z "@@versionlocked@@" ] +#!if [ "@@#version@@" -gt 0 -a -z "@@versionlocked@@" ] choice bool "Version of @@pkg_label@@" help @@ -184,18 +184,18 @@ choice Based on this version, crosstool-NG may apply some version-specific quirks while building @@pkg_label@@. -config @@pfx@@_VERY_NEW +config @@fork|@@_VERY_NEW bool "newer than anything below" depends on EXPERIMENTAL - depends on @@pfx@@_SRC_DEVEL || @@pfx@@_SRC_CUSTOM + depends on @@fork|@@_SRC_DEVEL || @@fork|@@_SRC_CUSTOM #!foreach milestone - select @@masterpfx@@_@@ms_kcfg@@_or_later - depends on !@@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_older + select @@master|@@_@@ms|@@_or_later + depends on !@@master|@@_REQUIRE_@@ms|@@_or_older #!end-foreach #!foreach version -config @@pfx@@_V_@@kcfg@@ - bool "@@ver@@@@ver_postfix@@" +config @@fork|@@_V_@@ver_sel|@@ + bool "@@ver@@@@obsolete? (OBSOLETE)@@@@experimental? (EXPERIMENTAL)@@" #!if [ "@@obsolete@@" = "yes" ] depends on OBSOLETE #!end-if @@ -204,26 +204,26 @@ config @@pfx@@_V_@@kcfg@@ #!end-if #!foreach milestone #!if [ "@@version_cmp_milestone@@" -ge 0 ] - select @@masterpfx@@_@@ms_kcfg@@_or_later + select @@master|@@_@@ms|@@_or_later #!end-if #!if [ "@@version_cmp_milestone@@" -le 0 ] - select @@masterpfx@@_@@ms_kcfg@@_or_older + select @@master|@@_@@ms|@@_or_older #!end-if #!if [ "@@version_cmp_milestone@@" -gt 0 ] - depends on !@@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_older + depends on !@@master|@@_REQUIRE_@@ms|@@_or_older #!end-if #!if [ "@@version_cmp_milestone@@" -lt 0 ] - depends on !@@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_later + depends on !@@master|@@_REQUIRE_@@ms|@@_or_later #!end-if #!end-foreach #!end-foreach -config @@pfx@@_VERY_OLD +config @@fork|@@_VERY_OLD bool "older than anything above" depends on OBSOLETE && EXPERIMENTAL - depends on @@pfx@@_SRC_DEVEL || @@pfx@@_SRC_CUSTOM + depends on @@fork|@@_SRC_DEVEL || @@fork|@@_SRC_CUSTOM #!foreach milestone - depends on !@@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_later + depends on !@@master|@@_REQUIRE_@@ms|@@_or_later #!end-foreach endchoice @@ -231,46 +231,46 @@ endchoice #!if [ -n "@@versionlocked@@" ] #!foreach version -config @@pfx@@_V_@@kcfg@@ +config @@fork|@@_V_@@ver_sel|@@ def_bool y - depends on @@versionlocked@@_V_@@kcfg@@ + depends on @@versionlocked|@@_V_@@ver_sel|@@ #!end-foreach #!end-if -config @@pfx@@_VERSION +config @@fork|@@_VERSION string #!foreach version - default "@@ver@@" if @@pfx@@_V_@@kcfg@@ + default "@@ver@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "unknown" -#!if [ -n "@@all_versions@@" ] -config @@pfx@@_MIRRORS +#!if [ "@@#version@@" -gt 0 ] +config @@fork|@@_MIRRORS string #!foreach version - default "@@mirrors@@" if @@pfx@@_V_@@kcfg@@ + default "@@mirrors@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@mirrors@@" -config @@pfx@@_ARCHIVE_FILENAME +config @@fork|@@_ARCHIVE_FILENAME string #!foreach version - default "@@archive_filename@@" if @@pfx@@_V_@@kcfg@@ + default "@@archive_filename@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@archive_filename@@" -config @@pfx@@_ARCHIVE_DIRNAME +config @@fork|@@_ARCHIVE_DIRNAME string #!foreach version - default "@@archive_dirname@@" if @@pfx@@_V_@@kcfg@@ + default "@@archive_dirname@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@archive_dirname@@" -config @@pfx@@_ARCHIVE_FORMATS +config @@fork|@@_ARCHIVE_FORMATS string #!foreach version - default "@@archive_formats@@" if @@pfx@@_V_@@kcfg@@ + default "@@archive_formats@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@archive_formats@@" @@ -284,18 +284,18 @@ endif #!foreach milestone #!// Milestones selected by a chosen version of this package -config @@masterpfx@@_@@ms_kcfg@@_or_later +config @@master|@@_@@ms|@@_or_later bool -config @@masterpfx@@_@@ms_kcfg@@_or_older +config @@master|@@_@@ms|@@_or_older bool #!// Milestone requirements selected by other packages that restrict #!// the choices in this package -config @@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_later +config @@master|@@_REQUIRE_@@ms|@@_or_later bool -config @@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_older +config @@master|@@_REQUIRE_@@ms|@@_or_older bool #!end-foreach diff --git a/maintainer/package-versions.template b/maintainer/package-versions.template index 36451620..61f938f6 100644 --- a/maintainer/package-versions.template +++ b/maintainer/package-versions.template @@ -2,12 +2,12 @@ #!foreach version run_pkgversion \ master=@@master@@ \ - masterpfx=@@masterpfx@@ \ - originpfx=@@originpfx@@ \ + masterpfx=@@master|@@ \ + originpfx=@@origin|@@ \ pkg_name=@@pkg_name@@ \ - pfx=@@pfx@@ \ - versionlocked=@@versionlocked@@ \ + pfx=@@fork|@@ \ + versionlocked=@@versionlocked|@@ \ ver=@@ver@@ \ - kcfg=@@kcfg@@ + kcfg=@@ver_sel|@@ #!end-foreach #!end-foreach -- cgit v1.2.3 From 961ea1938204e4fc9199c2ff5933caaa1e3d0710 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 24 Aug 2017 15:29:55 -0700 Subject: Allow loops to skip entries if certain variable is kept Signed-off-by: Alexey Neyman --- bootstrap | 44 ++++++++++++++++++++++++++++++------ maintainer/kconfig-versions.template | 8 +++---- 2 files changed, 41 insertions(+), 11 deletions(-) (limited to 'maintainer') diff --git a/bootstrap b/bootstrap index e702dbbc..45fad9c8 100755 --- a/bootstrap +++ b/bootstrap @@ -91,7 +91,7 @@ set_iter() run_if() { - local cond="${1}" + local cond="$*" local endline find_end "if" @@ -125,8 +125,9 @@ do_foreach() for k in "${!info[@]}"; do saveinfo["${k}"]=${info["${k}"]} done - eval "enter_${var} ${v}" - eval "$@" + if eval "enter_${var} ${v}"; then + eval "$@" + fi info=() for k in "${!saveinfo[@]}"; do info["${k}"]=${saveinfo["${k}"]} @@ -136,19 +137,48 @@ do_foreach() run_foreach() { - local var="${1}" local endline + local var="${1}" + shift if [ "${info[iter_${var}]+set}" != "set" ]; then error "line ${l}: iterator over '${var}' is not defined" fi find_end "foreach" debug "Loop over '${var}', lines ${l}..${endline}" - do_foreach ${var} run_lines $[l + 1] $[endline - 1] + do_foreach ${var} run_lines_if $[l + 1] $[endline - 1] "$*" lnext=$[endline + 1] debug "Continue at line ${lnext}" } +run_lines_if() +{ + local start="${1}" + local end="${2}" + shift 2 + local cond="$*" + local a prev + + for a in ${cond}; do + if [ -n "${prev}" ]; then + case "${prev}" in + if-differs) + if [ "${info[${a}]}" = "${saveinfo[${a}]}" ]; then + return + fi + ;; + *) + error "line ${l}: unknown condition '${prev}' for loop" + ;; + esac + prev= + else + prev=${a} + fi + done + run_lines "${start}" "${end}" +} + run_lines() { local start="${1}" @@ -215,10 +245,10 @@ run_lines() debug "Evaluate: ${s}" case "${s}" in "#!if "*) - run_if "${s#* }" + run_if ${s#* } ;; "#!foreach "*) - run_foreach "${s#* }" + run_foreach ${s#* } ;; "#!//"*) # Comment, do nothing diff --git a/maintainer/kconfig-versions.template b/maintainer/kconfig-versions.template index 8bf4affe..0e0ceb08 100644 --- a/maintainer/kconfig-versions.template +++ b/maintainer/kconfig-versions.template @@ -248,28 +248,28 @@ config @@fork|@@_VERSION #!if [ "@@#version@@" -gt 0 ] config @@fork|@@_MIRRORS string -#!foreach version +#!foreach version if-differs mirrors default "@@mirrors@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@mirrors@@" config @@fork|@@_ARCHIVE_FILENAME string -#!foreach version +#!foreach version if-differs archive_filename default "@@archive_filename@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@archive_filename@@" config @@fork|@@_ARCHIVE_DIRNAME string -#!foreach version +#!foreach version if-differs archive_dirname default "@@archive_dirname@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@archive_dirname@@" config @@fork|@@_ARCHIVE_FORMATS string -#!foreach version +#!foreach version if-differs archive_formats default "@@archive_formats@@" if @@fork|@@_V_@@ver_sel|@@ #!end-foreach default "@@archive_formats@@" -- cgit v1.2.3