File: nm-copr-build.sh

package info (click to toggle)
network-manager 1.54.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 71,432 kB
  • sloc: ansic: 483,661; python: 11,632; xml: 8,546; sh: 5,552; perl: 596; cpp: 178; javascript: 130; ruby: 107; makefile: 64; lisp: 22
file content (101 lines) | stat: -rwxr-xr-x 3,613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

# This is the build script used by our copr repository at
#   https://copr.fedorainfracloud.org/coprs/networkmanager
#
# On a new upstream release, add new copr jobs named "NetworkManager-X.Y" and
# "NetworkManager-X.Y-debug".
#
#   - best, look at the latest copr project and replicate the settings.
#   - add a custom build with the following script:
#
#        #!/bin/bash
#        export GIT_REF=nm-$X-$Y
#        export DEBUG=0/1
#        export LTO=
#        curl https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/raw/main/contrib/scripts/nm-copr-build.sh | bash
#
#   - for certain CentOS/EPEL you need to add https://copr.fedorainfracloud.org/coprs/nmstate/nm-build-deps/
#     as build chroot. See under "Settings/Project Details" for the latest copr project.
#   - go to "Settings/Integrations" and find the notification URL for the project. Then
#     go to https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/hooks and add
#     a push event for the "nm-$X-$Y" branch.
#
# environment variables for this script:
# - GIT_REF: the ref that should be build. Can be "main" or a git sha.
# - 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.
# - 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.
#     See "contrib/scripts/nm-copr-build-nm-git-bundle.sh" script and
#     https://copr.fedorainfracloud.org/coprs/networkmanager/NetworkManager-main/package/nm-git-bundle/

set -ex

if [[ "$DEBUG" == 1 ]]; then
    DEBUG="--with debug"
else
    DEBUG="--without debug"
fi

if [ "$LTO" = 0 ]; then
    LTO='--without lto'
elif [ "$LTO" = 1 ]; then
    LTO='--with lto'
else
    LTO=
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 --no-tags 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-main/fedora-41-x86_64/08367599-nm-git-bundle/nm-git-bundle-20241209-150540.noarch.rpm'
    fi
    mkdir nm-git-bundle
    pushd nm-git-bundle
    time 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 "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 $LTO -s copr
popd

mv ./NetworkManager/contrib/fedora/rpm/latest/{SOURCES,SPECS}/* .
rm -rf ./NetworkManager