Rewild Your Web
web
browser
dweb
1#!/bin/bash
2
3# Simplified version of:
4# https://searchfox.org/firefox-main/rev/e62801966f0afe75facf57d066b6e472fbbc1adb/taskcluster/scripts/misc/build-sysroot.sh
5
6set -x
7set -e
8
9sysroot="servo-arm64-sysroot"
10
11packages="
12 linux-libc-dev
13 libasound2-dev
14 libstdc++-8-dev
15 libfontconfig1-dev
16 libfreetype6-dev
17 libgconf2-dev
18 libgcc-8-dev
19 libgtk-3-dev
20 libpango1.0-dev
21 libpulse-dev
22 libudev-dev
23 libx11-xcb-dev
24 libxt-dev
25 $*
26"
27
28echo "deb http://snapshot.debian.org/archive/debian/20230611T210420Z buster main" | mmdebstrap \
29 --architectures=arm64 \
30 --variant=extract \
31 --mode=fakeroot \
32 --include=$(echo $packages | tr ' ' ,) \
33 buster $sysroot \
34 --dpkgopt=path-exclude="*" \
35 --dpkgopt=path-include="/lib/*" \
36 --dpkgopt=path-include="/lib32/*" \
37 --dpkgopt=path-include="/usr/include/*" \
38 --dpkgopt=path-include="/usr/lib/*" \
39 --dpkgopt=path-include="/usr/lib32/*" \
40 --dpkgopt=path-exclude="/usr/lib/debug/*" \
41 --dpkgopt=path-exclude="/usr/lib/python*" \
42 --dpkgopt=path-include="/usr/share/pkgconfig/*" \
43
44# Remove more unwanted files
45rm -rf $sysroot/etc $sysroot/dev $sysroot/tmp $sysroot/var
46
47# Remove empty directories
48find $sysroot -depth -type d -empty -delete
49
50# Adjust symbolic links to link into the sysroot instead of absolute
51# paths that end up pointing at the host system.
52find $sysroot -type l | while read l; do
53 t=$(readlink $l)
54 case "$t" in
55 /*)
56 # We have a path in the form "$sysroot/a/b/c/d" and we want ../../..,
57 # which is how we get from d to the root of the sysroot. For that,
58 # we start from the directory containing d ("$sysroot/a/b/c"), remove
59 # all non-slash characters, leaving is with "///", replace each slash
60 # with "../", which gives us "../../../", and then we remove the last
61 # slash.
62 rel=$(dirname $l | sed 's,[^/],,g;s,/,../,g;s,/$,,')
63 ln -sf $rel$t $l
64 ;;
65 esac
66done
67