Created
February 27, 2019 03:38
-
-
Save jabinb/99caed14026852c6915c4ba655e08909 to your computer and use it in GitHub Desktop.
Build source RPM from fedora rawhide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh -ex | |
| # Author: Jabin Bastian <jabin@simplywallst.com> | |
| # ./build-rpm.sh | |
| # | |
| # This script builds an RPM using mock via the mmornati/mock-rpmbuilder docker container. | |
| # The container requires privileged access in order to run, @see https://github.com/mmornati/docker-mock-rpmbuilder | |
| # Source RPMs are fetched from the Fedora Rawhide repo. | |
| # | |
| # Variables: | |
| # | |
| # $PACKAGE Sets the package to built (just the name segment like `zlib`). | |
| # $PACKAGE_VERSION Sets the version to find on the rawhide repo, requires a wildcard like `1.12.*`. | |
| # $ARCH Optionally Sets the Mock target architecture to be built (default `x86_64`) . | |
| # $TARGET Optionally sets the Mock target environment (default `epel-7`). | |
| # $OUTPUT_DIR Optionally sets the directory the built packages are copied to (default `./rpm-packages`). | |
| # | |
| # Usage: PACKAGE=zlib PACKAGE_VERSION=1.* ARCH=x86_64 TARGET=centos-7 OUTPUT_DIR=./rpms ./build-rpm.sh | |
| if [ -z "$PACKAGE" ] || [ -z "$PACKAGE_VERSION" ]; then | |
| echo "You must set the PACKAGE and PACKAGE_VERSION variables." | |
| echo "e.g. PACKAGE=\"zlib\" PACKAGE_VERSION=\"1.*\" $0" | |
| exit 1 | |
| fi | |
| PACKAGE_NAME="${PACKAGE}-${PACKAGE_VERSION}" | |
| ARCH=${ARCH:-x86_64} | |
| TARGET=${TARGET:-epel-7} | |
| MOCK_CONFIG="${TARGET}-${ARCH}" | |
| TMP_DIR="/tmp/rpmbuild-${PACKAGE}" | |
| OUTPUT_DIR=${OUTPUT_DIR:-./rpm-packages} | |
| SRC_PACKAGE_DIR="https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/source/tree/Packages/$(echo ${PACKAGE_NAME} | cut -c 1-1)/" | |
| mkdir -p ${TMP_DIR} | |
| docker run --rm --privileged=true \ | |
| -e MOCK_CONFIG=${MOCK_CONFIG} \ | |
| -e NO_CLEANUP=true \ | |
| -v ${TMP_DIR}:/output \ | |
| mmornati/mock-rpmbuilder \ | |
| /bin/bash -c " | |
| yum -y install wget && \ | |
| wget -nd --recursive --no-parent --accept '${PACKAGE_NAME}' ${SRC_PACKAGE_DIR} && \ | |
| SOURCE_RPM=\`ls ${PACKAGE_NAME}\` /build-rpm.sh" | |
| mkdir -p ${OUTPUT_DIR} | |
| # Copy the main RPM and any devel package | |
| mv ${TMP_DIR}/${MOCK_CONFIG}/${PACKAGE_NAME}${ARCH}.rpm ${OUTPUT_DIR} | |
| mv ${TMP_DIR}/${MOCK_CONFIG}/${PACKAGE}-devel-${PACKAGE_VERSION}${ARCH}.rpm ${OUTPUT_DIR} || true | |
| rm -rf ${TMP_DIR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment