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
|
||||||
|
|
||||||
|
|
||||||
|
run_debootstrap() {
|
||||||
[[ -d ${DBS_ROOT} ]] && rm -rf ${DBS_ROOT}
|
[[ -d ${DBS_ROOT} ]] && rm -rf ${DBS_ROOT}
|
||||||
|
|
||||||
[[ -f ${CACHE_DIR}/lock ]] && rm -f ${CACHE_DIR}/lock
|
[[ -f ${CACHE_DIR}/lock ]] && rm -f ${CACHE_DIR}/lock
|
||||||
mkdir -p ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
mkdir -p ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
||||||
mount --bind ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
mount --bind ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
|
||||||
|
|
||||||
debootstrap --verbose --merged-usr --variant=minbase --include=systemd-sysv,locales \
|
debootstrap --verbose --merged-usr --variant=minbase \
|
||||||
|
--include=systemd-sysv,locales \
|
||||||
--exclude=sysv-rc,initscripts,startpar,lsb-base,insserv \
|
--exclude=sysv-rc,initscripts,startpar,lsb-base,insserv \
|
||||||
buster ${DBS_ROOT}
|
${DEBIAN_RELEASE} ${DBS_ROOT} ${DEBIAN_MIRROR}
|
||||||
|
}
|
||||||
|
|
||||||
|
run_chroot_stage() {
|
||||||
mount chproc ${DBS_ROOT}/proc -t proc
|
mount chproc ${DBS_ROOT}/proc -t proc
|
||||||
mount chsys ${DBS_ROOT}/sys -t sysfs
|
mount chsys ${DBS_ROOT}/sys -t sysfs
|
||||||
|
|
||||||
cp --preserve=mode ${SCRIPT_DIR}/build-user-rootfs-stage-two ${DBS_ROOT}/root/install.sh
|
cp --preserve=mode ${SCRIPT_DIR}/build-user-rootfs-stage-two ${DBS_ROOT}/root/install.sh
|
||||||
|
|
||||||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot ${DBS_ROOT} /root/install.sh
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot ${DBS_ROOT} /root/install.sh ${DEBIAN_RELEASE} ${DEBIAN_MIRROR}
|
||||||
rm -f ${DBS_ROOT}/root/install.sh
|
rm -f ${DBS_ROOT}/root/install.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cleanup_chroot() {
|
||||||
umount ${DBS_ROOT}/proc
|
umount ${DBS_ROOT}/proc
|
||||||
umount ${DBS_ROOT}/sys
|
umount ${DBS_ROOT}/sys
|
||||||
umount ${DBS_ROOT}/var/cache/apt/archives
|
umount ${DBS_ROOT}/var/cache/apt/archives
|
||||||
rm -f ${DBS_ROOT}/var/cache/apt/pkgcache.bin
|
rm -f ${DBS_ROOT}/var/cache/apt/pkgcache.bin
|
||||||
rm -f ${DBS_ROOT}/var/cache/apt/srcpkgcache.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"
|
generate_tarball() {
|
||||||
|
printf "\n\n----- Generating rootfs tarball -----\n\n"
|
||||||
tar -C ${DBS_ROOT} -c --xattrs --xattrs-include=* -f ${DBS_BASE}/user-rootfs.tar .
|
tar -C ${DBS_ROOT} -c --xattrs --xattrs-include=* -f ${DBS_BASE}/user-rootfs.tar .
|
||||||
xz --force --threads=0 ${DBS_BASE}/user-rootfs.tar
|
#xz --force --threads=0 ${DBS_BASE}/user-rootfs.tar
|
||||||
ls -al ${DBS_BASE}/user-rootfs.tar.xz
|
ls -al ${DBS_BASE}/user-rootfs.tar
|
||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
run_debootstrap
|
||||||
|
run_chroot_stage
|
||||||
|
cleanup_chroot
|
||||||
|
generate_tarball
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
#!/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"
|
||||||
|
|
||||||
|
setup_locale() {
|
||||||
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
|
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
|
||||||
locale-gen
|
locale-gen
|
||||||
update-locale LANG=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
|
export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_systemd() {
|
||||||
mkdir -p /etc/systemd/user.conf.d
|
mkdir -p /etc/systemd/user.conf.d
|
||||||
printf '[Manager]\nDefaultEnvironment="DISPLAY=:0"\n' > /etc/systemd/user.conf.d/50-display-env.conf
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
write_launch_script() {
|
||||||
mkdir -p /usr/libexec
|
mkdir -p /usr/libexec
|
||||||
cat > /usr/libexec/launch <<- 'EOF'
|
cat > /usr/libexec/launch <<- 'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@ -23,18 +29,45 @@ cat > /usr/libexec/launch <<- 'EOF'
|
|||||||
$@
|
$@
|
||||||
EOF
|
EOF
|
||||||
chmod +x /usr/libexec/launch
|
chmod +x /usr/libexec/launch
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_apt_sources() {
|
||||||
|
echo "deb ${DEBIAN_MIRROR} ${DEBIAN_RELEASE} main contrib non-free"
|
||||||
|
echo "deb ${DEBIAN_MIRROR}-security ${DEBIAN_RELEASE}/updates main contrib non-free"
|
||||||
|
echo "deb ${DEBIAN_MIRROR} unstable main"
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_etc() {
|
||||||
printf "127.0.0.1\tsubgraph localhost\n" > /etc/hosts
|
printf "127.0.0.1\tsubgraph localhost\n" > /etc/hosts
|
||||||
echo "subgraph" > /etc/hostname
|
echo "subgraph" > /etc/hostname
|
||||||
echo "deb http://http.debian.net/debian unstable main" >> /etc/apt/sources.list
|
generate_apt_sources > /etc/apt/sources.list
|
||||||
|
}
|
||||||
|
|
||||||
|
create_user() {
|
||||||
useradd -s /bin/bash -m user
|
useradd -s /bin/bash -m user
|
||||||
echo "user:user" | chpasswd
|
echo "user:user" | chpasswd
|
||||||
usermod -aG sudo user
|
usermod -aG sudo user
|
||||||
echo "export DISPLAY=:0" >> /home/user/.bashrc
|
echo "export DISPLAY=:0" >> /home/user/.bashrc
|
||||||
|
}
|
||||||
|
|
||||||
|
install_packages() {
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get --assume-yes upgrade
|
apt-get --assume-yes upgrade
|
||||||
apt-get --assume-yes --no-install-recommends install ${PACKAGES}
|
apt-get --assume-yes --no-install-recommends install ${PACKAGES}
|
||||||
|
|
||||||
printf "\n\nInstalled Packages\n\n"
|
printf "\n\nInstalled Packages\n\n"
|
||||||
dpkg -l
|
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