From 3d3298bd8a7423359b9a2c323cf318c36b74718f Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 10 Nov 2015 17:11:00 +0100 Subject: Fully fix OTHERMIRROR variable interpretation. --- bin/build-deb-package | 2 +- bin/sbuild-deb-package | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/bin/build-deb-package b/bin/build-deb-package index 5f1ed5d..e787c69 100755 --- a/bin/build-deb-package +++ b/bin/build-deb-package @@ -274,7 +274,7 @@ build_packages() { mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/"{amd64,i386} OTHERMIRROR="" if [ "x${COMPONENT}" = "x${COMPONENT_NIGHTLY}" ]; then - grep -qs "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST}-nightly ${l_CODENAME} ${COMPONENT_MAIN} ${COMPONENT}" + grep -qs "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST}-nightly ${l_CODENAME} ${COMPONENT_MAIN}" else grep "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST} ${l_CODENAME} ${COMPONENT}" fi diff --git a/bin/sbuild-deb-package b/bin/sbuild-deb-package index 9e66850..d0aaf0b 100755 --- a/bin/sbuild-deb-package +++ b/bin/sbuild-deb-package @@ -256,18 +256,24 @@ build_packages() { mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/"{amd64,i386} OTHERMIRROR="" if [ "x${COMPONENT}" = "x${COMPONENT_NIGHTLY}" ]; then - grep -qs "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="--extra-repository=\"deb http://${REPOS_SERVER}/${l_DIST}-nightly ${l_CODENAME} ${COMPONENT_MAIN} ${COMPONENT}\"" + grep -qs "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST}-nightly ${l_CODENAME} ${COMPONENT_MAIN}" else - grep "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="--extra-repository=\"deb http://${REPOS_SERVER}/${l_DIST} ${l_CODENAME} ${COMPONENT}\"" + grep "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST} ${l_CODENAME} ${COMPONENT}" fi # create git changelog immediately prior to building the package git --no-pager log --since "2 years ago" --format="%ai %aN (%h) %n%n%x09*%w(68,0,10) %s%d%n" > ChangeLog # build the source package - dpkg-buildpackage -uc -us -S + dpkg-buildpackage -uc -us -S -d cd .. DSCFILE="$(pwd)/$(ls -1 "${PROJECT}_"*.dsc | head -n1)" + SBUILD_OPTIONS_64="-j2 -sAd ${VERSION} -k ${GPG_KEY} -c arctica-${l_CODENAME}" + SBUILD_OPTIONS_32="-j2 -sAd ${VERSION} -k ${GPG_KEY} -c arctica-${l_CODENAME}-i386 --arch=i386 --debbuildopts=-B" + if [ -n "${SA_OPTION}" ]; then + SBUILD_OPTIONS_64=${SBUILD_OPTIONS}" ${SA_OPTION}" + fi + [ "x${SKIP_ARCH}" != "xamd64" ] && grep -Eqs 'Architecture.*(all|any|amd64)' "${TEMP_DIR}/${PROJECT}/debian/control" && { cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/amd64" tac ${DSCFILE} | while read line; do @@ -276,7 +282,11 @@ build_packages() { filename="$(echo $line | cut -d" " -f3-)" cp "${TEMP_DIR}/${filename}" . done - nice ${SBUILD} -j2 -sAd "${VERSION}" -k "${GPG_KEY}" -c "arctica-${l_CODENAME}" ${OTHERMIRROR} ${SA_OPTION} "${DSCFILE}" + if [ -z "${OTHERMIRROR}" ]; then + nice ${SBUILD} ${SBUILD_OPTIONS_64} "${DSCFILE}" + else + nice ${SBUILD} ${SBUILD_OPTIONS_64} --extra-repository="${OTHERMIRROR}" "${DSCFILE}" + fi } [ "x${SKIP_ARCH}" != "xi386" ] && grep -Eqs 'Architecture.*(any|i386)' "${TEMP_DIR}/${PROJECT}/debian/control" && { cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/i386" @@ -286,7 +296,11 @@ build_packages() { filename="$(echo $line | cut -d" " -f3-)" cp "${TEMP_DIR}/${filename}" . done - nice ${SBUILD} -j2 -sAd "${VERSION}" -k "${GPG_KEY}" -c "arctica-${l_CODENAME}-i386" ${OTHERMIRROR} --arch=i386 --debbuildopts="-B" "${DSCFILE}" + if [ -z "${OTHERMIRROR}" ]; then + nice ${SBUILD} ${SBUILD_OPTIONS_32} "${DSCFILE}" + else + nice ${SBUILD} ${SBUILD_OPTIONS_32} --extra-repository="${OTHERMIRROR}" "${DSCFILE}" + fi } done } -- cgit v1.2.3 From 7fdf2992eb045916ce14458e526b31c6bed81de6 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 11 Nov 2015 11:31:35 +0100 Subject: Use build-dep resolver aptitude (not apt-get). --- bin/sbuild-deb-package | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/sbuild-deb-package b/bin/sbuild-deb-package index d0aaf0b..06d61bd 100755 --- a/bin/sbuild-deb-package +++ b/bin/sbuild-deb-package @@ -268,8 +268,9 @@ build_packages() { cd .. DSCFILE="$(pwd)/$(ls -1 "${PROJECT}_"*.dsc | head -n1)" - SBUILD_OPTIONS_64="-j2 -sAd ${VERSION} -k ${GPG_KEY} -c arctica-${l_CODENAME}" - SBUILD_OPTIONS_32="-j2 -sAd ${VERSION} -k ${GPG_KEY} -c arctica-${l_CODENAME}-i386 --arch=i386 --debbuildopts=-B" + SBUILD_OPTIONS="-j2 -sAd ${VERSION} -k ${GPG_KEY} --build-dep-resolver=aptitude" + SBUILD_OPTIONS_64="${SBUILD_OPTIONS} -c arctica-${l_CODENAME}" + SBUILD_OPTIONS_32="${SBUILD_OPTIONS} -c arctica-${l_CODENAME}-i386 --arch=i386 --debbuildopts=-B" if [ -n "${SA_OPTION}" ]; then SBUILD_OPTIONS_64=${SBUILD_OPTIONS}" ${SA_OPTION}" fi -- cgit v1.2.3 From d4dddc7c96e0a110b33bc9ddf33f8513cfc4dbad Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 11 Nov 2015 11:32:16 +0100 Subject: Only copy package files, if a filename could be extracted from the .dsc file. --- bin/sbuild-deb-package | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/sbuild-deb-package b/bin/sbuild-deb-package index 06d61bd..7d99a3b 100755 --- a/bin/sbuild-deb-package +++ b/bin/sbuild-deb-package @@ -281,7 +281,7 @@ build_packages() { if echo $line | grep -E "^Files:" 1>/dev/null; then break; fi # each line contains a file that is part of the src:package filename="$(echo $line | cut -d" " -f3-)" - cp "${TEMP_DIR}/${filename}" . + if [ -n "$filename" ]; then cp "${TEMP_DIR}/${filename}" .; fi done if [ -z "${OTHERMIRROR}" ]; then nice ${SBUILD} ${SBUILD_OPTIONS_64} "${DSCFILE}" @@ -295,7 +295,7 @@ build_packages() { if echo $line | grep -E "^Files:" 1>/dev/null; then break; fi # each line contains a file that is part of the src:package filename="$(echo $line | cut -d" " -f3-)" - cp "${TEMP_DIR}/${filename}" . + if [ -n "$filename" ]; then cp "${TEMP_DIR}/${filename}" .; fi done if [ -z "${OTHERMIRROR}" ]; then nice ${SBUILD} ${SBUILD_OPTIONS_32} "${DSCFILE}" -- cgit v1.2.3 From 1154f99a96c0387d53315af5e465b8154f05cd88 Mon Sep 17 00:00:00 2001 From: "Arctica Builder (CHEVALBLANC)" Date: Wed, 11 Nov 2015 11:34:35 +0100 Subject: Use the --no-log (-n) option for sbuild to pipe all output into the Jenkins console log. --- bin/sbuild-deb-package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sbuild-deb-package b/bin/sbuild-deb-package index 7d99a3b..a0c714e 100755 --- a/bin/sbuild-deb-package +++ b/bin/sbuild-deb-package @@ -268,7 +268,7 @@ build_packages() { cd .. DSCFILE="$(pwd)/$(ls -1 "${PROJECT}_"*.dsc | head -n1)" - SBUILD_OPTIONS="-j2 -sAd ${VERSION} -k ${GPG_KEY} --build-dep-resolver=aptitude" + SBUILD_OPTIONS="-n -j2 -sAd ${VERSION} -k ${GPG_KEY} --build-dep-resolver=aptitude" SBUILD_OPTIONS_64="${SBUILD_OPTIONS} -c arctica-${l_CODENAME}" SBUILD_OPTIONS_32="${SBUILD_OPTIONS} -c arctica-${l_CODENAME}-i386 --arch=i386 --debbuildopts=-B" if [ -n "${SA_OPTION}" ]; then -- cgit v1.2.3 From 3849c3d7878939110ad5eb185dde6ced1aade2ab Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Fri, 1 Jul 2016 07:26:02 +0200 Subject: bin/: new script debian-codename-to-version.sh to map Debian code names to numerical versions. --- bin/debian-codename-to-version.sh | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 bin/debian-codename-to-version.sh diff --git a/bin/debian-codename-to-version.sh b/bin/debian-codename-to-version.sh new file mode 100755 index 0000000..8bd0384 --- /dev/null +++ b/bin/debian-codename-to-version.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# Copyright (C) 2016 by Mihai Moldovan +# +# This programme is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This programme is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +export PATH="${HOME}/bin:${PATH}" + +# ${CDPATH} could lead to some very nasty problems. Better unset it. +unset CDPATH + +# Takes a Debian code name and converts it into the +# corresponding numerical version (based on year and month +# of the release.) +# The result is printed as a string with a trailing newline. +# The return code is either 0, iff mapping was successful, +# or 1 if the code name is unknown and mapping failed. + +typeset -l codename +codename="${1:?"No code name provided."}" + +typeset -l -i ret="0" + +case "${codename}" in + # The first version number is actually "fake", + # but given it's a rolling release, + # we can't really do better here. + ("sid"|"unstable") echo "9999";; + + # FIXME: add "testing" - but how? It's not really + # a stable release on its own, but a rolling + # release (see sid/unstable above). Yet, it differs + # from sid/unstable by not having one unique + # code name, but a floating one of the next + # stable release. We know the new release number + # beforehand, but mapping "testing" to the + # upcoming version number means that "testing"s + # version number itself would be floating, creating + # problems after each new release and requiring an + # update. On the other hand, giving "testing" a + # fixed version number such as "999" (smaller than + # "unstable"s, yet bigger than anything we encountered + # so far) would create an inconsistency: + # The "testing" code name would have a different + # version number than the code-name-to-be-released- + # next. + # For now and due to the aforementioned problems, + # I decided to not handle the "testing" code name + # at all. + ("stretch") echo "9";; + + ("jessie") echo "8";; + ("wheezy") echo "7";; + ("squeeze") echo "6";; + ("lenny") echo "5";; + ("etch") echo "4";; + ("sarge") echo "3.1";; + ("woody") echo "3.0";; + ("potato") echo "2.2";; + ("slink") echo "2.1";; + ("hamm") echo "2.0";; + ("bo") echo "1.3";; + ("rex") echo "1.2";; + ("buzz") echo "1.1";; + + (*) ret="1";; +esac + +return "${ret}" -- cgit v1.2.3 From 16d7cf35544f495035d27b2545c00db02889d865 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Fri, 1 Jul 2016 07:26:20 +0200 Subject: bin/: new script ubuntu-codename-to-version.sh to map Ubuntu code names to numerical versions. --- bin/ubuntu-codename-to-version.sh | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 bin/ubuntu-codename-to-version.sh diff --git a/bin/ubuntu-codename-to-version.sh b/bin/ubuntu-codename-to-version.sh new file mode 100755 index 0000000..943e130 --- /dev/null +++ b/bin/ubuntu-codename-to-version.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# Copyright (C) 2016 by Mihai Moldovan +# +# This programme is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This programme is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +export PATH="${HOME}/bin:${PATH}" + +# ${CDPATH} could lead to some very nasty problems. Better unset it. +unset CDPATH + +# Takes a Debian code name and converts it into the +# corresponding numerical version. +# The result is printed as a string with a trailing newline. +# The return code is either 0, iff mapping was successful, +# or 1 if the code name is unknown and mapping failed. + +typeset -l codename +codename="${1:?"No code name provided."}" + +typeset -l -i ret="0" + +case "${codename}" in + # The first version number is actually "fake", + # but given it's a rolling release, + # we can't really do better here. + ("devel") echo "9999";; + + ("yakkety") echo "16.10";; + + ("xenial") echo "16.04";; + ("wily") echo "15.10";; + ("vivid") echo "15.04";; + ("utopic") echo "14.10";; + ("trusty") echo "14.04";; + ("saucy") echo "13.10";; + ("raring") echo "13.04";; + ("precise") echo "12.04";; + ("quantal") echo "12.10";; + ("oneiric") echo "11.10";; + ("natty") echo "11.04";; + ("maverick") echo "10.10";; + ("lucid") echo "10.04";; + ("karmic") echo "9.10";; + ("jaunty") echo "9.04";; + ("intrepid") echo "8.10";; + ("hardy") echo "8.04";; + ("gutsy") echo "7.10";; + ("feisty") echo "7.04";; + ("edgy") echo "6.10";; + ("dapper") echo "6.06";; + ("breezy") echo "5.10";; + ("hoary") echo "5.04";; + ("warty") echo "4.10";; + + (*) ret="1";; +esac + +return "${ret}" -- cgit v1.2.3 From b9992a54faffe763946fc1ca9276ee65149c5b46 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Fri, 1 Jul 2016 07:46:02 +0200 Subject: bin/sbuild-deb-package: change package versioning to mitigate errors during dist-upgrades. The local version now contains a numerical version of the code name instead of a string, which is lexicographically compared and will wrap around at some point for Ubuntu, or just be plain random between releases for Debian. Descriptions have been updated to include a capitalized distro name and also the numerical version in addition to the code name. In order to make the transition work, ALL packages (releases and nightlies) must be revbumped. For nightlies, one commit to each repo is enough to generate a new git date and commit number, while release packages need a proper revision or version bump. Merely rebuilding with the old version is not enough, as the new packages will be seen as older than the old ones. --- bin/sbuild-deb-package | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/bin/sbuild-deb-package b/bin/sbuild-deb-package index a0c714e..6519c4b 100755 --- a/bin/sbuild-deb-package +++ b/bin/sbuild-deb-package @@ -233,13 +233,34 @@ build_packages() { } # for Ubuntu version is the codename of the distribution release - VERSION="${l_CODENAME}" + typeset -l codename="${l_CODENAME}" # translate the version name for Debian releases - [ "x${l_CODENAME}" = "xsid" ] && VERSION="unstable" - #[ "x$l_CODENAME" = "xjessie" ] && VERSION=testing - #[ "x$l_CODENAME" = "xwheezy" ] && VERSION=stable - #[ "x$l_CODENAME" = "xoldstable" ] && VERSION=oldstable + [ "x${l_CODENAME}" = "xsid" ] && codename="unstable" + #[ "x$l_CODENAME" = "xjessie" ] && codename=testing + #[ "x$l_CODENAME" = "xwheezy" ] && codename=stable + #[ "x$l_CODENAME" = "xoldstable" ] && codename=oldstable + + typeset -l numerical_version="" + typeset -l -i tmp_ret="1" + typeset -l pretty_dist="" + + if [ -n "${l_DIST}" ] && [ "${l_DIST}" = "debian" ]; then + pretty_dist="Debian" + numerical_version="$("${script_path}/debian-codename-to-version.sh" "${codename}")" + tmp_ret="${?}" + fi + + if [ -n "${l_DIST}" ] && [ "${l_DIST}" = "ubuntu" ]; then + pretty_dist="Ubuntu" + numerical_version="$("${script_path}/ubuntu-codename-to-version.sh" "${codename}")" + tmp_ret="${?}" + fi + + if [ "${tmp_ret}" -ne "0" ]; then + echo "Error: unable to map code name \"${codename}\" to Debian or Ubuntu numerical versions. Unknown code name or not applicable to distribution \"${dist_pretty}\"? Aborting." >&2 + exit 1 + fi # modify the section for non-main package builds [ "x${COMPONENT}" != "xmain" ] && { @@ -249,9 +270,9 @@ build_packages() { # modify changelog for this build if [ "${COMPONENT}" != "${COMPONENT_NIGHTLY}" ]; then - dch --distribution "${VERSION}" --force-distribution -l "+git${DATE}.${GITREV}+${l_CODENAME}.${COMPONENT}." "Auto-built ${l_DIST} ${l_CODENAME} package for ${REPOS_SERVER} repository (Git commit: ${GIT_OBJECT_ID})." + dch --distribution "${codename}" --force-distribution -l "+git${DATE}.${GITREV}+${numerical_version}.${COMPONENT}." "Auto-built ${pretty_dist} ${l_CODENAME} package for ${REPOS_SERVER} repository (Git commit: ${GIT_OBJECT_ID})." else - dch --distribution "${VERSION}" --force-distribution -l "~git${DATE}.${GITREV}+${l_CODENAME}.${COMPONENT}." "Development-Snapshot!!! Auto-built ${l_DIST} ${l_CODENAME} package for ${REPOS_SERVER} repository (Git commit: ${GIT_OBJECT_ID})." + dch --distribution "${codename}" --force-distribution -l "~git${DATE}.${GITREV}+${numerical_version}.${COMPONENT}." "Development-Snapshot!!! Auto-built ${pretty_dist} ${l_CODENAME} package for ${REPOS_SERVER} repository (Git commit: ${GIT_OBJECT_ID})." fi mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/"{amd64,i386} OTHERMIRROR="" @@ -268,7 +289,7 @@ build_packages() { cd .. DSCFILE="$(pwd)/$(ls -1 "${PROJECT}_"*.dsc | head -n1)" - SBUILD_OPTIONS="-n -j2 -sAd ${VERSION} -k ${GPG_KEY} --build-dep-resolver=aptitude" + SBUILD_OPTIONS="-n -j2 -sAd ${codename} -k ${GPG_KEY} --build-dep-resolver=aptitude" SBUILD_OPTIONS_64="${SBUILD_OPTIONS} -c arctica-${l_CODENAME}" SBUILD_OPTIONS_32="${SBUILD_OPTIONS} -c arctica-${l_CODENAME}-i386 --arch=i386 --debbuildopts=-B" if [ -n "${SA_OPTION}" ]; then -- cgit v1.2.3 From e00a37895b6b56f28d9b0d3d360af500397dd39e Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Mon, 4 Jul 2016 21:42:28 +0200 Subject: bin/{debian,ubuntu}-codename-to-version.sh: fix various shortcomings: - return can only be used in functions. Switch to "exit" instead. - typeset -l makes the content lowercase, not the variable "local" (that's implied by using typeset.) Hence, drop it where inappropriate. - typeset -l is only available in BASH 4 and higher. Use it conditionally only. - Use tr to convert strings to lowercase when using a BASH version lower than 4. --- bin/debian-codename-to-version.sh | 14 +++++++++++--- bin/ubuntu-codename-to-version.sh | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/debian-codename-to-version.sh b/bin/debian-codename-to-version.sh index 8bd0384..42f497b 100755 --- a/bin/debian-codename-to-version.sh +++ b/bin/debian-codename-to-version.sh @@ -29,10 +29,18 @@ unset CDPATH # The return code is either 0, iff mapping was successful, # or 1 if the code name is unknown and mapping failed. -typeset -l codename +# Where supported (BASH 4 and higher), automatically +# lower-case the codename argument. +if [ -n "${BASH_VERSINFO[0]}" ] && [ "${BASH_VERSINFO[0]}" -gt 3 ]; then + typeset -l codename +fi codename="${1:?"No code name provided."}" -typeset -l -i ret="0" +if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ]; then + codename="$(tr '[:upper:]' '[:lower:]' <<< "${codename}")" +fi + +typeset -i ret="0" case "${codename}" in # The first version number is actually "fake", @@ -79,4 +87,4 @@ case "${codename}" in (*) ret="1";; esac -return "${ret}" +exit "${ret}" diff --git a/bin/ubuntu-codename-to-version.sh b/bin/ubuntu-codename-to-version.sh index 943e130..f2884cf 100755 --- a/bin/ubuntu-codename-to-version.sh +++ b/bin/ubuntu-codename-to-version.sh @@ -28,10 +28,18 @@ unset CDPATH # The return code is either 0, iff mapping was successful, # or 1 if the code name is unknown and mapping failed. -typeset -l codename +# Where supported (BASH 4 and higher), automatically +# lower-case the codename argument. +if [ -n "${BASH_VERSINFO[0]}" ] && [ "${BASH_VERSINFO[0]}" -gt 3 ]; then + typeset -l codename +fi codename="${1:?"No code name provided."}" -typeset -l -i ret="0" +if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ]; then + codename="$(tr '[:upper:]' '[:lower:]' <<< "${codename}")" +fi + +typeset -i ret="0" case "${codename}" in # The first version number is actually "fake", @@ -69,4 +77,4 @@ case "${codename}" in (*) ret="1";; esac -return "${ret}" +exit "${ret}" -- cgit v1.2.3 From 9b98ace894ac4641e789dd04637aa52b58d3c177 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Mon, 4 Jul 2016 22:50:46 +0200 Subject: bin/build-deb-package: fix various issues: - typeset -l makes the content lowercase, not the variable "local" (that's implied by using typeset.) Hence, drop it where inappropriate. - typeset -l is only available in BASH 4 and higher. Use it conditionally only. - Use tr to convert strings to lowercase when using a BASH version lower than 4. - Don't accept empty numerical version values. --- bin/sbuild-deb-package | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/sbuild-deb-package b/bin/sbuild-deb-package index 6519c4b..84f43ad 100755 --- a/bin/sbuild-deb-package +++ b/bin/sbuild-deb-package @@ -233,7 +233,11 @@ build_packages() { } # for Ubuntu version is the codename of the distribution release - typeset -l codename="${l_CODENAME}" + if [ -n "${BASH_VERSINFO[0]}" ] && [ "${BASH_VERSINFO[0]}" -gt 3 ]; then + typeset -l codename="${l_CODENAME}" + else + typeset codename="$(tr '[:upper:]' '[:lower:]' <<< "${l_CODENAME}")" + fi # translate the version name for Debian releases [ "x${l_CODENAME}" = "xsid" ] && codename="unstable" @@ -241,9 +245,9 @@ build_packages() { #[ "x$l_CODENAME" = "xwheezy" ] && codename=stable #[ "x$l_CODENAME" = "xoldstable" ] && codename=oldstable - typeset -l numerical_version="" - typeset -l -i tmp_ret="1" - typeset -l pretty_dist="" + typeset numerical_version="" + typeset -i tmp_ret="1" + typeset pretty_dist="" if [ -n "${l_DIST}" ] && [ "${l_DIST}" = "debian" ]; then pretty_dist="Debian" @@ -257,7 +261,7 @@ build_packages() { tmp_ret="${?}" fi - if [ "${tmp_ret}" -ne "0" ]; then + if [ "${tmp_ret}" -ne "0" ] || [ -z "${numerical_version}" ]; then echo "Error: unable to map code name \"${codename}\" to Debian or Ubuntu numerical versions. Unknown code name or not applicable to distribution \"${dist_pretty}\"? Aborting." >&2 exit 1 fi -- cgit v1.2.3