ci: Enable IRC flake reporting on freedreno baremetal boards.
[mesa.git] / .gitlab-ci / create-rootfs.sh
1 #!/bin/bash
2
3 set -ex
4
5 apt-get -y install --no-install-recommends \
6 ca-certificates \
7 initramfs-tools \
8 libpng16-16 \
9 strace \
10 libsensors5 \
11 libexpat1 \
12 libdrm2 \
13 libdrm-nouveau2 \
14 firmware-qcom-media \
15 netcat-openbsd \
16 wget \
17 xz-utils
18 passwd root -d
19 chsh -s /bin/sh
20
21 cat > /init <<EOF
22 #!/bin/sh
23 export PS1=lava-shell:
24 exec sh
25 EOF
26 chmod +x /init
27
28 mkdir -p /lib/firmware/rtl_nic
29 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rtl_nic/rtl8153a-3.fw -O /lib/firmware/rtl_nic/rtl8153a-3.fw
30
31 #######################################################################
32 # Strip the image to a small minimal system without removing the debian
33 # toolchain.
34
35 # xz compress firmware so it doesn't waste RAM at runtime. Except db820c's
36 # GPU firmware, due to using a precompiled kernel without compression support.
37 find /lib/firmware -type f -print0 | \
38 grep -vz a530 | \
39 xargs -0r -P4 -n4 xz -T1 -C crc32
40 ln -s /lib/firmware/qcom/a530* /lib/firmware/
41
42 # Copy timezone file and remove tzdata package
43 rm -rf /etc/localtime
44 cp /usr/share/zoneinfo/Etc/UTC /etc/localtime
45
46 UNNEEDED_PACKAGES="libfdisk1
47 tzdata
48 diffutils"
49
50 export DEBIAN_FRONTEND=noninteractive
51
52 # Removing unused packages
53 for PACKAGE in ${UNNEEDED_PACKAGES}
54 do
55 echo ${PACKAGE}
56 if ! apt-get remove --purge --yes "${PACKAGE}"
57 then
58 echo "WARNING: ${PACKAGE} isn't installed"
59 fi
60 done
61
62 apt-get autoremove --yes || true
63
64 # Dropping logs
65 rm -rf /var/log/*
66
67 # Dropping documentation, localization, i18n files, etc
68 rm -rf /usr/share/doc/*
69 rm -rf /usr/share/locale/*
70 rm -rf /usr/share/man
71 rm -rf /usr/share/i18n/*
72 rm -rf /usr/share/info/*
73 rm -rf /usr/share/lintian/*
74 rm -rf /usr/share/common-licenses/*
75 rm -rf /usr/share/mime/*
76
77 # Dropping reportbug scripts
78 rm -rf /usr/share/bug
79
80 # Drop udev hwdb not required on a stripped system
81 rm -rf /lib/udev/hwdb.bin /lib/udev/hwdb.d/*
82
83 # Drop all gconv conversions && binaries
84 rm -rf usr/bin/iconv
85 rm -rf usr/sbin/iconvconfig
86 rm -rf usr/lib/*/gconv/
87
88 # Remove libusb database
89 rm -rf usr/sbin/update-usbids
90 rm -rf var/lib/usbutils/usb.ids
91 rm -rf usr/share/misc/usb.ids
92
93 #######################################################################
94 # Crush into a minimal production image to be deployed via some type of image
95 # updating system.
96 # IMPORTANT: The Debian system is not longer functional at this point,
97 # for example, apt and dpkg will stop working
98
99 UNNEEDED_PACKAGES="apt libapt-pkg5.0 "\
100 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
101 "perl-base "\
102 "debconf libdebconfclient0 "\
103 "e2fsprogs e2fslibs libfdisk1 "\
104 "insserv "\
105 "udev "\
106 "init-system-helpers "\
107 "bash "\
108 "cpio "\
109 "xz-utils "\
110 "passwd "\
111 "libsemanage1 libsemanage-common "\
112 "libsepol1 "\
113 "gpgv "\
114 "hostname "\
115 "adduser "\
116 "debian-archive-keyring "\
117
118 # Removing unneeded packages
119 for PACKAGE in ${UNNEEDED_PACKAGES}
120 do
121 echo "Forcing removal of ${PACKAGE}"
122 if ! dpkg --purge --force-remove-essential --force-depends "${PACKAGE}"
123 then
124 echo "WARNING: ${PACKAGE} isn't installed"
125 fi
126 done
127
128 # Show what's left package-wise before dropping dpkg itself
129 COLUMNS=300 dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
130
131 # Drop dpkg
132 dpkg --purge --force-remove-essential --force-depends dpkg
133
134 # No apt or dpkg, no need for its configuration archives
135 rm -rf etc/apt
136 rm -rf etc/dpkg
137
138 # Drop directories not part of ostree
139 # Note that /var needs to exist as ostree bind mounts the deployment /var over
140 # it
141 rm -rf var/* opt srv share
142
143 # ca-certificates are in /etc drop the source
144 rm -rf usr/share/ca-certificates
145
146 # No bash, no need for completions
147 rm -rf usr/share/bash-completion
148
149 # No zsh, no need for comletions
150 rm -rf usr/share/zsh/vendor-completions
151
152 # drop gcc-6 python helpers
153 rm -rf usr/share/gcc-6
154
155 # Drop sysvinit leftovers
156 rm -rf etc/init.d
157 rm -rf etc/rc[0-6S].d
158
159 # Drop upstart helpers
160 rm -rf etc/init
161
162 # Various xtables helpers
163 rm -rf usr/lib/xtables
164
165 # Drop all locales
166 # TODO: only remaining locale is actually "C". Should we really remove it?
167 rm -rf usr/lib/locale/*
168
169 # partition helpers
170 rm usr/sbin/*fdisk
171
172 # local compiler
173 rm usr/bin/localedef
174
175 # Systemd dns resolver
176 find usr etc -name '*systemd-resolve*' -prune -exec rm -r {} \;
177
178 # Systemd network configuration
179 find usr etc -name '*networkd*' -prune -exec rm -r {} \;
180
181 # systemd ntp client
182 find usr etc -name '*timesyncd*' -prune -exec rm -r {} \;
183
184 # systemd hw database manager
185 find usr etc -name '*systemd-hwdb*' -prune -exec rm -r {} \;
186
187 # No need for fuse
188 find usr etc -name '*fuse*' -prune -exec rm -r {} \;
189
190 # lsb init function leftovers
191 rm -rf usr/lib/lsb
192
193 # Only needed when adding libraries
194 rm usr/sbin/ldconfig*
195
196 # Games, unused
197 rmdir usr/games
198
199 # Remove pam module to authenticate against a DB
200 # plus libdb-5.3.so that is only used by this pam module
201 rm usr/lib/*/security/pam_userdb.so
202 rm usr/lib/*/libdb-5.3.so
203
204 # remove NSS support for nis, nisplus and hesiod
205 rm usr/lib/*/libnss_hesiod*
206 rm usr/lib/*/libnss_nis*