Skip to content
Permalink
Browse files

Setting up rpm spec for odo for rpm build (#2107)

* Setting up rpm spec for odo for rpm build

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

* Fixing typo

* Printing envs for debugging

* Removing -rpm suffix for rpm target

* Update rpm prepare script to store version information alongside rpmbuild artifacts

* Adding script to create tarball of the source. To be run after rpm-prepare is done

* Fixing dist git tarball generator

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

* Removing script from commit as its not yet perfect

* Updating redistributable to use name-redistributable

* Removing version replacement in version.go

* Some minor fixes to spec and script

* Record the need to update version in rpm-prepare script into release process

* Renaming atomic-openshift-odo to openshift-odo
  • Loading branch information...
mohammedzee1000 authored and openshift-merge-robot committed Sep 20, 2019
1 parent e2ca944 commit 567ad811de1b783651bc5067f626f6b9cf68aba0
Showing with 181 additions and 2 deletions.
  1. +5 −1 Makefile
  2. +2 −1 docs/development.adoc
  3. +78 −0 rpms/openshift-odo.spec
  4. +14 −0 scripts/rpm-local-build.sh
  5. +82 −0 scripts/rpm-prepare.sh
@@ -1,5 +1,9 @@
PROJECT := github.com/openshift/odo
GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
ifdef GITCOMMIT
GITCOMMIT := $(GITCOMMIT)
else
GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
endif
PKGS := $(shell go list ./... | grep -v $(PROJECT)/vendor | grep -v $(PROJECT)/tests )
COMMON_FLAGS := -X $(PROJECT)/pkg/odo/cli/version.GITCOMMIT=$(GITCOMMIT)
BUILD_FLAGS := -ldflags="-w $(COMMON_FLAGS)"
@@ -420,7 +420,8 @@ To release a new version:
** link:/pkg/odo/cli/version/version.go[`cmd/version.go`]
** link:/scripts/installer.sh[`scripts/installer.sh`]
** link:/Dockerfile.rhel[`Dockerfile.rhel`]
+
** link:/scripts/rpm-prepare.sh[`scripts/rpm-prepare.sh`]

There is a helper script link:../scripts/bump-version.sh[scripts/bump-version.sh] that changes version number in all the files listed above (except `odo.rb`).

* Updates the CLI reference documentation in the `docs/cli-reference.md` file:
@@ -0,0 +1,78 @@
#this is a template spec and actual spec will be generated
#debuginfo not supported with Go
%global debug_package %{nil}
%global package_name openshift-odo
%global product_name odo
%global golang_version 1.11
%global odo_version ${ODO_RPM_VERSION}
%global odo_release ${ODO_RELEASE}
%global git_commit ${GIT_COMMIT}
%global odo_cli_version v%{odo_version}
%global source_dir openshift-odo-%{odo_version}-%{odo_release}
%global source_tar %{source_dir}.tar.gz
%global gopath %{_builddir}/gocode

Name: %{package_name}
Version: %{odo_version}
Release: %{odo_release}%{?dist}
Summary: %{product_name} client odo CLI binary
License: ASL 2.0
URL: https://github.com/openshift/odo/tree/%{odo_cli_version}

ExclusiveArch: x86_64

Source0: %{source_tar}
BuildRequires: gcc
BuildRequires: golang >= %{golang_version}
Provides: %{package_name}
Obsoletes: %{package_name}

%description
OpenShift Do (odo) is a fast, iterative, and straightforward CLI tool for developers who write, build, and deploy applications on OpenShift.

%prep
%setup -q -n %{source_dir}

%build
export GITCOMMIT="%{git_commit}"
mkdir -p %{gopath}/src/github.com/openshift
ln -s "$(pwd)" %{gopath}/src/github.com/openshift/odo
export GOPATH=%{gopath}
cd %{gopath}/src/github.com/openshift/odo
make test
make cross
unlink %{gopath}/src/github.com/openshift/odo
rm -rf %{gopath}

%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 dist/bin/linux-amd64/odo %{buildroot}%{_bindir}/odo
mkdir -p %{buildroot}%{_datadir}
install -d %{buildroot}%{_datadir}/%{name}-redistributable/{linux,macos,windows}
install -p -m 755 dist/bin/linux-amd64/odo %{buildroot}%{_datadir}/%{name}-redistributable/linux/odo-linux-amd64
install -p -m 755 dist/bin/darwin-amd64/odo %{buildroot}%{_datadir}/%{name}-redistributable/macos/odo-darwin-amd64
install -p -m 755 dist/bin/windows-amd64/odo.exe %{buildroot}%{_datadir}/%{name}-redistributable/windows/odo-windows-amd64.exe

%files
%license LICENSE
%{_bindir}/odo

%package redistributable
Summary: %{product_name} client CLI binaries for Linux, macOS and Windows
BuildRequires: gcc
BuildRequires: golang >= %{golang_version}
Provides: %{package_name}-redistributable
Obsoletes: %{package_name}-redistributable

%description redistributable
%{product_name} client odo cross platform binaries for Linux, macOS and Windows.

%files redistributable
%license LICENSE
%dir %{_datadir}/%{name}-redistributable/linux/
%dir %{_datadir}/%{name}-redistributable/macos/
%dir %{_datadir}/%{name}-redistributable/windows/
%{_datadir}/%{name}-redistributable/linux/odo-linux-amd64
%{_datadir}/%{name}-redistributable/macos/odo-darwin-amd64
%{_datadir}/%{name}-redistributable/windows/odo-windows-amd64.exe

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e

if [[ ! -d dist/rpmbuild ]]; then
echo "Cannot build as artifacts are not generated. Run scrips/rpm-prepare.sh first"
exit 1
fi

echo "Copying content to local rpmbuild"
cp -avrf dist/rpmbuild/SOURCES/* $HOME/rpmbuild/SOURCES/
cp -avrf dist/rpmbuild/SPECS/* $HOME/rpmbuild/SPECS/

echo "Building locally"
rpmbuild -ba $HOME/rpmbuild/SPECS/openshift-odo.spec
@@ -0,0 +1,82 @@
#!/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.0.0-beta5}
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//-}

# 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"

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"
if [[ -d $DIST_DIR ]]; then
rm -rf $DIST_DIR
fi
if [[ -d $FINAL_OUT_DIR ]]; then
rm -rf $FINAL_OUT_DIR
fi

echo "Configuring output directory $OUT_DIR"
if [[ -d $OUT_DIR ]]; then
rm -rf $OUT_DIR
fi
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
if [[ -f ./odo ]]; then
rm -rf ./odo
fi
popd

# Create tarball
tar -czf $NAME.tar.gz $NAME
# Removed copied content
if [[ -d $NAME ]]; then
rm -rf $NAME
fi
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


# 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"

0 comments on commit 567ad81

Please sign in to comment.
You can’t perform that action at this time.