-
Notifications
You must be signed in to change notification settings - Fork 2
Implement versionless bee files #7
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
94ef841
beesh: join together verify_new_package_variables and extract_new_pac…
donald 9c3c227
beesh: allow change of PKGVERSION , PKGEXTRAVERSION and PKGREVISION
donald 6becbc0
beesh: first run beefile, then check for completeness
donald 1963674
beesh: add validate_pkg_complete, validate_pkg_complete_from_filename
donald 476d2c1
beesh: call validate_pkg_from_filename
donald 29a17d8
beesh: add callback function bee_version
donald c43b32f
beesh: use validate_pkg_complete for check of completeness
donald 59b38ad
beesh: avoid warnings of beeversion
donald 60427db
beesh: avoid wrong diagnostic
donald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
|
@@ -191,8 +192,35 @@ function check_repositories() { | |
fi | ||
} | ||
|
||
function validate_pkg_complete() { | ||
test -n "$PKGNAME" -a -n "$PKGVERSION" -a -n "$PKGREVISION" || 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() { | ||
B=${S} | ||
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" 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" | ||
} | ||
|
||
function add_sourcesubdir() { | ||
|
@@ -732,9 +760,8 @@ 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 | ||
if [ "${oPKGFULLNAME}" != "${nPKGFULLNAME}" ] ; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this removal correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, it is. Please ignore. |
||
print_error "${BEE##*/}: Changing PKGFULLNAME and one of PKGNAME or PKGEXTRANAME is not supported." | ||
|
@@ -751,10 +778,6 @@ function verify_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="" | ||
|
@@ -763,9 +786,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 | ||
|
@@ -781,31 +802,15 @@ 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} | ||
|
||
# since PKGARCH is now known reconstruct PKGALLPKG | ||
: ${PKGALLPKG:=${PKGFULLPKG}.${PKGARCH}} | ||
|
||
eval $("${BEE_BINDIR}/beeversion" "${PKGALLPKG}") | ||
eval $("${BEE_BINDIR}/beeversion" "${PKGALLPKG}" 2>/dev/null) | ||
} | ||
|
||
############################################################################### | ||
############################################################################### | ||
############################################################################### | ||
|
||
|
@@ -961,37 +966,48 @@ PKGNAME= | |
PKGVERSION= | ||
PKGREVISION= | ||
|
||
eval $("${BEE_BINDIR}/beeversion" "${BEE}") | ||
eval $("${BEE_BINDIR}/beeversion" "${BEE}" 2>/dev/null) | ||
|
||
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 | ||
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 | ||
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}} | ||
|
||
verify_new_package_variables | ||
extract_new_package_variables | ||
|
||
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}" | ||
|
||
F=${BEEPKGROOT}/files | ||
S=${BEEWORKDIR}/source | ||
B=${BEEWORKDIR}/build | ||
D=${BEEWORKDIR}/image | ||
|
||
if [ "$BUILD_IN_SOURCEDIR" ] ; then | ||
print_info "BUILD_IN_SOURCEDIR requested" | ||
B="$S" | ||
fi | ||
|
||
|
||
config_handle_deprecated_beefile | ||
expand_prefix_variables | ||
config_export | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When should
bee_die
be used and whenprint_error
? When I want to save writingexit 1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I recognized, that I wrote
{print_error ... ; exit 1 }
a few times I refactored it into a procedure. It makes the code a bit more readable, when used as an expression (test bla || bee_die bla
instead oftest bla || { bee_error bla; exit 1;}
).I didn't walk through code unrelated to versionless to change it in very possible place.