Skip to content

Commit

Permalink
beesh: Enable versionless bee filenames by setting #@beepackage in be…
Browse files Browse the repository at this point in the history
…efile

use '#@beepackage pkg-1.0-0' to set version information within bee file.

the bee file needs to match <PKGNAME>.bee or <PKGFULLNAME>.bee

This enables bee-files to be stored in git repositories and track changes.
  • Loading branch information
mariux committed Jul 21, 2016
1 parent 130ccfd commit 356505d
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/beesh.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,20 @@ function check_rebuild() {
return 0
fi

print_warning "please increase revision number"

beefile_dir=${beefile%/*}
eval $(${BEEVERSION} "${beefile}")

beefile_pattern="${PKGFULLNAME}-${PKGFULLVERSION}"
beefile_pattern=${beefile_pattern//+/\\+} # replace all + with \+
beefile_pattern=${beefile_pattern//./\\.} # replace all . with \.

beefile_max=$(for bf in $(ls "${beefile%/*}/${beefile_pattern}*.bee" "${BEE_BEEDIR}/${beefile_pattern}*.bee" 2>/dev/null |\
beefile_max=$(for bf in $(ls ${beefile%/*}/${beefile_pattern}*.bee ${BEE_BEEDIR}/${beefile_pattern}*.bee 2>/dev/null |\
grep -E "/${beefile_pattern}-[0-9]+.bee") ; do
echo "${bf}"
done | ${BEESORT} | tail -1)

eval $(${BEEVERSION} ${beefile_max})
print_warning "cp ${beefile} ${PWD}/${PKGFULLNAME}-${PKGFULLVERSION}-$((PKGREVISION + 1)).bee"
print_warning "please increase revision number to $((PKGREVISION + 1))"

exit 1
}
Expand Down Expand Up @@ -949,7 +947,33 @@ PKGNAME=
PKGVERSION=
PKGREVISION=

eval $("${BEE_BINDIR}/beeversion" "${BEE}")
set +e

BEEOVERWRITE=( $(grep -m 1 '^#@beepackage' "${BEE}") )
if [ $? == 0 ] ; then
ver=${BEEOVERWRITE[1]}
overwrite=1
else
ver=${BEE}
overwrite=0
fi

set -e

eval $("${BEEVERSION}" "${ver}")

if [ "${overwrite}" == 1 ] ; then
if [ "${BEE##*/}" == "${PKGNAME}.bee" ] ; then
:
elif [ "${BEE##*/}" == "${PKGFULLNAME}.bee" ] ; then
:
elif [ "${BEE##*/}" == "${PKGFULLPKG}.bee" ] ; then
print_warning "***ATTENTION***: using full beefile name (including version) and the #@beepackage feature at the same time."
else
print_error "filename '${BEE##*/}' does not match '${BEEOVERWRITE[1]}' set as #@beepackage for PKGNAME or PKGFULLNAME"
exit 1
fi
fi

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)"
Expand Down Expand Up @@ -986,7 +1010,7 @@ config_export

###############################################################################

check_rebuild "${BEE}" "${PKGALLPKG}"
check_rebuild "${BEE%/*}/${PKGFULLPKG}.bee" "${PKGALLPKG}"

print_info "current working directory: ${PWD}"

Expand Down

0 comments on commit 356505d

Please sign in to comment.