-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathDebian-13-XFCE.Dockerfile
More file actions
412 lines (372 loc) · 12.3 KB
/
Copy pathDebian-13-XFCE.Dockerfile
File metadata and controls
412 lines (372 loc) · 12.3 KB
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# Dockerfile (GUI)
# Stage 1: Build and customize the rootfs for development (GUI - Debian 13)
ARG TARGETPLATFORM
FROM debian:trixie AS customizer
ENV DEBIAN_FRONTEND=noninteractive
# Update base system and enable non-free/contrib for hfsprogs
RUN (sed -i 's/main/main contrib non-free/g' /etc/apt/sources.list 2>/dev/null || sed -i 's/Components: main/Components: main contrib non-free/g' /etc/apt/sources.list.d/debian.sources) && \
apt-get update && apt-get upgrade -y
# Copy custom scripts first
COPY scripts/download-firmware /usr/local/bin/
# Copy our bashrc script to the rootfs
COPY scripts/bashrc.sh /etc/profile.d/ds-aliases.sh
# Make scripts executable
RUN chmod +x /usr/local/bin/download-firmware /etc/profile.d/ds-aliases.sh
# Main installation layer for everything (Minimal + CLI + GUI)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# Core utilities
bash \
dialog \
coreutils \
file \
findutils \
grep \
sed \
gawk \
curl \
wget \
ca-certificates \
locales \
bash-completion \
udev \
dbus \
systemd-sysv \
systemd-resolved \
# Compression tools
zip \
unzip \
p7zip-full \
bzip2 \
xz-utils \
tar \
gzip \
# System tools
htop \
btop \
vim \
nano \
git \
sudo \
openssh-server \
net-tools \
iptables \
iputils-ping \
iproute2 \
dnsutils \
usbutils \
pciutils \
lsof \
psmisc \
procps \
fastfetch \
kmod \
# Wireless networking tools
iw \
# Logging & Rotation
logrotate \
# Development tools
build-essential \
gcc \
g++ \
gdb \
make \
cmake \
autoconf \
automake \
libtool \
pkg-config \
# Additional dev tools
clang \
llvm \
valgrind \
strace \
ltrace \
# Python Development
python3 \
python3-pip \
python3-dev \
python3-venv \
python-is-python3 \
# File system tools
gparted \
dosfstools \
exfatprogs \
btrfs-progs \
ntfs-3g \
xfsprogs \
jfsutils \
hfsprogs \
reiserfsprogs \
cryptsetup \
nilfs-tools \
udftools \
f2fs-tools \
# Audio
pulseaudio \
pulseaudio-utils \
pavucontrol \
# XFCE Desktop Environment and essential tools
xfce4 \
desktop-base \
xfce4-terminal \
xfce4-session \
xfce4-goodies \
xfce4-taskmanager \
mousepad \
galculator \
nemo-fileroller \
ristretto \
xfce4-screenshooter \
catfish \
xcursor-themes \
xfce4-clipman-plugin \
xinit \
xorg \
dbus-x11 \
at-spi2-core \
tumbler \
# Icon themes
adwaita-icon-theme-full \
hicolor-icon-theme \
gnome-icon-theme \
tango-icon-theme \
# GTK theme engines and popular themes
gtk2-engines-murrine \
gtk2-engines-pixbuf \
arc-theme \
numix-gtk-theme \
papirus-icon-theme \
greybird-gtk-theme \
# Essential fonts for GUI rendering
fonts-dejavu-core \
fonts-liberation \
fonts-liberation2 \
fonts-noto-core \
fonts-noto-ui-core \
# File manager and GUI utilities
thunar \
thunar-volman \
thunar-archive-plugin \
thunar-media-tags-plugin \
gvfs \
gvfs-backends \
gvfs-fuse \
x11-xserver-utils \
x11-utils \
xclip \
xsel \
xfwm4 \
xfconf \
zenity \
notification-daemon \
# Browser (Firefox ESR)
firefox-esr \
# User directory management
xdg-user-dirs \
# PolicyKit for permissions
polkitd \
mate-polkit \
# Docker
docker.io \
docker-compose \
docker-cli \
&& apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Configure iptables-legacy (Required for Android compatibility)
RUN update-alternatives --set iptables /usr/sbin/iptables-legacy && \
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
# Configure locales, environment, SSH, and user setup
RUN sed -i '/en_US.UTF-8/s/^# //' /etc/locale.gen && \
locale-gen && \
update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 && \
# Configure SSH (Disable Root Login)
mkdir -p /var/run/sshd && \
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
# Initialize default user directories for GUI apps
xdg-user-dirs-update && \
# Remove default user if it exists
deluser --remove-home debian || true
# Fix DHCP in the container
RUN mkdir -p /etc/systemd/network && \
cat <<'EOF' > /etc/systemd/network/10-eth-dhcp.network
[Match]
Name=eth*
[Network]
DHCP=yes
IPv6AcceptRA=yes
[DHCPv4]
UseDNS=yes
UseDomains=yes
RouteMetric=100
EOF
# Apply Android compatibility fixes (Systemd and Udev)
RUN <<EOF_RUN
# --- 1. General Fixes ---
# Android network group setup (required for socket access on Android kernels)
grep -q '^aid_inet:' /etc/group || echo 'aid_inet:x:3003:' >> /etc/group
grep -q '^aid_net_raw:' /etc/group || echo 'aid_net_raw:x:3004:' >> /etc/group
grep -q '^aid_net_admin:' /etc/group || echo 'aid_net_admin:x:3005:' >> /etc/group
# Root permissions for Android hardware access
usermod -a -G aid_inet,aid_net_raw,input,video,tty root || true
# _apt needs aid_inet as primary group so apt works on Android
grep -q '^_apt:' /etc/passwd && usermod -g aid_inet _apt || true
# Future users created with adduser automatically get network access
if [ -f /etc/adduser.conf ]; then
sed -i '/^EXTRA_GROUPS=/d; /^ADD_EXTRA_GROUPS=/d' /etc/adduser.conf
echo 'ADD_EXTRA_GROUPS=1' >> /etc/adduser.conf
echo 'EXTRA_GROUPS="aid_inet aid_net_raw input video tty"' >> /etc/adduser.conf
fi
# --- 2. Systemd-Specific Fixes ---
# Mask problematic services for Android kernels
ln -sf /dev/null /etc/systemd/system/systemd-networkd-wait-online.service
ln -sf /dev/null /etc/systemd/system/systemd-journald-audit.socket
# Journald configuration (skip Audit, KMsg, etc)
cat >> /etc/systemd/journald.conf << 'EOT'
[Journal]
ReadKMsg=no
Audit=no
Storage=volatile
EOT
mkdir -p /etc/systemd/journald.conf.d
cat > /etc/systemd/journald.conf.d/ds-logging.conf << 'EOT'
[Journal]
SystemMaxUse=200M
RuntimeMaxUse=200M
MaxRetentionSec=7day
MaxLevelStore=info
EOT
# Enable essential services
mkdir -p /etc/systemd/system/multi-user.target.wants
GUEST_SYSTEMD_PATH="/lib/systemd/system"
for service in dbus.service systemd-udevd.service systemd-resolved.service systemd-networkd.service NetworkManager.service; do
if [ -f "$GUEST_SYSTEMD_PATH/$service" ]; then
ln -sf "$GUEST_SYSTEMD_PATH/$service" "/etc/systemd/system/multi-user.target.wants/$service"
fi
done
# Disable power button handling in systemd-logind
mkdir -p /etc/systemd/logind.conf.d
cat > /etc/systemd/logind.conf.d/99-power-key.conf << 'EOF'
[Login]
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandlePowerKeyLongPress=ignore
HandlePowerKeyLongPressHibernate=ignore
EOF
# Apply udev overrides
# 1. Trigger override (Prevents coldplugging Android hardware)
mkdir -p /etc/systemd/system/systemd-udev-trigger.service.d
cat > /etc/systemd/system/systemd-udev-trigger.service.d/override.conf << 'EOF'
[Service]
ExecStart=
ExecStart=-/usr/bin/udevadm trigger --subsystem-match=usb --subsystem-match=block --subsystem-match=input --subsystem-match=tty --subsystem-match=net
EOF
# 2. Read-only path overrides to prevent failures
for unit in systemd-udevd.service systemd-udev-trigger.service systemd-udev-settle.service systemd-udevd-kernel.socket systemd-udevd-control.socket; do
mkdir -p "/etc/systemd/system/${unit}.d"
printf "[Unit]\nConditionPathIsReadWrite=\n" > "/etc/systemd/system/${unit}.d/99-readonly-fix.conf"
done
# Limit specific network services to only start in NAT mode
# Prevents cellular network breakage when running in host network mode
for unit in NetworkManager.service dhcpcd.service systemd-resolved.service systemd-networkd.service; do
if [ -f "$GUEST_SYSTEMD_PATH/$unit" ] || [ -f "/etc/systemd/system/multi-user.target.wants/$unit" ]; then
mkdir -p "/etc/systemd/system/${unit}.d"
cat > "/etc/systemd/system/${unit}.d/99-netmode-limit.conf" << 'EOF'
[Service]
ExecCondition=
ExecCondition=/bin/sh -c "grep -qE 'net_mode=(nat|gateway)' /run/droidspaces/container.config"
EOF
fi
done
# Configure logrotate for Android
if [ -f /etc/logrotate.conf ]; then
sed -i 's/^#maxsize.*/maxsize 50M/' /etc/logrotate.conf
if ! grep -q "maxsize 50M" /etc/logrotate.conf; then
echo "maxsize 50M" >> /etc/logrotate.conf
fi
fi
# Mark fixes as completed
echo "Post-extraction fixes applied on $(date)" > /etc/droidspaces
EOF_RUN
# Install and enable XFCE autostart service
COPY scripts/xfce-start /usr/local/bin/xfce-start
RUN chmod +x /usr/local/bin/xfce-start
RUN cat > /etc/systemd/system/xfce-autostart.service << 'EOF'
[Unit]
Description=XFCE Autostart
After=graphical.target
[Service]
Type=simple
User=root
ExecCondition=/bin/sh -c "grep -q 'enable_termux_x11=1' /run/droidspaces/container.config"
ExecCondition=/bin/sh -c "test -S /tmp/.X11-unix/X5"
ExecStart=/usr/local/bin/xfce-start
Restart=on-failure
[Install]
WantedBy=graphical.target
EOF
RUN chmod 644 /etc/systemd/system/xfce-autostart.service && \
mkdir -p /etc/systemd/system/graphical.target.wants && \
ln -sf /etc/systemd/system/xfce-autostart.service /etc/systemd/system/graphical.target.wants/xfce-autostart.service
# Update icon and font caches in a final setup layer
RUN gtk-update-icon-cache -f /usr/share/icons/hicolor 2>/dev/null || true && \
gtk-update-icon-cache -f /usr/share/icons/Adwaita 2>/dev/null || true && \
gtk-update-icon-cache -f /usr/share/icons/Papirus 2>/dev/null || true && \
gtk-update-icon-cache -f /usr/share/icons/Tango 2>/dev/null || true && \
fc-cache -fv
# Fix xfwm4 vblank_mode for Turnip (Qualcomm GPU) - prevents XFCE compositor hang
# The sed fix 's/vblank_mode=auto/vblank_mode=off/' does NOT work on the XML format
# (the file uses value="auto" as an XML attribute, not a bare key=value pair).
# Instead we pre-place the complete xfwm4.xml with the correct value already set.
# xfconf will not regenerate the file if it already exists, so this is reliable.
#
# Coverage:
# /etc/skel → copied verbatim into every new user's $HOME by adduser
# /root → root's home is never seeded from /etc/skel, so patch it directly
# /usr/share/xfwm4/defaults → xfwm4's key=value seed file, read before xfconf
COPY scripts/xfwm4.xml /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml
COPY scripts/xfwm4.xml /root/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml
# /usr/share/xfwm4/defaults - key=value seed file xfwm4 reads before xfconf
RUN if [ -f /usr/share/xfwm4/defaults ]; then \
if grep -q '^vblank_mode=' /usr/share/xfwm4/defaults; then \
sed -i 's/^vblank_mode=.*/vblank_mode=off/' /usr/share/xfwm4/defaults; \
else \
echo 'vblank_mode=off' >> /usr/share/xfwm4/defaults; \
fi; \
fi
# Copy binfmt scripts
COPY scripts/binfmt/qemu-binfmt-register.sh /usr/local/bin/
COPY scripts/binfmt/qemu-binfmt-register.service /etc/systemd/system/
RUN chmod +x /usr/local/bin/qemu-binfmt-register.sh && \
chmod 644 /etc/systemd/system/qemu-binfmt-register.service && \
ln -sf /etc/systemd/system/qemu-binfmt-register.service /etc/systemd/system/multi-user.target.wants/qemu-binfmt-register.service
# Purge and reinstall qemu and binfmt in the exact order specified
RUN apt-get purge -y qemu-* binfmt-support || true && \
apt-get autoremove -y && \
apt-get autoclean && \
# Remove any leftover config files
rm -rf /var/lib/binfmts/* && \
rm -rf /etc/binfmt.d/* && \
rm -rf /usr/lib/binfmt.d/qemu-* && \
# Update package lists
apt-get update && \
# Install ONLY these packages (in this specific order)
apt-get install -y qemu-user-static && \
apt-get install -y binfmt-support && \
# Add amd64 architecture and install libc6:amd64
dpkg --add-architecture amd64 && \
apt-get update && \
apt-get install -y libc6:amd64
# Install custom mesa from lfdevs/mesa-for-android-container
COPY scripts/install-mesa /usr/local/bin/install-mesa
RUN chmod +x /usr/local/bin/install-mesa && install-mesa
# Final cleanup of APT cache
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Stage 2: Export to scratch for extraction
FROM scratch AS export
# Copy the entire filesystem from the customizer stage
COPY --from=customizer / /