blob: 24d235bd7904472b63ca60208f4b38b57d43978a (
plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// Builds are driven by the tag name. The pipeline does nothing at all unless
// the checkout is a tag of the form
//
// fedora-<fedora_ver>-libcamera-<release_suffix>
//
// e.g. fedora-45-libcamera-sp12in1.
TAG_PATTERN = /^fedora-(\d+)-libcamera-([a-z0-9]+)$/
def fedoraVersionFromTag() {
def tag = env.TAG_NAME ?: ''
tag ==~ TAG_PATTERN ? tag.split('-')[1] : null
}
pipeline {
agent none
options {
timestamps()
}
environment {
B2_ENDPOINT = 'https://s3.eu-central-003.backblazeb2.com'
AWS_DEFAULT_REGION = 'eu-central-003'
RPM_BUCKET = 'dist-sayagit-fedora-rpm'
// awscli2 sends CRC32 checksums by default, which B2 rejects. Ask for
// them only where the S3 API requires them.
AWS_REQUEST_CHECKSUM_CALCULATION = 'when_required'
AWS_RESPONSE_CHECKSUM_VALIDATION = 'when_required'
}
stages {
stage('Build and publish libcamera RPMs (ARM64)') {
when {
beforeAgent true
allOf {
buildingTag()
expression { env.TAG_NAME ==~ TAG_PATTERN }
}
}
agent {
kubernetes {
defaultContainer 'rpmbuild'
yaml """
apiVersion: v1
kind: Pod
metadata:
namespace: jenkins
spec:
nodeSelector:
kubernetes.io/arch: arm64
containers:
- name: rpmbuild
image: fedora:${fedoraVersionFromTag()}
imagePullPolicy: Always
command: [ 'sleep' ]
args: [ 'infinity' ]
tty: true
resources:
requests:
cpu: "4"
memory: 4Gi
ephemeral-storage: 10Gi
limits:
memory: 8Gi
ephemeral-storage: 30Gi
"""
}
}
steps {
checkout scm
container('rpmbuild') {
withCredentials([usernamePassword(
credentialsId: 'backblaze-b2-dist-rpm',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh '''
set -eux
dnf --assumeyes install \\
git rpm-build rpmdevtools dnf5-plugins awscli2 curl \\
createrepo_c
git config --global --add safe.directory '*'
tag_fedora=${TAG_NAME#fedora-}
tag_fedora=${tag_fedora%%-libcamera-*}
tag_suffix=${TAG_NAME##*-libcamera-}
fedora_version=${tag_fedora}
export RELEASE_SUFFIX=${tag_suffix}
# A numbered tag has to agree with the container it
# selected, which is what stamps %{?dist} onto the
# release.
container_fedora=$(rpm --eval '%{fedora}')
if [ "${tag_fedora}" != "${container_fedora}" ]; then
echo "tag names Fedora ${tag_fedora}, container is ${container_fedora}" >&2
exit 1
fi
work="${WORKSPACE}/work"
out="${WORKSPACE}/rpms"
prefix="s3://${RPM_BUCKET}/fedora/${fedora_version}/aarch64"
# Resolving is a source-RPM download and a couple of
# spec edits, so ask what the build would produce
# before paying for the build itself.
rpm_files=$(./build.sh -n -w "${work}")
missing=false
for rpm_name in ${rpm_files}; do
if ! aws s3 ls --endpoint-url "${B2_ENDPOINT}" \\
"${prefix}/${rpm_name}"; then
missing=true
fi
done
if [ "${missing}" = false ]; then
echo "${TAG_NAME} is already published in full, nothing to do"
exit 0
fi
./build.sh -o "${out}" -w "${work}"
# Every subpackage goes up, not just the two the
# image needs: Fedora's libcamera-qcam and the rest
# carry a versioned Requires on this exact release,
# so a partial set would leave them unresolvable.
for rpm_name in ${rpm_files}; do
aws s3 cp --endpoint-url "${B2_ENDPOINT}" \\
"${out}/${rpm_name}" "${prefix}/${rpm_name}"
done
repo="${WORKSPACE}/repo"
mkdir -p "${repo}"
aws s3 sync --endpoint-url "${B2_ENDPOINT}" \\
--exclude '*' --include '*.rpm' \\
"${prefix}/" "${repo}/"
createrepo_c --update "${repo}"
aws s3 sync --endpoint-url "${B2_ENDPOINT}" \\
--exclude 'repomd.xml*' \\
"${repo}/repodata/" "${prefix}/repodata/"
aws s3 cp --endpoint-url "${B2_ENDPOINT}" \\
"${repo}/repodata/repomd.xml" \\
"${prefix}/repodata/repomd.xml"
'''
}
}
}
}
}
}
|