From 94ef8414e19059c2a903fdb3882acf67403821e5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 24 Jun 2016 10:14:49 +0200 Subject: [PATCH 1/9] beesh: join together verify_new_package_variables and extract_new_package_variables we want to expand the handling of variables changed by the beefile a bit which is easier implement and follow when done in a single function --- src/beesh.sh.in | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index b7b91c5..d0b7780 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -732,7 +732,7 @@ function save_current_package_variables() { oPKGREVISION=${PKGREVISION} } -function verify_new_package_variables() { +function extract_new_package_variables() { nPKGFULLNAME="${PKGNAME}${PKGEXTRANAME:+_${PKGEXTRANAME}}" if [ "${oPKGFULLNAME}" != "${PKGFULLNAME}" ] ; then @@ -763,9 +763,7 @@ function verify_new_package_variables() { fi fi PKGFULLVERSION="${PKGVERSION}${PKGEXTRAVERSION:+_${PKGEXTRAVERSION}}" -} -function extract_new_package_variables() { if [ "${PKGNAME}" != "${oPKGNAME}" ] ; then # pkgname changed! we allow prefixing 'anything-' to the packagename if [ "${PKGNAME}" != "${PKGNAME/-${oPKGNAME}}-${oPKGNAME}" ] ; then @@ -989,7 +987,6 @@ save_current_package_variables # now set PKGARCH if set or changed by user via ARCH=.. and not given via file.arch.bee : ${PKGARCH:=${ARCH}} -verify_new_package_variables extract_new_package_variables config_handle_deprecated_beefile From 9c3c2274f8f62526b2a83225879aae44905ad72f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 23 Jun 2016 22:44:53 +0200 Subject: [PATCH 2/9] beesh: allow change of PKGVERSION , PKGEXTRAVERSION and PKGREVISION When we start with a versionless file, we need to be able to change the versions. We will add other tests for completeness in the following patches --- src/beesh.sh.in | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index d0b7780..2e746f3 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -779,21 +779,6 @@ function extract_new_package_variables() { fi print_info "${COLOR_YELLOW}PKGEXTRANAME changed from '${oPKGEXTRANAME}' to '${PKGEXTRANAME}'" fi - if [ "${PKGVERSION}" != "${oPKGVERSION}" ] ; then - print_error "${BEE##*/}: Invalid change in PKGVERSION(${PKGVERSION}) detected. Changing PKGVERSION is not supported." - exit 1 - fi - if [ "${PKGEXTRAVERSION}" != "${oPKGEXTRAVERSION}" ] ; then - if [ ! -z "${oPKGEXTRAVERSION}" -a "${PKGEXTRAVERSION}" != "${oPKGEXTRAVERSION}_${PKGEXTRAVERSION#${oPKGEXTRAVERSION}_}" ] ; then - print_error "${BEE##*/}: Invalid change in PKGEXTRAVERSION(${PKGEXTRAVERSION}) detected. Only appending '_something' is supported." - exit 1 - fi - print_info "${COLOR_YELLOW}PKGEXTRAVERSION changed from '${oPKGEXTRAVERSION}' to '${PKGEXTRAVERSION}'" - fi - if [ "${PKGREVISION}" != "${oPKGREVISION}" ] ; then - print_error "${BEE##*/}: Invalid change in PKGREVISION(${PKGREVISION}) detected. Changing PKGREVISION is not supported." - exit 1 - fi PKGFULLPKG=${PKGFULLNAME}-${PKGFULLVERSION}-${PKGREVISION} From 7cf9bc6d185807f9da89c4553226f5de7ed70d16 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 23 Jun 2016 22:47:03 +0200 Subject: [PATCH 3/9] beesh: first run beefile, then check for completeness we allow the bee file to be started without a complete version set. the bee file should set the version with a callback we add in a following patch. When we allow the version to be set in the bee file, $B and $S, which depend on the full package name, can only be set after the bee file is run. So we need to postpone the effect of the build_in_sourcedir callback to a later time. The beefiles can also set $B=$S directly. We deprecate this with this patch, but still detect it and act accordinly. --- src/beesh.sh.in | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index 2e746f3..6633859 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -192,7 +192,7 @@ function check_repositories() { } function build_in_sourcedir() { - B=${S} + BUILD_IN_SOURCEDIR=1 } function add_sourcesubdir() { @@ -946,34 +946,40 @@ PKGREVISION= eval $("${BEE_BINDIR}/beeversion" "${BEE}") -if [ -z "${PKGNAME}" -o -z "${PKGVERSION}" -o -z "${PKGREVISION}" ] ; then - print_error "${BEE}: please use the proper package versioning (e.g. package-1.0-0)" - exit 1 -fi - -BEEPKGROOT="${BEE_TMP_BUILDROOT}/${PKGNAME}" -BEEWORKDIR="${BEEPKGROOT}/${PKGFULLPKG}" - -F=${BEEPKGROOT}/files -S=${BEEWORKDIR}/source -B=${BEEWORKDIR}/build -D=${BEEWORKDIR}/image - ############################################################################### # clear PKGALLPKG since we can't trust PKGARCH in this state PKGALLPKG= +S='S_NOT_YET_DEFINED' save_current_package_variables # source file.bee . "${BEE}" +if [ "$B" = 'S_NOT_YET_DEFINED' ] ; then + print_warning "${BEE}: setting \$B=\"\$S\" is deprecated. use build_in_sourcedir instead." + build_in_sourcedir +fi + # now set PKGARCH if set or changed by user via ARCH=.. and not given via file.arch.bee : ${PKGARCH:=${ARCH}} extract_new_package_variables +if [ -z "${PKGNAME}" -o -z "${PKGVERSION}" -o -z "${PKGREVISION}" ] ; then + print_error "${BEE}: please use the proper package versioning (e.g. package-1.0-0)" + exit 1 +fi + +BEEPKGROOT="${BEE_TMP_BUILDROOT}/${PKGNAME}" +BEEWORKDIR="${BEEPKGROOT}/${PKGFULLPKG}" + +F=${BEEPKGROOT}/files +S=${BEEWORKDIR}/source +B=${BEEWORKDIR}/build +D=${BEEWORKDIR}/image + config_handle_deprecated_beefile expand_prefix_variables config_export @@ -1035,6 +1041,11 @@ for t in "${bee_buildmagic[@]}" ; do fi done +if [ "$BUILD_IN_SOURCEDIR" ] ; then + print_info "BUILD_IN_SOURCEDIR requested" + B="$S" +fi + bee_init_buildinsourcedir print_info "changing to build directory: ${B}" From 1a7fb62ad6e1c802f26ee9b9bb07e541333e982e Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 12:57:21 +0200 Subject: [PATCH 4/9] beesh: add validate_pkg_complete, validate_pkg_complete_from_filename --- src/beesh.sh.in | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index 6633859..7a31fea 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -191,6 +191,19 @@ function check_repositories() { fi } +function validate_pkg_complete() { + test -n "$PKGNAME" -a -n "$PKGVERSION" -a -n "$PKGREVISION" -a "$PKGSUFFIX" = '.bee' || return 1 + return 0 +} + +function validate_pkg_complete_from_filename() { + test -n "$PKGNAME" -a "$PKGSUFFIX" = '.bee' || return 1 + test "$PKGFULLVERSION" = '0' && return 0 # versionless. bla-0 + test -n "$PKGVERSION" -a -n "$PKGREVISION" && return 0 # with version bla-1.2.3-55 + return 1 +} + +############################################################################### function build_in_sourcedir() { BUILD_IN_SOURCEDIR=1 } @@ -788,7 +801,6 @@ function extract_new_package_variables() { eval $("${BEE_BINDIR}/beeversion" "${PKGALLPKG}") } -############################################################################### ############################################################################### ############################################################################### From 1faec717e2728c1cb317a2efefcdfabb66def37e Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 12:57:43 +0200 Subject: [PATCH 5/9] beesh: call validate_pkg_from_filename --- src/beesh.sh.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index 7a31fea..8dcdb60 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -958,6 +958,9 @@ PKGREVISION= eval $("${BEE_BINDIR}/beeversion" "${BEE}") +validate_pkg_complete_from_filename || \ + bee_die "filename $BEE is invalid. (valid examples: bla-0.bee bla-1.2.3-55.bee bla_lall_x-1.2.3.4_xxx-0.x86_64.bee)" + ############################################################################### # clear PKGALLPKG since we can't trust PKGARCH in this state From 0c9d9b3d8b66c1a14c8f67c356288c7010253b87 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 00:20:13 +0200 Subject: [PATCH 6/9] beesh: add callback function bee_version at the same time add utility function bee_die and relax the checks so that we can update the full version string from inside the bee file --- src/beesh.sh.in | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index 8dcdb60..99edef2 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -208,6 +208,20 @@ function build_in_sourcedir() { BUILD_IN_SOURCEDIR=1 } +function bee_die() { + print_error $* + exit 1 +} + +function bee_version() { + test -n "$1" || bee_die "bee_version: missing argument" + test "$PKGFULLVERSION"="0" -a -z "$PKGREVISION" || bee_die "bee_version: version is already fixed" + local oPKGFULLNAME="$PKGFULLNAME" + eval $("${BEE_BINDIR}/beeversion" "$1") || bee_die "bee_version: invalid version string" + validate_pkg_complete || bee_die "bee_version: please use the proper package versioning (e.g. package-1.0-0)" + test "$PKGFULLNAME" = "$oPKGFULLNAME" || bee_die "bee_version: not allowed to change the package name from $oPKGFULLNAME to $PKGFULLNAME" +} + function add_sourcesubdir() { print_warning "WARNING: add_sourcesubdir is deprecated in favor of sourcesubdir_append" sourcesubdir_append "${@}" @@ -747,7 +761,6 @@ function save_current_package_variables() { function extract_new_package_variables() { nPKGFULLNAME="${PKGNAME}${PKGEXTRANAME:+_${PKGEXTRANAME}}" - if [ "${oPKGFULLNAME}" != "${PKGFULLNAME}" ] ; then if [ "${oPKGFULLNAME}" != "${nPKGFULLNAME}" ] ; then print_error "${BEE##*/}: Changing PKGFULLNAME and one of PKGNAME or PKGEXTRANAME is not supported." @@ -764,10 +777,6 @@ function extract_new_package_variables() { nPKGFULLVERSION="${PKGVERSION}${PKGEXTRAVERSION:+_${PKGEXTRAVERSION}}" if [ "${oPKGFULLVERSION}" != "${PKGFULLVERSION}" ] ; then - if [ "${oPKGFULLVERSION}" != "${nPKGFULLVERSION}" ] ; then - print_error "${BEE##*/}: Changing PKGFULLVERSION and one of PKGVERSION or PKGEXTRAVERSION is not supported." - exit 1 - fi PKGVERSION=${PKGFULLVERSION//_*} if [ "$PKGVERSION" = "$PKGFULLVERSION" ] ; then PKGEXTRAVERSION="" From b60de32b0fdee046a993e3692fa1392f53ffd21a Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 13:15:50 +0200 Subject: [PATCH 7/9] beesh: use validate_pkg_complete for check of completeness --- src/beesh.sh.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index 99edef2..d26721e 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -192,7 +192,7 @@ function check_repositories() { } function validate_pkg_complete() { - test -n "$PKGNAME" -a -n "$PKGVERSION" -a -n "$PKGREVISION" -a "$PKGSUFFIX" = '.bee' || return 1 + test -n "$PKGNAME" -a -n "$PKGVERSION" -a -n "$PKGREVISION" || return 1 return 0 } @@ -991,10 +991,7 @@ fi extract_new_package_variables -if [ -z "${PKGNAME}" -o -z "${PKGVERSION}" -o -z "${PKGREVISION}" ] ; then - print_error "${BEE}: please use the proper package versioning (e.g. package-1.0-0)" - exit 1 -fi +validate_pkg_complete || bee_die "if you start from a generic file ( package-0.bee ) you need to call bee_version from inside the bee file (e.g. bee_version package-1.0-0)" BEEPKGROOT="${BEE_TMP_BUILDROOT}/${PKGNAME}" BEEWORKDIR="${BEEPKGROOT}/${PKGFULLPKG}" From bf781856eff1d98d2c50b9abb975eaf01babe0cc Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 13:42:16 +0200 Subject: [PATCH 8/9] beesh: avoid warnings of beeversion this is save, because after every call the completeness of the output is checked and a wrong syntax will be detected --- src/beesh.sh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index d26721e..a579719 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -217,7 +217,7 @@ function bee_version() { test -n "$1" || bee_die "bee_version: missing argument" test "$PKGFULLVERSION"="0" -a -z "$PKGREVISION" || bee_die "bee_version: version is already fixed" local oPKGFULLNAME="$PKGFULLNAME" - eval $("${BEE_BINDIR}/beeversion" "$1") || bee_die "bee_version: invalid version string" + eval $("${BEE_BINDIR}/beeversion" "$1" 2>/dev/null) || bee_die "bee_version: invalid version string" validate_pkg_complete || bee_die "bee_version: please use the proper package versioning (e.g. package-1.0-0)" test "$PKGFULLNAME" = "$oPKGFULLNAME" || bee_die "bee_version: not allowed to change the package name from $oPKGFULLNAME to $PKGFULLNAME" } @@ -807,7 +807,7 @@ function extract_new_package_variables() { # since PKGARCH is now known reconstruct PKGALLPKG : ${PKGALLPKG:=${PKGFULLPKG}.${PKGARCH}} - eval $("${BEE_BINDIR}/beeversion" "${PKGALLPKG}") + eval $("${BEE_BINDIR}/beeversion" "${PKGALLPKG}" 2>/dev/null) } ############################################################################### @@ -965,7 +965,7 @@ PKGNAME= PKGVERSION= PKGREVISION= -eval $("${BEE_BINDIR}/beeversion" "${BEE}") +eval $("${BEE_BINDIR}/beeversion" "${BEE}" 2>/dev/null) validate_pkg_complete_from_filename || \ bee_die "filename $BEE is invalid. (valid examples: bla-0.bee bla-1.2.3-55.bee bla_lall_x-1.2.3.4_xxx-0.x86_64.bee)" From 1c259c4c02213d0f92daeb3136432ca40c5cd5f7 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 14:26:42 +0200 Subject: [PATCH 9/9] beesh: avoid wrong diagnostic we may fail to find a free revision number (eg with versionless bee files) and if so, we want to avoid the error message of beeversion and a wrong "cp" hint. --- src/beesh.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index a579719..744fc64 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -157,6 +157,7 @@ function check_rebuild() { echo "${bf}" done | ${BEESORT} | tail -1) + test -n "${beefile_max}" || exit 1 eval $(${BEEVERSION} ${beefile_max}) print_warning "cp ${beefile} ${PWD}/${PKGFULLNAME}-${PKGFULLVERSION}-$((PKGREVISION + 1)).bee"