From aac98d93df04bb9f1d3ebe70aaf9504ee4d7f50f Mon Sep 17 00:00:00 2001 From: Mark Ferrell Date: Fri, 31 Jan 2014 08:38:12 -0800 Subject: Enable support for "Release" versions * In bringing builder versions in-line with other vendor tools (ebuild, rpm, dpkg, etc) I am adding "optional" Release support. * In order to "hopefully" integrate with existing Builder tree's the RELEASE variable is allowed to be unset. If unset builder will attempt to derrive a release from the VERSION variable. If no RELEASE can be found, then the RELEASE defaults to 0. --- build | 17 +++++++++++++++++ builder/build-clean | 4 ++-- builder/build-distclean | 4 ++-- builder/build-install | 4 ++-- builder/build-makedeps | 2 +- builder/build-package | 10 +++++----- builder/build-query | 18 +++++++++++++++++- 7 files changed, 46 insertions(+), 13 deletions(-) diff --git a/build b/build index 68acae2..a1cfe50 100755 --- a/build +++ b/build @@ -107,6 +107,8 @@ import() # routine will source the build-rules to finish collecting data, so we # end up sourcing the Buildrules twice. eval $(build-query --environ "${1}") + RELEASE= + S= # Source in the category Buildrules if [ -f "${BUILDER_PKGDIR}/${CATEGORY}/.buildrules" ]; then @@ -127,6 +129,21 @@ import() if [ -z "${DESCRIPTION}" ]; then die "missing description in '${NAME}'" fi + + if test -z "${RELEASE}"; then + RELEASE="${VERSION#*-}" + if ! test -z "${RELEASE}" && test "${RELEASE}" != "${VERSION}"; then + VERSION="${VERSION%-${RELEASE}}" + if test -z "${S}"; then + S="${W}/${NAME}-${VERSION}-${RELEASE}" + fi + else + RELEASE='0' + fi + fi + if test -z "${S}"; then + S="${W}/${NAME}-${VERSION}" + fi } if [ ! -z "${BUILDER_DEBUG}" ]; then diff --git a/builder/build-clean b/builder/build-clean index 05c49ec..b7c0927 100755 --- a/builder/build-clean +++ b/builder/build-clean @@ -4,8 +4,8 @@ eval $(build-query --environ "${1}") if [ -z "${NOCLEAN}" ]; then echo "cleaning: ${1}" - if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" ]; then - rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" & + if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then + rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" & fi if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then cd "${SYSROOT}" diff --git a/builder/build-distclean b/builder/build-distclean index 2cf0cc9..1b61e4a 100755 --- a/builder/build-distclean +++ b/builder/build-distclean @@ -3,8 +3,8 @@ echo "distcleaning: ${1}" eval $(build-query --environ "${1}") -if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" ]; then - rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" & +if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then + rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" & fi if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then cd "${SYSROOT}" diff --git a/builder/build-install b/builder/build-install index 94f6971..7a2c121 100755 --- a/builder/build-install +++ b/builder/build-install @@ -3,7 +3,7 @@ echo "installing: ${1}" eval $(build-query --environ "${1}") -if [ ! -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" ]; then +if [ ! -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then die "archive does not exist for package '${NAME}'" fi if [ ! -d "${SYSROOT}" ]; then @@ -25,7 +25,7 @@ if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then rm "var/db/binpkgs/${CATEGORY}/${NAME}" fi -${ARCHIVE_DECOMPRESSOR} "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" | tar x +${ARCHIVE_DECOMPRESSOR} "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" | tar x touch "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" # vim: filetype=sh diff --git a/builder/build-makedeps b/builder/build-makedeps index cd03df9..e4b628c 100755 --- a/builder/build-makedeps +++ b/builder/build-makedeps @@ -37,7 +37,7 @@ for package in $(cd "${BUILDER_PKGDIR}" && echo */*); do fi package_make="$(echo "${package}"|tr '/-' '__')" - package_archive="${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" + package_archive="${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" package_install="${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" package_logdir="${L}" diff --git a/builder/build-package b/builder/build-package index 7be2932..aa9fd2d 100755 --- a/builder/build-package +++ b/builder/build-package @@ -175,8 +175,8 @@ echo "archiving: ${1}" mkenv "archive" PKG_LOGFILE="${L}/archive.log" -ARCHIVE_TMP1="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}.XXXXXXXX")" -ARCHIVE_TMP2="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}.XXXXXXXX")" +ARCHIVE_TMP1="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}-${RELEASE}.XXXXXXXX")" +ARCHIVE_TMP2="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}-${RELEASE}.XXXXXXXX")" [ -f "${ARCHIVE_TMP1}" ] || die "failed to create temporary archive for package '${NAME}'" [ -f "${ARCHIVE_TMP2}" ] || die "failed to create temporary archive for package '${NAME}'" @@ -194,10 +194,10 @@ fi cd "${D}" tar -cvf "${ARCHIVE_TMP1}" . > "${PKG_LOGFILE}" 2>&1 ${ARCHIVE_COMPRESSOR} "${ARCHIVE_TMP1}" > "${ARCHIVE_TMP2}" 2>> "${PKG_LOGFILE}" -if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" ]; then - rm -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" +if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then + rm -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" fi -mv -v "${ARCHIVE_TMP2}" "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" >> "${PKG_LOGFILE}" 2>&1 +mv -v "${ARCHIVE_TMP2}" "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" >> "${PKG_LOGFILE}" 2>&1 cd "${W}" find "${D}" -delete & diff --git a/builder/build-query b/builder/build-query index 4dce55c..3e74098 100755 --- a/builder/build-query +++ b/builder/build-query @@ -106,6 +106,8 @@ while [ "$#" -gt "0" ]; do QUERY_ACTION="pkgdir";; (-r|-rulefile|--rulesfile) QUERY_ACTION="rulesfile";; + (--release) + QUERY_ACTION="release";; (-R|-rdepends|--rdepends) QUERY_ACTION="rdepends";; (-rdeps-all|--rdeps-all) @@ -230,6 +232,7 @@ esac # These variables are only set within a Rulesfile and thus need to be cleared # before sourcing it in. VERSION= +RELEASE= DESCRIPTION= SOURCE_URI= PATCHES= @@ -245,7 +248,17 @@ fi if [ -d "${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" ]; then SOURCE_URI="file://${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" fi -export VERSION DESCRIPTION SOURCE_URI PATCHES BDEPENDS RDEPENDS + +if test -z "${RELEASE}"; then + RELEASE="${VERSION#*-}" + if ! test -z "${RELEASE}" && test "${RELEASE}" != "${VERSION}"; then + VERSION="${VERSION%-${RELEASE}}" + else + RELEASE='0' + fi +fi + +export VERSION RELEASE DESCRIPTION SOURCE_URI PATCHES BDEPENDS RDEPENDS # Ironically, the source working directory can't be assigned until we source in # the Buildrules due to the dependancy on the VERSION @@ -260,6 +273,7 @@ case "${QUERY_ACTION}" in (rdeps_all) recurse_rdeps ${RDEPENDS};; (descr) echo "${DESCRIPTION}";; (version) echo "${VERSION}";; +(release) echo "${RELEASE}";; (patches) echo "${PATCHES}";; # Allow the caller to specify the variable to report. @@ -285,6 +299,7 @@ case "${QUERY_ACTION}" in CATEGORY="${CATEGORY}" RULESFILE="${RULESFILE}" VERSION="${VERSION}" + RELEASE="${RELEASE}" DESCRIPTION="${DESCRIPTION}" SOURCE_URI="${SOURCE_URI}" EOF @@ -324,6 +339,7 @@ case "${QUERY_ACTION}" in (summary) echo "Name: ${CATEGORY}/${NAME}" echo "Version: ${VERSION}" + echo "Release: ${RELEASE}" echo "Source: ${SOURCE_URI}" if [ ! -z "${RDEPENDS}" ]; then echo "Depends: ${RDEPENDS}" -- cgit v1.2.3-18-g5258