refactored appimg build scripts
This commit is contained in:
parent
13fae562f9
commit
f3a13f6e6d
@ -1,40 +1,56 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
DEBIAN_MIRROR="https://deb.debian.org/debian"
|
||||||
|
DEBIAN_RELEASE="buster"
|
||||||
|
|
||||||
#SCRIPT=$(realpath ${BASH_SOURCE})
|
|
||||||
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE}))
|
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE}))
|
||||||
DBS_BASE=$(realpath ${SCRIPT_DIR}/../build/debootstrap)
|
DBS_BASE=$(realpath ${SCRIPT_DIR}/../build/debootstrap)
|
||||||
DBS_ROOT=${DBS_BASE}/rootfs
|
DBS_ROOT=${DBS_BASE}/rootfs
|
||||||
CACHE_DIR=${DBS_BASE}/var-cache-apt-archives
|
CACHE_DIR=${DBS_BASE}/var-cache-apt-archives
|
||||||
|
|
||||||
[[ -d ${DBS_ROOT} ]] && rm -rf ${DBS_ROOT}
|
|
||||||
|
|
||||||
[[ -f ${CACHE_DIR}/lock ]] && rm -f ${CACHE_DIR}/lock
|
run_debootstrap() {
|
||||||
mkdir -p ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
[[ -d ${DBS_ROOT} ]] && rm -rf ${DBS_ROOT}
|
||||||
mount --bind ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
|
||||||
|
|
||||||
debootstrap --verbose --merged-usr --variant=minbase --include=systemd-sysv,locales \
|
[[ -f ${CACHE_DIR}/lock ]] && rm -f ${CACHE_DIR}/lock
|
||||||
--exclude=sysv-rc,initscripts,startpar,lsb-base,insserv \
|
mkdir -p ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
||||||
buster ${DBS_ROOT}
|
mount --bind ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
||||||
|
|
||||||
mount chproc ${DBS_ROOT}/proc -t proc
|
debootstrap --verbose --merged-usr --variant=minbase \
|
||||||
mount chsys ${DBS_ROOT}/sys -t sysfs
|
--include=systemd-sysv,locales \
|
||||||
|
--exclude=sysv-rc,initscripts,startpar,lsb-base,insserv \
|
||||||
|
${DEBIAN_RELEASE} ${DBS_ROOT} ${DEBIAN_MIRROR}
|
||||||
|
}
|
||||||
|
|
||||||
cp --preserve=mode ${SCRIPT_DIR}/build-user-rootfs-stage-two ${DBS_ROOT}/root/install.sh
|
run_chroot_stage() {
|
||||||
|
mount chproc ${DBS_ROOT}/proc -t proc
|
||||||
|
mount chsys ${DBS_ROOT}/sys -t sysfs
|
||||||
|
|
||||||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot ${DBS_ROOT} /root/install.sh
|
cp --preserve=mode ${SCRIPT_DIR}/build-user-rootfs-stage-two ${DBS_ROOT}/root/install.sh
|
||||||
rm -f ${DBS_ROOT}/root/install.sh
|
|
||||||
|
|
||||||
umount ${DBS_ROOT}/proc
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot ${DBS_ROOT} /root/install.sh ${DEBIAN_RELEASE} ${DEBIAN_MIRROR}
|
||||||
umount ${DBS_ROOT}/sys
|
rm -f ${DBS_ROOT}/root/install.sh
|
||||||
umount ${DBS_ROOT}/var/cache/apt/archives
|
}
|
||||||
rm -f ${DBS_ROOT}/var/cache/apt/pkgcache.bin
|
|
||||||
rm -f ${DBS_ROOT}/var/cache/apt/srcpkgcache.bin
|
|
||||||
|
|
||||||
printf "\n\n----- Generating compressed tarball (this will take a couple of minutes) -----\n\n"
|
|
||||||
tar -C ${DBS_ROOT} -c --xattrs --xattrs-include=* -f ${DBS_BASE}/user-rootfs.tar .
|
|
||||||
xz --force --threads=0 ${DBS_BASE}/user-rootfs.tar
|
|
||||||
ls -al ${DBS_BASE}/user-rootfs.tar.xz
|
|
||||||
printf "\n\n"
|
|
||||||
|
|
||||||
|
|
||||||
|
cleanup_chroot() {
|
||||||
|
umount ${DBS_ROOT}/proc
|
||||||
|
umount ${DBS_ROOT}/sys
|
||||||
|
umount ${DBS_ROOT}/var/cache/apt/archives
|
||||||
|
rm -f ${DBS_ROOT}/var/cache/apt/pkgcache.bin
|
||||||
|
rm -f ${DBS_ROOT}/var/cache/apt/srcpkgcache.bin
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_tarball() {
|
||||||
|
printf "\n\n----- Generating rootfs tarball -----\n\n"
|
||||||
|
tar -C ${DBS_ROOT} -c --xattrs --xattrs-include=* -f ${DBS_BASE}/user-rootfs.tar .
|
||||||
|
#xz --force --threads=0 ${DBS_BASE}/user-rootfs.tar
|
||||||
|
ls -al ${DBS_BASE}/user-rootfs.tar
|
||||||
|
printf "\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
run_debootstrap
|
||||||
|
run_chroot_stage
|
||||||
|
cleanup_chroot
|
||||||
|
generate_tarball
|
||||||
|
@ -1,40 +1,73 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
PACKAGES="man manpages vim less xz-utils sudo tmux dbus libpam-systemd vifm openssh-client gnome-terminal packagekit-gtk3-module libcanberra-gtk3-module firefox fonts-roboto-hinted nautilus eog evince unzip"
|
PACKAGES="man manpages vim less xz-utils sudo tmux dbus libpam-systemd vifm openssh-client gnome-terminal packagekit-gtk3-module libcanberra-gtk3-module firefox fonts-roboto-hinted nautilus eog evince unzip"
|
||||||
|
|
||||||
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
|
setup_locale() {
|
||||||
locale-gen
|
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
|
||||||
update-locale LANG=en_US.UTF-8
|
locale-gen
|
||||||
export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
|
update-locale LANG=en_US.UTF-8
|
||||||
|
export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
|
||||||
|
}
|
||||||
|
|
||||||
mkdir -p /etc/systemd/user.conf.d
|
configure_systemd() {
|
||||||
printf '[Manager]\nDefaultEnvironment="DISPLAY=:0"\n' > /etc/systemd/user.conf.d/50-display-env.conf
|
mkdir -p /etc/systemd/user.conf.d
|
||||||
|
printf '[Manager]\nDefaultEnvironment="DISPLAY=:0"\n' > /etc/systemd/user.conf.d/50-display-env.conf
|
||||||
|
|
||||||
mkdir -p /etc/systemd/logind.conf.d
|
mkdir -p /etc/systemd/logind.conf.d
|
||||||
printf 'KillUserProcesses=no\n' > /etc/systemd/logind.conf.d/50-no-kill-user-processes.conf
|
printf 'KillUserProcesses=no\n' > /etc/systemd/logind.conf.d/50-no-kill-user-processes.conf
|
||||||
|
}
|
||||||
|
|
||||||
mkdir -p /usr/libexec
|
write_launch_script() {
|
||||||
cat > /usr/libexec/launch <<- 'EOF'
|
mkdir -p /usr/libexec
|
||||||
#!/bin/bash
|
cat > /usr/libexec/launch <<- 'EOF'
|
||||||
export DISPLAY=:0
|
#!/bin/bash
|
||||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
|
export DISPLAY=:0
|
||||||
export XDG_RUNTIME_DIR=/run/user/1000
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
|
||||||
export PULSE_SERVER=unix:/run/user/host/pulse/native
|
export XDG_RUNTIME_DIR=/run/user/1000
|
||||||
$@
|
export PULSE_SERVER=unix:/run/user/host/pulse/native
|
||||||
|
$@
|
||||||
EOF
|
EOF
|
||||||
chmod +x /usr/libexec/launch
|
chmod +x /usr/libexec/launch
|
||||||
|
}
|
||||||
|
|
||||||
printf "127.0.0.1\tsubgraph localhost\n" > /etc/hosts
|
generate_apt_sources() {
|
||||||
echo "subgraph" > /etc/hostname
|
echo "deb ${DEBIAN_MIRROR} ${DEBIAN_RELEASE} main contrib non-free"
|
||||||
echo "deb http://http.debian.net/debian unstable main" >> /etc/apt/sources.list
|
echo "deb ${DEBIAN_MIRROR}-security ${DEBIAN_RELEASE}/updates main contrib non-free"
|
||||||
useradd -s /bin/bash -m user
|
echo "deb ${DEBIAN_MIRROR} unstable main"
|
||||||
echo "user:user" | chpasswd
|
}
|
||||||
usermod -aG sudo user
|
|
||||||
echo "export DISPLAY=:0" >> /home/user/.bashrc
|
|
||||||
|
|
||||||
apt-get update
|
setup_etc() {
|
||||||
apt-get --assume-yes upgrade
|
printf "127.0.0.1\tsubgraph localhost\n" > /etc/hosts
|
||||||
apt-get --assume-yes --no-install-recommends install ${PACKAGES}
|
echo "subgraph" > /etc/hostname
|
||||||
|
generate_apt_sources > /etc/apt/sources.list
|
||||||
|
}
|
||||||
|
|
||||||
printf "\n\nInstalled Packages\n\n"
|
create_user() {
|
||||||
dpkg -l
|
useradd -s /bin/bash -m user
|
||||||
|
echo "user:user" | chpasswd
|
||||||
|
usermod -aG sudo user
|
||||||
|
echo "export DISPLAY=:0" >> /home/user/.bashrc
|
||||||
|
}
|
||||||
|
|
||||||
|
install_packages() {
|
||||||
|
apt-get update
|
||||||
|
apt-get --assume-yes upgrade
|
||||||
|
apt-get --assume-yes --no-install-recommends install ${PACKAGES}
|
||||||
|
|
||||||
|
printf "\n\nInstalled Packages\n\n"
|
||||||
|
dpkg -l
|
||||||
|
}
|
||||||
|
|
||||||
|
set -u
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DEBIAN_RELEASE=${1}
|
||||||
|
DEBIAN_MIRROR=${2}
|
||||||
|
|
||||||
|
setup_locale
|
||||||
|
configure_systemd
|
||||||
|
write_launch_script
|
||||||
|
setup_etc
|
||||||
|
create_user
|
||||||
|
install_packages
|
||||||
|
Loading…
Reference in New Issue
Block a user