diff --git a/build-tools/build-srpms-parallel b/build-tools/build-srpms-parallel index f2610597..2f4f398f 100755 --- a/build-tools/build-srpms-parallel +++ b/build-tools/build-srpms-parallel @@ -654,6 +654,7 @@ build_dir_srpm () { local COPY_LIST_TO_TAR local SRC_DIR local TIS_PATCH_VER + local PBR_VERSION local BUILD_IS_BIG=0 local BUILD_IS_SLOW=0 @@ -751,8 +752,8 @@ build_dir_srpm () { return 1 fi - echo "srpm_extract_to_git '$ORIG_SRPM_PATH' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER'" - srpm_extract_to_git $ORIG_SRPM_PATH $PKG_BASE $ROOT_DIR $BUILD_DIR $PKG_NAME_VER $NO_META_PATCH_FLAG $TIS_PATCH_VER + echo "srpm_extract_to_git '$ORIG_SRPM_PATH' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER' '$PBR_VERSION'" + srpm_extract_to_git $ORIG_SRPM_PATH $PKG_BASE $ROOT_DIR $BUILD_DIR $PKG_NAME_VER $NO_META_PATCH_FLAG $TIS_PATCH_VER $PBR_VERSION RC=$? if [ $RC -ne 0 ]; then if [ $RC -eq 1 ]; then @@ -819,7 +820,7 @@ build_dir_srpm () { done fi - srpm_assemble $FULL_BUILD_DIR $TIS_PATCH_VER + srpm_assemble $FULL_BUILD_DIR $TIS_PATCH_VER $PBR_VERSION if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): failed to assemble srpm for '$PKG_NAME_VER'" @@ -973,6 +974,7 @@ build_dir_spec () { local SRC_DIR local OPT_DEP_LIST local TIS_PATCH_VER + local PBR_VERSION local BUILD_IS_BIG=0 local BUILD_IS_SLOW=0 @@ -1057,8 +1059,8 @@ build_dir_spec () { return 1 fi - echo "tar_and_spec_extract_to_git '$SPEC' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER'" - tar_and_spec_extract_to_git "$SPEC" "$PKG_BASE" "$ROOT_DIR" "$BUILD_DIR" "$PKG_NAME_VER" "$NO_META_PATCH_FLAG" "$TIS_PATCH_VER" + echo "tar_and_spec_extract_to_git '$SPEC' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER' '$PBR_VERSION'" + tar_and_spec_extract_to_git "$SPEC" "$PKG_BASE" "$ROOT_DIR" "$BUILD_DIR" "$PKG_NAME_VER" "$NO_META_PATCH_FLAG" "$TIS_PATCH_VER" "$PBR_VERSION" RC=$? if [ $RC -ne 0 ]; then if [ $RC -eq 1 ]; then diff --git a/build-tools/build-srpms-serial b/build-tools/build-srpms-serial index aa00d8c1..2df1ee71 100755 --- a/build-tools/build-srpms-serial +++ b/build-tools/build-srpms-serial @@ -632,6 +632,7 @@ build_dir_srpm () { local COPY_LIST_TO_TAR local SRC_DIR local TIS_PATCH_VER + local PBR_VERSION local BUILD_IS_BIG=0 local BUILD_IS_SLOW=0 @@ -730,8 +731,8 @@ build_dir_srpm () { return 1 fi - echo "srpm_extract_to_git '$ORIG_SRPM_PATH' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER'" - srpm_extract_to_git $ORIG_SRPM_PATH $PKG_BASE $ROOT_DIR $BUILD_DIR $PKG_NAME_VER $NO_META_PATCH_FLAG $TIS_PATCH_VER + echo "srpm_extract_to_git '$ORIG_SRPM_PATH' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER' '$PBR_VERSION'" + srpm_extract_to_git $ORIG_SRPM_PATH $PKG_BASE $ROOT_DIR $BUILD_DIR $PKG_NAME_VER $NO_META_PATCH_FLAG $TIS_PATCH_VER $PBR_VERSION RC=$? if [ $RC -ne 0 ]; then if [ $RC -eq 1 ]; then @@ -797,7 +798,7 @@ build_dir_srpm () { done fi - srpm_assemble $FULL_BUILD_DIR $TIS_PATCH_VER + srpm_assemble $FULL_BUILD_DIR $TIS_PATCH_VER $PBR_VERSION if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): failed to assemble srpm for '$PKG_NAME_VER'" SRPM_FAILED_REBUILD_LIST="$SRPM_FAILED_REBUILD_LIST $TARGET_FOUND" @@ -948,6 +949,7 @@ build_dir_spec () { local SRC_DIR local OPT_DEP_LIST local TIS_PATCH_VER + local PBR_VERSION local BUILD_IS_BIG=0 local BUILD_IS_SLOW=0 @@ -1035,8 +1037,8 @@ build_dir_spec () { return 1 fi - echo "tar_and_spec_extract_to_git '$SPEC' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER'" - tar_and_spec_extract_to_git "$SPEC" "$PKG_BASE" "$ROOT_DIR" "$BUILD_DIR" "$PKG_NAME_VER" "$NO_META_PATCH_FLAG" "$TIS_PATCH_VER" + echo "tar_and_spec_extract_to_git '$SPEC' '$PKG_BASE' '$ROOT_DIR' '$BUILD_DIR' '$PKG_NAME_VER' '$NO_META_PATCH_FLAG' '$TIS_PATCH_VER' '$PBR_VERSION'" + tar_and_spec_extract_to_git "$SPEC" "$PKG_BASE" "$ROOT_DIR" "$BUILD_DIR" "$PKG_NAME_VER" "$NO_META_PATCH_FLAG" "$TIS_PATCH_VER" "$PBR_VERSION" RC=$? if [ $RC -ne 0 ]; then if [ $RC -eq 1 ]; then diff --git a/build-tools/default_build_srpm b/build-tools/default_build_srpm index e562fa0a..48c5123d 100755 --- a/build-tools/default_build_srpm +++ b/build-tools/default_build_srpm @@ -18,6 +18,10 @@ if [ $? -ne 0 ]; then exit 1 fi +if [ "x$PBR_VERSION" != "x" ] && [ "x$PBR_VERSION" != "xNA" ]; then + VERSION=$PBR_VERSION +fi + if [ "x$VERSION" == "x" ]; then for SPEC in `find $SPECS_BASE -name '*.spec' | sort -V`; do SPEC_PATH="$SPEC" @@ -253,9 +257,11 @@ for SPEC in `ls -1 $BUILD_DIR/SPECS`; do echo "SPEC file: $SPEC_PATH" echo "SRPM build directory: $BUILD_DIR" echo "TIS_PATCH_VER: $TIS_PATCH_VER" + echo "PBR_VERSION: $PBR_VERSION" sed -i -e "1 i%define _tis_build_type $BUILD_TYPE" $SPEC_PATH sed -i -e "1 i%define tis_patch_ver $TIS_PATCH_VER" $SPEC_PATH + sed -i -e "1 i%define pbr_version $PBR_VERSION" $SPEC_PATH rpmbuild -bs $SPEC_PATH --define="%_topdir $BUILD_DIR" --undefine=dist --define="_tis_dist .tis" else echo "SRPM build not needed" diff --git a/build-tools/spec-utils b/build-tools/spec-utils index 49f0c14d..6e531158 100644 --- a/build-tools/spec-utils +++ b/build-tools/spec-utils @@ -4,6 +4,7 @@ spec_query_with_macros () { local SPEC_FILE=$1; shift local BUILD_DIR=$1; shift local TIS_PATCH_VER=$1; shift + local PBR_VERSION=$1; shift local rc TMPSPEC=$(mktemp /tmp/spec-utils-XXXXXX) @@ -13,6 +14,7 @@ spec_query_with_macros () { --define="_tis_build_type ${BUILD_TYPE:-std}" \ --define="_tis_dist .tis" \ --define="tis_patch_ver ${TIS_PATCH_VER:-0}" \ + --define="pbr_version ${PBR_VERSION:-0}" \ --define="platform_release ${PLATFORM_RELEASE:-00.00}" \ --define="%_topdir $BUILD_DIR" \ "${@}" \ @@ -78,6 +80,7 @@ spec_evaluate () { _tis_build_type) MACRO_VALUE="${BUILD_TYPE}" ;; _tis_dist) MACRO_VALUE=".tis" ;; tis_patch_ver) MACRO_VALUE="{TIS_PATCH_VER:-0}" ;; + pbr_version) MACRO_VALUE="{PBR_VERSION:-0}" ;; platform_release) MACRO_VALUE="$PLATFORM_RELEASE" ;; _topdir) MACRO_VALUE="$BUILD_DIR" ;; *) ;; @@ -148,9 +151,9 @@ spec_find_macro_via_rpm () { # >&2 echo "spec_find_macro_via_rpm: TARGET=$TARGET" case "$TARGET" in - name|_name) (spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{NAME}\n' | head -n 1 ; exit ${PIPESTATUS[0]} ); RC=$? ;; - version|_version) (spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{VERSION}\n' | head -n 1 ; exit ${PIPESTATUS[0]} ); RC=$? ;; - release|_release) (spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{RELEASE}\n' | head -n 1 ; exit ${PIPESTATUS[0]} ); RC=$? ;; + name|_name) (spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{NAME}\n' | head -n 1 ; exit ${PIPESTATUS[0]} ); RC=$? ;; + version|_version) (spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{VERSION}\n' | head -n 1 ; exit ${PIPESTATUS[0]} ); RC=$? ;; + release|_release) (spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{RELEASE}\n' | head -n 1 ; exit ${PIPESTATUS[0]} ); RC=$? ;; *) ;; esac @@ -199,6 +202,7 @@ spec_find_tag () { local SPEC_FILE=$2 local RPMBUILD_DIR=$3 local TIS_PATCH_VER=$4 + local PBR_VERSION=$5 local LINE="" if [ "x$RPMBUILD_DIR" == "x" ];then @@ -209,7 +213,7 @@ spec_find_tag () { # Note: ${VAR:-val} is bash syntax for providing a default value. # ie. if $VAR is not set, use 'val' as default value - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} > $SPEC_FILE2 + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} > $SPEC_FILE2 if [ $? != 0 ]; then # spec_query_with_macros can fail on grub2 if it's just a spec file without SOURCES \cp $SPEC_FILE $SPEC_FILE2 @@ -326,14 +330,14 @@ spec_list_packages () { if [ "$bd" == "SPECS" ]; then local dd=$(dirname $d) - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}\n' --define="%_topdir $dd" 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}\n' --define="%_topdir $dd" 2>> /dev/null else - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}\n' 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}\n' 2>> /dev/null fi if [ $? -ne 0 ]; then # spec_query_with_macros can fail on grub2 if it's just a spec file without SOURCES - local NAME=$(spec_find_tag Name "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + local NAME=$(spec_find_tag Name "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) if [ $? -ne 0 ]; then >&2 echo "ERROR: failed to evaluate 'Name'" return 1 @@ -353,7 +357,7 @@ spec_list_packages () { fi # >&2 echo "spec_list_packages: PKG_NAME_TEMP=$PKG_NAME_TEMP" - PKG_NAME=$(spec_evaluate "$PKG_NAME_TEMP" "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + PKG_NAME=$(spec_evaluate "$PKG_NAME_TEMP" "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) if [ $? -ne 0 ]; then >&2 echo "ERROR: failed to evaluate package '$PACKAGE_LINE'" return 1 @@ -378,20 +382,20 @@ spec_list_versioned_packages () { if [ "$bd" == "SPECS" ]; then local dd=$(dirname $d) - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}-%{version}\n' --define="%_topdir $dd" 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}-%{version}\n' --define="%_topdir $dd" 2>> /dev/null else - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}-%{version}\n' 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}-%{version}\n' 2>> /dev/null fi if [ $? -ne 0 ]; then # spec_query_with_macros can fail on grub2 if it's just a spec file without SOURCES - local NAME=$(spec_find_tag Name "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + local NAME=$(spec_find_tag Name "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) if [ $? -ne 0 ]; then >&2 echo "ERROR: failed to evaluate 'Name'" return 1 fi - local VERSION=$(spec_find_tag Version "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + local VERSION=$(spec_find_tag Version "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) echo "$NAME-$VERSION" grep "^%package" $SPEC_FILE | while read PACKAGE_LINE; do @@ -407,7 +411,7 @@ spec_list_versioned_packages () { fi # >&2 echo "spec_list_packages: PKG_NAME_TEMP=$PKG_NAME_TEMP" - PKG_NAME=$(spec_evaluate "$PKG_NAME_TEMP" "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + PKG_NAME=$(spec_evaluate "$PKG_NAME_TEMP" "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) if [ $? -ne 0 ]; then >&2 echo "ERROR: failed to evaluate package '$PACKAGE_LINE'" return 1 @@ -431,9 +435,9 @@ spec_name_ver_rel () { RPMBUILD_DIR=$(dirname $(dirname $SPEC_FILE)) fi - NAME=$(spec_find_tag Name $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) - VERSION=$(spec_find_tag Version $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) - RELEASE=$(spec_find_tag Release $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + NAME=$(spec_find_tag Name $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) + VERSION=$(spec_find_tag Version $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) + RELEASE=$(spec_find_tag Release $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) echo "$NAME-$VERSION-$RELEASE" } @@ -450,21 +454,21 @@ spec_list_ver_rel_packages () { if [ "$bd" == "SPECS" ]; then local dd=$(dirname $d) - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}-%{version}-%{release}\n' --define="%_topdir $dd" 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}-%{version}-%{release}\n' --define="%_topdir $dd" 2>> /dev/null else - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}-%{version}-%{release}\n' 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}-%{version}-%{release}\n' 2>> /dev/null fi if [ $? -ne 0 ]; then # spec_query_with_macros can fail on grub2 if it's just a spec file without SOURCES - local NAME=$(spec_find_tag Name "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + local NAME=$(spec_find_tag Name "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) if [ $? -ne 0 ]; then >&2 echo "ERROR: failed to evaluate 'Name'" return 1 fi - local VERSION=$(spec_find_tag Version "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) - local RELEASE=$(spec_find_tag Release "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + local VERSION=$(spec_find_tag Version "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) + local RELEASE=$(spec_find_tag Release "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0}) echo "$NAME-$VERSION-$RELEASE" grep "^%package" $SPEC_FILE | while read PACKAGE_LINE; do @@ -480,7 +484,7 @@ spec_list_ver_rel_packages () { fi # >&2 echo "spec_list_packages: PKG_NAME_TEMP=$PKG_NAME_TEMP" - PKG_NAME=$(spec_evaluate "$PKG_NAME_TEMP" "$SPEC_FILE" $RPMBUILD_DIR ${TIS_PATCH_VER:-0}) + PKG_NAME=$(spec_evaluate "$PKG_NAME_TEMP" "$SPEC_FILE" $RPMBUILD_DIR) if [ $? -ne 0 ]; then >&2 echo "ERROR: failed to evaluate package '$PACKAGE_LINE'" return 1 @@ -505,9 +509,9 @@ spec_list_ver_rel_arch_packages () { if [ "$bd" == "SPECS" ]; then local dd=$(dirname $d) - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}-%{version}-%{release}.%{arch}\n' --define="%_topdir $dd" 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}-%{version}-%{release}.%{arch}\n' --define="%_topdir $dd" 2>> /dev/null else - spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} -q --qf '%{name}-%{version}-%{release}.%{arch}\n' 2>> /dev/null + spec_query_with_macros $SPEC_FILE $RPMBUILD_DIR ${TIS_PATCH_VER:-0} ${PBR_VERSION:-0} -q --qf '%{name}-%{version}-%{release}.%{arch}\n' 2>> /dev/null fi } @@ -691,6 +695,10 @@ spec_untar_path () { spec_validate_tis_release () { local SPEC_FILE=$1 + if rpmspec --define='_tis_dist .tis' -P $SPEC_FILE 2>/dev/null | grep '^Version:' | grep '%{pbr_version}'; then + return 0 + fi + # TIS Release value must include either %{?_tis_dist}.%{tis_patch_ver} or %{tis_patch_ver}%{?_tis_dist} # Because spec_query_with_macros defines tis_patch_ver, we're using rpmspec directly here rpmspec --define='_tis_dist .tis' -P $SPEC_FILE 2>/dev/null | grep '^Release:' \ diff --git a/build-tools/srpm-utils b/build-tools/srpm-utils index 84e9045d..73c9254e 100644 --- a/build-tools/srpm-utils +++ b/build-tools/srpm-utils @@ -155,8 +155,9 @@ srpm_create_raw_extract_script () { local TIS_PATCH_VER=$5 local RAW_SCRIPT=$6 local TAR_DIR=$7 + local PBR_VERSION=${8:-0} - echo "SPEC_FILE=$SPEC_FILE ROOT_DIR=$ROOT_DIR RPMBUILD_DIR=$RPMBUILD_DIR TARGET_ARCH=$TARGET_ARCH TIS_PATCH_VER=$TIS_PATCH_VER RAW_SCRIPT=$RAW_SCRIPT TAR_DIR=$TAR_DIR" + echo "SPEC_FILE=$SPEC_FILE ROOT_DIR=$ROOT_DIR RPMBUILD_DIR=$RPMBUILD_DIR TARGET_ARCH=$TARGET_ARCH TIS_PATCH_VER=$TIS_PATCH_VER RAW_SCRIPT=$RAW_SCRIPT TAR_DIR=$TAR_DIR PBR_VERSION=$PBR_VERSION" local BUILD_DIR="$RPMBUILD_DIR/BUILD" local ApplyPatchCount=0 @@ -184,11 +185,12 @@ srpm_create_raw_extract_script () { local SAME=0 # Build the srpm as though for std build, for naming consistency - echo "stdbuf -oL -eL rpmbuild -bp $SPEC_FILE --root $ROOT_DIR --define='%_topdir $RPMBUILD_DIR' --define='_tis_dist .tis' --define='tis_patch_ver $TIS_PATCH_VER' --nodeps --target $TARGET_ARCH > $STDOUT_LOG 2> $STDERR_LOG" + echo "stdbuf -oL -eL rpmbuild -bp $SPEC_FILE --root $ROOT_DIR --define='%_topdir $RPMBUILD_DIR' --define='_tis_dist .tis' --define='tis_patch_ver $TIS_PATCH_VER' --define='pbr_version $PBR_VERSION' --nodeps --target $TARGET_ARCH > $STDOUT_LOG 2> $STDERR_LOG" stdbuf -oL -eL rpmbuild -bp $SPEC_FILE --root $ROOT_DIR \ --define="%_topdir $RPMBUILD_DIR" \ --define='_tis_dist .tis' \ --define="tis_patch_ver $TIS_PATCH_VER" \ + --define="pbr_version $PBR_VERSION" \ --define="_tis_build_type $BUILD_TYPE" \ --nodeps --target $TARGET_ARCH > $STDOUT_LOG 2> $STDERR_LOG if [ $? -ne 0 ]; then @@ -212,6 +214,7 @@ srpm_create_raw_extract_script () { --define="%_topdir $RPMBUILD_DIR" \ --define='_tis_dist .tis' \ --define="tis_patch_ver $TIS_PATCH_VER" \ + --define="pbr_version $PBR_VERSION" \ --define="_tis_build_type $BUILD_TYPE" \ --nodeps --target $TARGET_ARCH > $STDOUT_LOG 2> $STDERR_LOG if [ $? -ne 0 ]; then @@ -1230,6 +1233,7 @@ srpm_build_std_dictionary () { srpm_assemble () { local FULL_BUILD_DIR=$1 local TIS_PATCH_VER=$2 + local PBR_VERSION=$3 local SPEC_PATH local SPEC @@ -1257,7 +1261,7 @@ srpm_assemble () { fi fi - RELEASE=$(spec_find_tag Release "$SPEC_PATH" "$(dirname $(dirname $SPEC_PATH))" "$TIS_PATCH_VER" 2>> /dev/null) + RELEASE=$(spec_find_tag Release "$SPEC_PATH" "$(dirname $(dirname $SPEC_PATH))" "$TIS_PATCH_VER" "$PBR_VERSION" 2>> /dev/null) if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): 'Release' not found in '$SPEC_PATH'" RELEASE="0" @@ -1286,9 +1290,11 @@ srpm_assemble () { echo "SPEC file: $SPEC_PATH" echo "SRPM build directory: $FULL_BUILD_DIR" echo "TIS_PATCH_VER: $TIS_PATCH_VER" + echo "PBR_VERSION: $PBR_VERSION" sed -i -e "1 i%define _tis_build_type $BUILD_TYPE" $SPEC_PATH sed -i -e "1 i%define tis_patch_ver $TIS_PATCH_VER" $SPEC_PATH + sed -i -e "1 i%define pbr_version $PBR_VERSION" $SPEC_PATH # Build the srpm as though for std build, for naming consistency if [ "x$PLATFORM_RELEASE" == "x" ]; then @@ -1647,9 +1653,10 @@ tarball_extract () { local TIS_PATCH_VER="${12}" local OUTPUT_FILE="${13}" local NO_META_PATCH=${14} + local PBR_VERSION=${15} # BUILD_TYPE exported from higher layers - echo "tarball_extract SPEC_DIR=$SPEC_DIR SPEC=$SPEC SPEC_GIT=$SPEC_GIT SOURCE_DIR=$SOURCE_DIR BRANCH=$BRANCH ORIG_BRANCH=$ORIG_BRANCH TAR_DIR=$TAR_DIR ROOT_DIR=$ROOT_DIR PKG_DIR=$PKG_DIR BUILD_DIR=$BUILD_DIR TARGET_ARCH=$TARGET_ARCH TIS_PATCH_VER=$TIS_PATCH_VER OUTPUT_FILE=$OUTPUT_FILE NO_META_PATCH=$NO_META_PATCH" + echo "tarball_extract SPEC_DIR=$SPEC_DIR SPEC=$SPEC SPEC_GIT=$SPEC_GIT SOURCE_DIR=$SOURCE_DIR BRANCH=$BRANCH ORIG_BRANCH=$ORIG_BRANCH TAR_DIR=$TAR_DIR ROOT_DIR=$ROOT_DIR PKG_DIR=$PKG_DIR BUILD_DIR=$BUILD_DIR TARGET_ARCH=$TARGET_ARCH TIS_PATCH_VER=$TIS_PATCH_VER OUTPUT_FILE=$OUTPUT_FILE NO_META_PATCH=$NO_META_PATCH PBR_VERSION=$PBR_VERSION" if [ -f $OUTPUT_FILE ]; then \rm -f $OUTPUT_FILE @@ -1706,8 +1713,8 @@ tarball_extract () { RAW_SCRIPT=$ROOT_DIR/$PKG_DIR/raw_script EXTRACT_SCRIPT=$ROOT_DIR/$PKG_DIR/extract_script - echo "srpm_create_raw_extract_script '$SPEC_DIR/$SPEC' '$ROOT_DIR/$PKG_DIR' '$ROOT_DIR/$BUILD_DIR' '$TARGET_ARCH' '$TIS_PATCH_VER' '$RAW_SCRIPT' '$TAR_DIR'" - srpm_create_raw_extract_script "$SPEC_DIR/$SPEC" "$ROOT_DIR/$PKG_DIR" "$ROOT_DIR/$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$RAW_SCRIPT" "$TAR_DIR" + echo "srpm_create_raw_extract_script '$SPEC_DIR/$SPEC' '$ROOT_DIR/$PKG_DIR' '$ROOT_DIR/$BUILD_DIR' '$TARGET_ARCH' '$TIS_PATCH_VER' '$RAW_SCRIPT' '$TAR_DIR' '$PBR_VERSION'" + srpm_create_raw_extract_script "$SPEC_DIR/$SPEC" "$ROOT_DIR/$PKG_DIR" "$ROOT_DIR/$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$RAW_SCRIPT" "$TAR_DIR" "$PBR_VERSION" if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): srpm_create_raw_extract_script failed" cd $ORIG_DIR @@ -2194,6 +2201,7 @@ tar_and_spec_extract_to_git () { local BRANCH=$5 local NO_META_PATCH=$6 local TIS_PATCH_VER=$7 + local PBR_VERSION=$8 local USE_GIT=1 local TARGET_ARCH=x86_64 @@ -2344,7 +2352,7 @@ tar_and_spec_extract_to_git () { local RPMBUILD_BUILD_DIR="" local OUTPUT_FILE="$ROOT_DIR/$PKG_DIR/tarball_extract_result" - tarball_extract "$SPEC_DIR" "$SPEC" "$SPEC_GIT" "$SOURCE_DIR" "$BRANCH" "$ORIG_BRANCH" "$TAR_DIR" "$ROOT_DIR" "$PKG_DIR" "$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$OUTPUT_FILE" + tarball_extract "$SPEC_DIR" "$SPEC" "$SPEC_GIT" "$SOURCE_DIR" "$BRANCH" "$ORIG_BRANCH" "$TAR_DIR" "$ROOT_DIR" "$PKG_DIR" "$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$OUTPUT_FILE" "$NO_META_PATCH" "$PBR_VERSION" if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): tarball_extract failed while extracting '$SPEC_PATH'" cd $ORIG_DIR @@ -2375,7 +2383,8 @@ srpm_extract_to_git () { local BUILD_DIR=$4 local BRANCH=$5 local NO_META_PATCH=$6 - local TIS_PATCH_VER=$7 + local TIS_PATCH_VER=${7:-0} + local PBR_VERSION=${8:-0} local USE_GIT=1 local TARGET_ARCH=x86_64 @@ -2491,7 +2500,7 @@ srpm_extract_to_git () { local RPMBUILD_BUILD_DIR="" local OUTPUT_FILE="$ROOT_DIR/$PKG_DIR/tarball_extract_result" - tarball_extract "$SPEC_DIR" "$SPEC" "$SPEC_GIT" "$SOURCE_DIR" "$BRANCH" "$ORIG_BRANCH" "$TAR_DIR" "$ROOT_DIR" "$PKG_DIR" "$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$OUTPUT_FILE" "$NO_META_PATCH" + tarball_extract "$SPEC_DIR" "$SPEC" "$SPEC_GIT" "$SOURCE_DIR" "$BRANCH" "$ORIG_BRANCH" "$TAR_DIR" "$ROOT_DIR" "$PKG_DIR" "$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$OUTPUT_FILE" "$NO_META_PATCH" "$PBR_VERSION" if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): tarball_extract failed while extracting '$ORIG_SRPM_PATH'" cd $ORIG_DIR @@ -2580,8 +2589,8 @@ srpm_extract_to_git () { fi mkdir -p $RPMBUILD_BUILD_DIR2 - echo "srpm_create_raw_extract_script '$SPEC_DIR/$SPEC' '$ROOT_DIR/$PKG_DIR' '$ROOT_DIR/$BUILD_DIR' '$TARGET_ARCH' '$TIS_PATCH_VER' '$RAW_SCRIPT' '$TAR_DIR'" - srpm_create_raw_extract_script "$SPEC_DIR/$SPEC" "$ROOT_DIR/$PKG_DIR" "$ROOT_DIR/$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$RAW_SCRIPT" "$TAR_DIR" + echo "srpm_create_raw_extract_script '$SPEC_DIR/$SPEC' '$ROOT_DIR/$PKG_DIR' '$ROOT_DIR/$BUILD_DIR' '$TARGET_ARCH' '$TIS_PATCH_VER' '$RAW_SCRIPT' '$TAR_DIR' '$PBR_VERSION'" + srpm_create_raw_extract_script "$SPEC_DIR/$SPEC" "$ROOT_DIR/$PKG_DIR" "$ROOT_DIR/$BUILD_DIR" "$TARGET_ARCH" "$TIS_PATCH_VER" "$RAW_SCRIPT" "$TAR_DIR" "$PBR_VERSION" if [ $? -ne 0 ]; then echo "ERROR: $FUNCNAME (${LINENO}): srpm_create_raw_extract_script post meta-patches failed" cd $ORIG_DIR @@ -3197,6 +3206,21 @@ srpm_git_revision_count_pkg () { return 0 } +srpm_pbr_version () { + local SRC_DIR=$1 + local VER + + pushd $SRC_DIR > /dev/null + VER=$(python setup.py -q rpm_version) + if [ $? -ne 0 ]; then + return 1 + fi + popd > /dev/null + + echo $VER + return 0 +} + srpm_source_build_data () { local DATA_FILE=$1 if [ ! -f $DATA_FILE ]; then @@ -3206,9 +3230,20 @@ srpm_source_build_data () { source $DATA_FILE # TIS_PATCH_VER is mandatory - if [ -z "$TIS_PATCH_VER" ]; then - >&2 echo "ERROR: $FUNCNAME (${LINENO}): TIS_PATCH_VER must be set in $DATA_FILE" + if [ -z "$TIS_PATCH_VER" ] && [ -z "$PBR_VERSION" ]; then + >&2 echo "ERROR: $FUNCNAME (${LINENO}): TIS_PATCH_VER or PBR_VERSION must be set in $DATA_FILE" return 1 + elif [[ "$PBR_VERSION" == "auto" ]]; then + TIS_PATCH_VER="0" + if [ ! -d "$SRC_DIR" ]; then + >&2 echo "ERROR: $FUNCNAME (${LINENO}): SRC_DIR must specify a subgit root path" + return 1 + fi + PBR_VERSION=$(srpm_pbr_version $SRC_DIR) + if [ $? -ne 0 ] || [ "$PBR_VERSION" == "" ]; then + >&2 echo "ERROR: $FUNCNAME (${LINENO}): Invalid PBR_VERSION '$PBR_VERSION'" + return 1 + fi elif [[ "${TIS_PATCH_VER}" =~ [^0-9] ]]; then # Expand TIS_PATCH_VER with supported variables local -i PKG_GITREVCOUNT=0 @@ -3252,5 +3287,8 @@ srpm_source_build_data () { TIS_PATCH_VER=$((TIS_PATCH_VER)) fi + # to avoid mockbuild error + PBR_VERSION=${PBR_VERSION:=NA} + return 0 }