-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpbuilderrc
267 lines (227 loc) · 8.51 KB
/
pbuilderrc
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#! /usr/bin/env bash
#########################################################################
# #
# Based on an outline by Stein Magnus Jodal #
# https://jodal.no/2015/03/08/building-arm-debs-with-pbuilder/ #
# Author: Copyright (C) 2018-2024 Mark Grant #
# #
# This file is maintained in the project at:- #
# https://github.com/m-grant-prg/pbuilder-config #
# new versions are merely copied to consumer projects. #
# #
# Released under the GPLv3 only. #
# SPDX-License-Identifier: GPL-3.0-only #
# #
# Purpose: #
# This pbuilderrc file provides a mechanism for pbuilder to be able to #
# build for different distributions, releases and architectures. This #
# information is conveyed on the command line. E.g. #
# sudo DIST=rpios REL=stretch ARCH=armhf APT_CACHER=yes \ #
# pbuilder create --override-config \ #
# --debootstrapopts --variant=buildd #
# #
#########################################################################
#########################################################################
# #
# Version v1.1.17 #
# #
#########################################################################
#############################
# Exit immediately on error #
#############################
set -e
##################
# Init variables #
##################
declare -i num_rel # Numeric release value
OTHERMIRROR=""
#############
# Functions #
#############
# Basic Debian setup which can be used for rpios on arm64 etc which utilise
# Debian repos.
# No parameters
# No return value
debian_basic_setup()
{
MIRRORSITE="$https_prefix/deb.debian.org/debian/"
COMPONENTS="main contrib non-free"
DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}"
"--keyring=/usr/share/keyrings/debian-archive-keyring.gpg")
if [[ $OTHERMIRROR != "" ]]; then
OTHERMIRROR+="|"
fi
OTHERMIRROR+="deb $https_prefix/deb.debian.org/debian-security/ "
# Change of name of the security suite from bullseye onwards
if (( $num_rel >= 11 )); then
OTHERMIRROR+="$REL-security main contrib non-free"
else
OTHERMIRROR+="$REL/updates main contrib non-free"
fi
OTHERMIRROR+="|deb $https_prefix/deb.debian.org/debian $REL-updates "
OTHERMIRROR+="main contrib non-free"
OTHERMIRROR+="|deb http://download.opensuse.org/repositories/home:"
OTHERMIRROR+="/m-grant-prg/Debian_$obs_rel/ /"
APTKEYRINGS=("${APTKEYRINGS[@]}"
"/etc/apt/trusted.gpg.d/home_m-grant-prg.gpg")
}
#########################################################################
# OpenSUSE Build Service needs a numeric string release for Debian and #
# rpios stable releases and a numeric value is needed for changes #
# such as >= release. The following is valid for buster onwards with a #
# quirk for the OBS Debian Testing version. #
#########################################################################
if [[ $DIST == "debian" || $DIST == "rpios" ]];then
if [[ $REL == "testing" ]];then
num_rel=$(distro-info -r --testing)
obs_rel="Testing"
else
num_rel=$(distro-info -r --series=$REL)
obs_rel=$num_rel
fi
fi
#########################################################################
# Determine the start of the apt list line as it is different depending #
# on whether apt-cacher-ng is available. #
#########################################################################
if [[ $APT_CACHER == "" ]]; then
APT_CACHER=yes
fi
# APT_CACHER == yes implies that not only the cache is available but also the
# local repository. A no implies the opposite.
case $APT_CACHER in
yes)
http_prefix="http://hermes.mgent.home:3142"
https_prefix="http://hermes.mgent.home:3142/HTTPS//"
;;
no)
http_prefix="http:/"
https_prefix="https:/"
;;
*)
printf "Unknown APT_CACHER value: %s\n" $APT_CACHER
exit 1
;;
esac
########################################################
# OTHERMIRROR may be added to later so initialise here #
########################################################
if [[ $APT_CACHER == yes ]]; then
OTHERMIRROR="deb http://hermes.mgent.home/aptrepos/$DIST $REL "
OTHERMIRROR+="alpha beta stable staging"
APTKEYRINGS=("/etc/apt/trusted.gpg.d/hermes-keyring.gpg")
fi
##########################
# DIST specific settings #
##########################
case $DIST in
debian)
debian_basic_setup
;;
rpios)
# arm64 onwards uses the standard Debian repositories.
if [[ $ARCH == "armhf" || $ARCH == "armel" ]]; then
MIRRORSITE="$http_prefix/mirrordirector.raspbian.org/raspbian/"
COMPONENTS="main contrib non-free rpi"
DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}"
"--keyring=/usr/share/keyrings/raspbian-archive-keyring.gpg")
if [[ $OTHERMIRROR != "" ]]; then
OTHERMIRROR+="|"
fi
OTHERMIRROR+="deb http://download.opensuse.org/repositories"
OTHERMIRROR+="/home:/m-grant-prg/Raspbian_$obs_rel/ /"
APTKEYRINGS=("${APTKEYRINGS[@]}"
"/etc/apt/trusted.gpg.d/home_m-grant-prg.gpg")
else
debian_basic_setup
fi
OTHERMIRROR+="|deb $http_prefix/archive.raspberrypi.org/debian/ "
OTHERMIRROR+="$REL main"
APTKEYRINGS=("${APTKEYRINGS[@]}"
"/etc/apt/trusted.gpg.d/raspberrypi-keyring.gpg")
;;
ubuntu)
MIRRORSITE="$http_prefix/uk.archive.ubuntu.com/ubuntu/"
COMPONENTS="main restricted universe multiverse"
DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}"
"--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg")
if [[ $OTHERMIRROR != "" ]]; then
OTHERMIRROR+="|"
fi
OTHERMIRROR+="deb $http_prefix/uk.archive.ubuntu.com/ubuntu/ "
OTHERMIRROR+="$REL-security "
OTHERMIRROR+="main restricted universe multiverse"
OTHERMIRROR+="|deb $http_prefix/uk.archive.ubuntu.com/ubuntu/ "
OTHERMIRROR+="$REL-updates "
OTHERMIRROR+="main restricted universe multiverse"
OTHERMIRROR+="|deb $http_prefix/ppa.launchpad.net/m-grant-prg/utils/"
OTHERMIRROR+="$DIST $REL main"
APTKEYRINGS=("${APTKEYRINGS[@]}"
"/etc/apt/trusted.gpg.d/mgrant-utils-ppa-keyring.gpg")
;;
*)
printf "Unknown DIST: %s\n" $DIST
exit 1
;;
esac
#############################################
# Check we now have a value of REL and ARCH #
#############################################
if [ "$REL" == "" ]; then
printf "REL is not set\n"
exit 1
fi
if [ "$ARCH" == "" ]; then
printf "ARCH is not set\n"
exit 1
fi
#####################################################
# We always need these packages in the base tarball #
#####################################################
EXTRAPACKAGES+=" apt-utils curl dirmngr gnupg2 software-properties-common vim"
########################
# Add the Architecture #
########################
DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--arch=$ARCH")
#############################################################################
# Non-existent user id for non-root build and user name for use by fakeroot #
#############################################################################
BUILDUSERID=1234
BUILDUSERNAME=pbuilder
####################
# Self explanatory #
####################
BASETGZ="/var/cache/pbuilder/$DIST-$REL-$ARCH-base.tgz"
DISTRIBUTION="$REL"
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/
PBUILDERSATISFYDEPENDSCMD+=pbuilder-satisfydepends-apt
BUILDRESULT="/home/mgrantprg/SWDev/pbuilder/$DIST-$REL-$ARCH-result/"
APTCACHE="/var/cache/pbuilder/aptcache/$DIST-$REL-$ARCH/"
AUTOCLEANAPTCACHE=yes
##########################################################################
# Hook scripts are executed during chroot setup, before packaging begins #
##########################################################################
HOOKDIR="/home/mgrantprg/SWDev/pbuilder/hook.d/"
#####################
# Now log the setup #
#####################
psetuplog="$BUILDRESULT""pbuilderrc-setup.log"
printf "Distribution = %s\n" "$DIST" > $psetuplog
printf "Release = %s\n" "$REL" >> $psetuplog
printf "Numeric Release = %i\n" "$num_rel" >> $psetuplog
printf "Arch = %s\n" "$ARCH" >> $psetuplog
printf "APT_CACHER = %s\n" "$APT_CACHER" >> $psetuplog
printf "Mirrorsite = %s\n" "$MIRRORSITE" >> $psetuplog
printf "Components = %s\n" "$COMPONENTS" >> $psetuplog
printf "Othermirror = %s\n" "$OTHERMIRROR" >> $psetuplog
printf "Aptkeyrings = %s\n" "${APTKEYRINGS[@]}" >> $psetuplog
printf "Extrapackages = %s\n" "$EXTRAPACKAGES" >> $psetuplog
printf "Builduserid = %s\n" "$BUILDUSERID" >> $psetuplog
printf "Buildusername = %s\n" "$BUILDUSERNAME" >> $psetuplog
printf "Debootstrap = %s\n" "$DEBOOTSTRAP" >> $psetuplog
printf "Debootstrapopts = %s\n" "${DEBOOTSTRAPOPTS[@]}" >> $psetuplog
printf "Basetgz = %s\n" "$BASETGZ" >> $psetuplog
printf "Pbuildersatisfydependscmd = %s\n" "$PBUILDERSATISFYDEPENDSCMD" >> $psetuplog
printf "Buildresult = %s\n" "$BUILDRESULT" >> $psetuplog
printf "Aptcache = %s\n" "$APTCACHE" >> $psetuplog
printf "Hookdir = %s\n" "$HOOKDIR" >> $psetuplog