Files
odo/scripts/rpm-prepare.sh
Mohammed Ahmed 4305079156 Cleaning up odo rpm spec and scripts (#3904)
* Fixing rpm spec Provides and Obsoletes to be more specific

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing local build script to use dist/rpmbuild and topdir for build

 - This prevents polluting users main rpmbuild

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Setting goflags during `make test` and turning off missing buildid

 - without goflags, unit tests take a while as they dont use vendor
 - providing -mod=vendor does not seem to help
 - missing gnu build ids in go binaries can cause warnings

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing GOFLAGS from spec and adding build_flags to test target

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Unsetting any goflags for make test in openshift ci

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing the set +x from local build script

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding rpm tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing last rm -rf

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Reverting to explicitly setting GOFLAGS for make test

 - It appears that while `-mod=vendor` flag is available for `go test`
   it is sometimes not respected
 - It is therefore, better to just set GOFLAGS only for make test
 - More investigation is needed to find better solution, but we should
   not break stuff relation to testing and release, where we should not
   be pulling from outside world

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Cleaning up rpm-prepare

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing unnessasary newline

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding version file to spec for any future automation to have easier time

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
2020-09-10 11:55:19 -04:00

82 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
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
export ODO_VERSION=${ODO_VERSION:=1.2.6}
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//-}
# 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.13}
export GOLANG_VERSION_NODOT=${GOLANG_VERSION_NODOT:-113}
# Print env for verifcation
echo "Printing envs for verification"
echo "ODO_VERSION=$ODO_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"
OUT_DIR=".rpmbuild"
DIST_DIR="$(pwd)/dist"
SPEC_DIR="$OUT_DIR/SPECS"
SOURCES_DIR="$OUT_DIR/SOURCES"
FINAL_OUT_DIR="$DIST_DIR/rpmbuild"
NAME="openshift-odo-$ODO_RPM_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
echo "Configuring output directory $OUT_DIR"
rm -rf $OUT_DIR
mkdir -p $SPEC_DIR
mkdir -p $SOURCES_DIR/$NAME
mkdir -p $FINAL_OUT_DIR
echo "Generating spec file $SPEC_DIR/openshift-odo.spec"
envsubst <rpms/openshift-odo.spec > $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
# Remove bin if it exists, we dont need it in tarball
rm -rf ./odo
popd
# Create tarball
tar -czf $NAME.tar.gz $NAME
# Removed copied content
rm -rf $NAME
popd
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
# After success copy stuff to actual location
mv $OUT_DIR/* $FINAL_OUT_DIR
# Remove out dir
rm -rf $OUT_DIR
echo "Generated content in $FINAL_OUT_DIR"