build-sysroot.sh (3878B)
1 #!/bin/sh 2 3 set -x 4 set -e 5 6 arch=$1 7 shift 8 9 sysroot=$(basename $TOOLCHAIN_ARTIFACT) 10 sysroot=${sysroot%%.*} 11 12 # To repackage Firefox as a .deb package 13 # we bootstrap jessie systems on a bullseye image. 14 # To keep the build and repackage environments 15 # consistent the build baseline used here (jessie) should be 16 # synchronized with the packaging baseline used in 17 # taskcluster/docker/debian-repackage/Dockerfile 18 # and python/mozbuild/mozbuild/repackaging/deb.py 19 case "$arch" in 20 i386|amd64) 21 dist=jessie 22 ;; 23 arm64) 24 dist=buster 25 ;; 26 *) 27 echo "$arch is not supported." >&2 28 exit 1 29 ;; 30 esac 31 32 if [ -n "$DIST" ]; then 33 dist="$DIST" 34 fi 35 36 case "$dist" in 37 jessie) 38 gcc_version=4.9 39 ;; 40 stretch) 41 gcc_version=6 42 ;; 43 buster) 44 gcc_version=8 45 ;; 46 bullseye) 47 gcc_version=10 48 ;; 49 bookworm) 50 gcc_version=12 51 ;; 52 esac 53 54 if [ -n "$GCC_VERSION" ]; then 55 gcc_version="$GCC_VERSION" 56 fi 57 58 case "$dist" in 59 jessie|stretch|buster) 60 repo_url=https://archive.debian.org/debian 61 ;; 62 *) 63 : ${SNAPSHOT:=20230611T210420Z} 64 repo_url=http://snapshot.debian.org/archive/debian/$SNAPSHOT 65 ;; 66 esac 67 68 case "$dist" in 69 jessie) 70 # The Debian Jessie GPG key expired. 71 GPG_KEY_EXPIRED=1 72 ;; 73 esac 74 75 if [ -n "$GPG_KEY_EXPIRED" ]; then 76 extra_apt_opt='Apt::Key::gpgvcommand "/usr/local/sbin/gpgvnoexpkeysig"' 77 fi 78 79 packages=" 80 linux-libc-dev 81 libasound2-dev 82 libstdc++-${gcc_version}-dev 83 libfontconfig1-dev 84 libfreetype6-dev 85 libgconf2-dev 86 libgcc-${gcc_version}-dev 87 libgtk-3-dev 88 libpango1.0-dev 89 libpulse-dev 90 libx11-xcb-dev 91 libxt-dev 92 valgrind 93 $* 94 " 95 96 # --keyring=... works around https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981710 97 # For a sysroot, we don't need everything. Essentially only libraries and headers, as 98 # well as pkgconfig files. We exclude debug info files and valgrind files that are not 99 # useful to build. 100 queue_base="$TASKCLUSTER_ROOT_URL/api/queue/v1" 101 ( 102 echo "deb $repo_url $dist main" 103 for task in $PACKAGES_TASKS; do 104 echo "deb [trusted=yes] $queue_base/task/$task/artifacts/public/build/ apt/" 105 done 106 ) | mmdebstrap \ 107 --architectures=$arch \ 108 --variant=extract \ 109 --include=$(echo $packages | tr ' ' ,) \ 110 $dist \ 111 $sysroot \ 112 - \ 113 --aptopt=/etc/apt/apt.conf.d/99taskcluster \ 114 ${extra_apt_opt:+--aptopt="$extra_apt_opt"} \ 115 --dpkgopt=path-exclude="*" \ 116 --dpkgopt=path-include="/lib/*" \ 117 --dpkgopt=path-exclude="/lib/systemd/*" \ 118 --dpkgopt=path-include="/lib32/*" \ 119 --dpkgopt=path-include="/lib64/*" \ 120 --dpkgopt=path-include="/usr/include/*" \ 121 --dpkgopt=path-include="/usr/lib/*" \ 122 --dpkgopt=path-include="/usr/lib32/*" \ 123 --dpkgopt=path-include="/usr/lib64/*" \ 124 --dpkgopt=path-exclude="/usr/lib/debug/*" \ 125 --dpkgopt=path-exclude="/usr/lib/python*" \ 126 --dpkgopt=path-exclude="/usr/lib/valgrind/*" \ 127 --dpkgopt=path-exclude="/usr/lib/*/perl" \ 128 --dpkgopt=path-include="/usr/share/pkgconfig/*" \ 129 --keyring=/usr/share/keyrings/debian-archive-removed-keys.gpg \ 130 -v 131 132 # Remove files that are created despite the path-exclude=*. 133 rm -rf $sysroot/etc $sysroot/dev $sysroot/tmp $sysroot/var 134 135 # Remove empty directories 136 find $sysroot -depth -type d -empty -delete 137 138 # Adjust symbolic links to link into the sysroot instead of absolute 139 # paths that end up pointing at the host system. 140 find $sysroot -type l | while read l; do 141 t=$(readlink $l) 142 case "$t" in 143 /*) 144 # We have a path in the form "$sysroot/a/b/c/d" and we want ../../.., 145 # which is how we get from d to the root of the sysroot. For that, 146 # we start from the directory containing d ("$sysroot/a/b/c"), remove 147 # all non-slash characters, leaving is with "///", replace each slash 148 # with "../", which gives us "../../../", and then we remove the last 149 # slash. 150 rel=$(dirname $l | sed 's,[^/],,g;s,/,../,g;s,/$,,') 151 ln -sf $rel$t $l 152 ;; 153 esac 154 done 155 156 tar caf $sysroot.tar.zst $sysroot 157 158 mkdir -p "$UPLOAD_DIR" 159 mv "$sysroot.tar.zst" "$UPLOAD_DIR"