diff options
author | Thomas Haller <thaller@redhat.com> | 2021-01-12 13:28:55 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-01-12 14:28:23 +0100 |
commit | 1277e4c8827edb6995e5b59e410a43364afdb887 (patch) | |
tree | df1448847102278a19d14c1d4ad7f2a30f5bb4db | |
parent | 55e4b0ea9ca6cffb39cf153e69b10071b492d114 (diff) | |
download | NetworkManager-1277e4c8827edb6995e5b59e410a43364afdb887.tar.gz |
contrib: add "contrib/scripts/nm-copr-build.sh" script
This will be the script used by our copr repositories ([1]) for building
the SRPM of NetworkManger from git.
[1] https://copr.fedorainfracloud.org/coprs/networkmanager/
-rwxr-xr-x | contrib/scripts/nm-copr-build.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/contrib/scripts/nm-copr-build.sh b/contrib/scripts/nm-copr-build.sh new file mode 100755 index 0000000000..78379a94f4 --- /dev/null +++ b/contrib/scripts/nm-copr-build.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# environment variables: +# - GIT_REF: the ref that should be build. Can be "master" or a git sha. +# - DEBUG: set to 1 to build "--with debug". +# - NM_GIT_BUNDLE: set to a HTTP url where to fetch the nm-git-bundle-*.noarch.rpm +# from. Set to empty to skip it. By default, it fetches the bundle from copr. + +set -ex + +if [[ "$DEBUG" == 1 ]]; then + DEBUG="--with debug" +else + DEBUG="--without debug" +fi + +if [[ -z "$GIT_REF" ]]; then + echo "\$GIT_REF is not set!" + exit 1 +fi + +mkdir NetworkManager +pushd NetworkManager +git init . + +git remote add origin https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git +git remote add github https://github.com/NetworkManager/NetworkManager + +get_nm_git_bundle() { + # try to fetch the refs from nm-git-bundle. + # + # This script runs in copr infrastructure to create the SRPM. + # The idea is that this URL is close and downloading it is cheaper + # than fetching everything from upstream git. + if [ -z "$NM_GIT_BUNDLE" ]; then + if [ -n "${NM_GIT_BUNDLE+x}" ]; then + return 0 + fi + NM_GIT_BUNDLE='https://download.copr.fedorainfracloud.org/results/networkmanager/NetworkManager-master/fedora-33-x86_64/01877051-nm-git-bundle/nm-git-bundle-20210112-123248.noarch.rpm' + fi + mkdir nm-git-bundle + pushd nm-git-bundle + curl "$NM_GIT_BUNDLE" \ + | rpm2cpio - \ + | cpio -idmv + popd + git remote add nm-git-bundle "$PWD/nm-git-bundle/usr/share/NetworkManager/nm-git-bundle.git" + git fetch nm-git-bundle +} + +get_nm_git_bundle +git fetch github +git fetch origin +git remote remove nm-git-bundle || true + +GIT_SHA="$(git show-ref --verify --hash "$GIT_REF" 2>/dev/null || + git show-ref --verify --hash "refs/remotes/origin/$GIT_REF" 2>/dev/null || + git rev-parse --verify "$GIT_REF^{commit}" 2>/dev/null)" + +git checkout -b tmp "$GIT_SHA" + +./contrib/fedora/rpm/build_clean.sh -g -S -w test $DEBUG -s copr +popd + +mv ./NetworkManager/contrib/fedora/rpm/latest/SRPMS/* . |