Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RPM Makefile
PACKAGE = nsbogan-atlassian-cli
VERSION = 3.9.0
RELEASE = 1
ARCH = noarch
NSBOGAN_USERNAME = automation
NSBOGAN_PASSWORD = automation
JAVA_VERSION = 1.6
PACKAGE_URL = https://marketplace.atlassian.com/download/plugins/org.swift.atlassian.cli/version/$(subst .,,${VERSION})
# Source directory
SRC_DIR=src
# Distribution directory where the source distributive is located
DIST_DIR=dist
# RPM file name
RPM_FILE=${PACKAGE}-${VERSION}-${RELEASE}.${ARCH}.rpm
clean:
@rm -rf $(DIST_DIR)
@rm -rf $(SRC_DIR)
download:
@echo "Downloading from $(PACKAGE_URL) ..."
@mkdir -p $(SRC_DIR)
@(if [ ! -f $(SRC_DIR)/${PACKAGE}.zip ] ; then curl -o $(SRC_DIR)/${PACKAGE}.zip --progress -fSL $(PACKAGE_URL) ; fi)
unzip: download
@(cd $(SRC_DIR) && unzip -qox ${PACKAGE}.zip)
@(cd $(SRC_DIR) && ln -fFs atlassian-cli-[0-9]* ${PACKAGE})
dist: unzip
@mkdir -p $(DIST_DIR)/
@(cd $(SRC_DIR)/${PACKAGE} && tar -czf ../../$(DIST_DIR)/${PACKAGE}-${VERSION}.tar.gz .)
rpm: dist
@echo "Making RPM..."
@mkdir -p ~/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
@cp -f $(DIST_DIR)/${PACKAGE}-${VERSION}.tar.gz ~/rpmbuild/SOURCES/
@cp -f rpm.spec ~/rpmbuild/SPECS/
@echo "%_topdir ${HOME}/rpmbuild" > ~/.rpmmacros
@echo "%_tmppath %_topdir/tmp" >> ~/.rpmmacros
@(LC_ALL=C rpmbuild -v --define "version ${VERSION}" --define "release ${RELEASE}" --define "arch ${ARCH}" --define "java_version ${JAVA_VERSION}" --define "username ${NSBOGAN_USERNAME}" --define "password ${NSBOGAN_PASSWORD}" -bb ~/rpmbuild/SPECS/rpm.spec)
# copy to dist
@cp -f ~/rpmbuild/RPMS/${ARCH}/$(RPM_FILE) $(DIST_DIR)/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment