2021-01-12 13:28:55 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# environment variables:
|
2021-04-01 22:23:56 +02:00
|
|
|
# - GIT_REF: the ref that should be build. Can be "main" or a git sha.
|
2023-01-24 08:46:08 +01:00
|
|
|
# - DEBUG: set to 1 to build "--with debug". Otherwise the default is a release
|
|
|
|
|
# build.
|
|
|
|
|
# - LTO: set to 1/0 to build "--with/--without lto", otherwise the default depends
|
|
|
|
|
# on the distribution.
|
2021-01-12 13:28:55 +01:00
|
|
|
# - 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
|
|
|
|
|
|
2023-01-24 08:46:08 +01:00
|
|
|
if [ "$LTO" = 0 ]; then
|
2023-01-24 10:29:35 +01:00
|
|
|
LTO='--without lto'
|
2023-01-24 08:46:08 +01:00
|
|
|
elif [ "$LTO" = 1 ]; then
|
2023-01-24 10:29:35 +01:00
|
|
|
LTO='--with lto'
|
2023-01-24 08:46:08 +01:00
|
|
|
else
|
|
|
|
|
LTO=
|
|
|
|
|
fi
|
|
|
|
|
|
2021-01-12 13:28:55 +01:00
|
|
|
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
|
2021-01-12 14:52:56 +01:00
|
|
|
git remote add --no-tags github https://github.com/NetworkManager/NetworkManager
|
2021-01-12 13:28:55 +01:00
|
|
|
|
|
|
|
|
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
|
2022-12-20 11:38:32 +01:00
|
|
|
NM_GIT_BUNDLE='https://download.copr.fedorainfracloud.org/results/networkmanager/NetworkManager-main/fedora-37-x86_64/05157676-nm-git-bundle/nm-git-bundle-20221220-102417.noarch.rpm'
|
2021-01-12 13:28:55 +01:00
|
|
|
fi
|
|
|
|
|
mkdir nm-git-bundle
|
|
|
|
|
pushd nm-git-bundle
|
2021-01-12 14:52:56 +01:00
|
|
|
time curl "$NM_GIT_BUNDLE" \
|
2021-01-12 13:28:55 +01:00
|
|
|
| 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 ||
|
2023-01-24 14:58:47 +01:00
|
|
|
git rev-parse --verify "refs/remotes/origin/$GIT_REF" 2>/dev/null ||
|
2021-01-12 13:28:55 +01:00
|
|
|
git rev-parse --verify "$GIT_REF^{commit}" 2>/dev/null)"
|
|
|
|
|
|
|
|
|
|
git checkout -b tmp "$GIT_SHA"
|
|
|
|
|
|
2023-01-24 08:46:08 +01:00
|
|
|
./contrib/fedora/rpm/build_clean.sh -g -S -w test $DEBUG $LTO -s copr
|
2021-01-12 13:28:55 +01:00
|
|
|
popd
|
|
|
|
|
|
2021-01-12 14:52:56 +01:00
|
|
|
mv ./NetworkManager/contrib/fedora/rpm/latest/{SOURCES,SPECS}/* .
|
|
|
|
|
rm -rf ./NetworkManager
|