From de1e8619cabac9becebf685930986c6e2c8a86de Mon Sep 17 00:00:00 2001 From: Mohammed Ahmed Date: Fri, 22 Apr 2022 17:50:33 +0530 Subject: [PATCH] Updating rpm scripts based on recommendations (#5685) https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_handling_non_sorting_versions_with_tilde_dot_and_caret Signed-off-by: Mohammed Zeeshan Ahmed --- rpms/openshift-odo.spec | 13 ++++++------ scripts/rpm-prepare.sh | 45 +++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/rpms/openshift-odo.spec b/rpms/openshift-odo.spec index c52bae6fd1a..a07000ee31e 100644 --- a/rpms/openshift-odo.spec +++ b/rpms/openshift-odo.spec @@ -7,7 +7,8 @@ %global product_name odo %global golang_version ${GOLANG_VERSION} %global golang_version_nodot ${GOLANG_VERSION_NODOT} -%global odo_version ${ODO_RPM_VERSION} +%global odo_version ${ODO_VERSION} +%global odo_rpm_version ${ODO_RPM_VERSION} %global odo_release ${ODO_RELEASE} %global git_commit ${GIT_COMMIT} %global odo_cli_version v%{odo_version} @@ -17,7 +18,7 @@ %global _missing_build_ids_terminate_build 0 Name: %{package_name} -Version: %{odo_version} +Version: %{odo_rpm_version} Release: %{odo_release}%{?dist} Summary: %{product_name} client odo CLI binary License: ASL 2.0 @@ -26,8 +27,8 @@ URL: https://github.com/redhat-developer/odo/tree/%{odo_cli_version} Source0: %{source_tar} BuildRequires: gcc BuildRequires: golang >= %{golang_version} -Provides: %{package_name} = %{odo_version} -Obsoletes: %{package_name} <= %{odo_version} +Provides: %{package_name} = %{odo_rpm_version} +Obsoletes: %{package_name} <= %{odo_rpm_version} %description odo is a fast, iterative, and straightforward CLI tool for developers who write, build, and deploy applications on OpenShift. @@ -75,8 +76,8 @@ cp -avrf dist/release/VERSION %{buildroot}%{_datadir}/%{name}-redistributable Summary: %{product_name} client CLI binaries for Linux, macOS and Windows BuildRequires: gcc BuildRequires: golang >= %{golang_version} -Provides: %{package_name}-redistributable = %{odo_version} -Obsoletes: %{package_name}-redistributable <= %{odo_version} +Provides: %{package_name}-redistributable = %{odo_rpm_version} +Obsoletes: %{package_name}-redistributable <= %{odo_rpm_version} %description redistributable %{product_name} client odo cross platform binaries for Linux, macOS and Windows. diff --git a/scripts/rpm-prepare.sh b/scripts/rpm-prepare.sh index 08ecfaf37fa..160f3aba378 100755 --- a/scripts/rpm-prepare.sh +++ b/scripts/rpm-prepare.sh @@ -4,24 +4,26 @@ set +ex echo "Reading ODO_VERSION, ODO_RELEASE and GIT_COMMIT env, if they are set" # Change version as needed. In most cases ODO_RELEASE would not be touched unless -# we want to do a re-lease of same version as we are not backporting +# we want to do a re-lease of same version as we are not backport export ODO_VERSION=${ODO_VERSION:=3.0.0-alpha1} export ODO_RELEASE=${ODO_RELEASE:=1} -export GIT_COMMIT=${GIT_COMMIT:=`git rev-parse --short HEAD 2>/dev/null`} -export ODO_RPM_VERSION=${ODO_VERSION//-} +export GIT_COMMIT=${GIT_COMMIT:=$(git rev-parse --short HEAD 2>/dev/null)} + +ODO_RPM_VERSION=$(echo $ODO_VERSION | tr '-' '~') +export ODO_RPM_VERSION # Golang version variables, if you are bumping this, please contact redhat maintainers to ensure that internal # build systems can handle these versions export GOLANG_VERSION=${GOLANG_VERSION:-1.16} export GOLANG_VERSION_NODOT=${GOLANG_VERSION_NODOT:-116} -# Print env for verifcation +# Print env for verification echo "Printing envs for verification" echo "ODO_VERSION=$ODO_VERSION" +echo "ODO_RPM_VERSION=$ODO_RPM_VERSION" echo "ODO_RELEASE=$ODO_RELEASE" echo "GIT_COMMIT=$GIT_COMMIT" -echo "ODO_RPM_VERSION=$ODO_RPM_VERSION" echo "GOLANG_VERSION=$GOLANG_VERSION" echo "GOLANG_VERSION_NODO=$GOLANG_VERSION_NODOT" @@ -32,19 +34,19 @@ SPEC_DIR="$OUT_DIR/SPECS" SOURCES_DIR="$OUT_DIR/SOURCES" FINAL_OUT_DIR="$DIST_DIR/rpmbuild" -NAME="openshift-odo-$ODO_RPM_VERSION-$ODO_RELEASE" +NAME="openshift-odo-$ODO_VERSION-$ODO_RELEASE" echo "Making release for $NAME, git commit $GIT_COMMIT" echo "Cleaning up old content" -rm -rf $DIST_DIR -rm -rf $FINAL_OUT_DIR +rm -rf "$DIST_DIR" +rm -rf "$FINAL_OUT_DIR" echo "Configuring output directory $OUT_DIR" rm -rf $OUT_DIR -mkdir -p $SPEC_DIR +mkdir -p "$SPEC_DIR" mkdir -p $SOURCES_DIR/$NAME -mkdir -p $FINAL_OUT_DIR +mkdir -p "$FINAL_OUT_DIR" echo "Generating spec file $SPEC_DIR/openshift-odo.spec" envsubst $SPEC_DIR/openshift-odo.spec @@ -52,27 +54,26 @@ envsubst $SPEC_DIR/openshift-odo.spec echo "Generating tarball $SOURCES_DIR/$NAME.tar.gz" # Copy code for manipulation cp -arf ./* $SOURCES_DIR/$NAME -pushd $SOURCES_DIR -pushd $NAME +pushd $SOURCES_DIR || exit 1 +pushd $NAME || exit 1 # Remove bin if it exists, we dont need it in tarball rm -rf ./odo -popd +popd || exit 1 # Create tarball tar -czf $NAME.tar.gz $NAME # Removed copied content -rm -rf $NAME -popd +rm -rf "$NAME" +popd || exit 1 echo "Finalizing..." # Store version information in file for reference purposes -echo "ODO_VERSION=$ODO_VERSION" > $OUT_DIR/version -echo "ODO_RELEASE=$ODO_RELEASE" >> $OUT_DIR/version -echo "GIT_COMMIT=$GIT_COMMIT" >> $OUT_DIR/version -echo "ODO_RPM_VERSION=$ODO_RPM_VERSION" >> $OUT_DIR/version -echo "GOLANG_VERSION=$GOLANG_VERSION" >> $OUT_DIR/version -echo "GOLANG_VERSION_NODOT=$GOLANG_VERSION_NODOT" >> $OUT_DIR/version - +echo "ODO_VERSION=$ODO_VERSION +ODO_RELEASE=$ODO_RELEASE +GIT_COMMIT=$GIT_COMMIT +ODO_RPM_VERSION=$ODO_RPM_VERSION +GOLANG_VERSION=$GOLANG_VERSION +GOLANG_VERSION_NODOT=$GOLANG_VERSION_NODOT" > $OUT_DIR/version # After success copy stuff to actual location mv $OUT_DIR/* $FINAL_OUT_DIR