280 lines
8.9 KiB
Bash
280 lines
8.9 KiB
Bash
#!/usr/bun/env bash
|
|
|
|
sudo apt install -y sbuild schroot
|
|
|
|
# corresponds to Debian 7 Wheezy 20170617T034212Z
|
|
# Devuan 1.0 Jessie corresponds to Debian 8 Jessie 20180623T023722Z
|
|
# Devuan 2.0 ASCII corresponds to Debian 9 Stretch 20200717T204551Z
|
|
# Devuan 3.0 Beowulf corresponds to Debian 10.4 Buster 20230611T103552Z
|
|
# Devuan 4.0 Chimaera corresponds to Debian 11.1 Bullseye20230611T103552Z
|
|
# Devuan 5.0 Daedalus corresponds to Debian 12 Bookworm 20231007T150030Z
|
|
# Devuan 6.0 Excalibur corresponds to Debian 13 Trixie testing
|
|
# Devuan 7.0 Freia corresponds to Debian 14 Forky
|
|
# Devuan Ceres corresponds to Debian Sid unstable
|
|
|
|
UNSTABLE="ceres"
|
|
# TESTING="excalibur"
|
|
STABLE="daedalus"
|
|
OLD_STABLE="chimaera"
|
|
|
|
# distro="devuan"
|
|
# location="/srv/chroot"
|
|
# tarball="${release}-sbuild.tgz"
|
|
R="/space/code_repositories/decode-os/os-build-system/arm-sdk"
|
|
strapdir="$R/tmp/devuan-arm64-build/bootstrap"
|
|
arch="arm64"
|
|
release="daedalus"
|
|
mirror="http://deb.devuan.org/merged/" # apt url for debootsrap and dpks.
|
|
apt_proxy="http://192.168.1.49:3142" # apt-cacher.-ng proxy
|
|
schroot_config="arm-sdk"
|
|
sources_dir="$R/tmp/kernels/rockpro64" # where the sources outside the chroot are palced.
|
|
sources_dest="/scratch" # where to mount the sources you wish to build in the chroot.
|
|
|
|
conf_print_schroot() {
|
|
fn conf_print_schroot
|
|
req=(OLD_STABLE STABLE TESTING UNSTABLE)
|
|
ckreq || return 1
|
|
|
|
cat <<-EOF
|
|
# schroot chroot definitions.
|
|
# See schroot.conf(5) for complete documentation of the file format.
|
|
#
|
|
# Please take note that you should not add untrusted users to
|
|
# root-groups, because they will essentially have full root access
|
|
# to your system. They will only have root access inside the chroot,
|
|
# but that's enough to cause malicious damage.
|
|
#
|
|
# Per chroot configuration should be put in /etc/schroot/chroot.d/<name>
|
|
# and this file reserved for default values for all chroots.
|
|
#
|
|
# This is mostly for sbuild created chroots who's creation time
|
|
# settings are limited.
|
|
#
|
|
[*]
|
|
type=directory
|
|
union-type=overlay
|
|
command-prefix=eatmydata,ccache
|
|
users=default
|
|
source-users=default
|
|
script-config=/etc/schroot/default/config
|
|
preserve-environment=true
|
|
EOF
|
|
}
|
|
# conf_print_schroot | sudo tee /etc/schroot/schroot.conf >/dev/null
|
|
|
|
#-------------------------------------------------------------------------------
|
|
## sbuild configuration
|
|
# See: https://wiki.ubuntu.com/SimpleSbuild
|
|
# cp /usr/share/doc/sbuild/examples/example.sbuildrc ~/.sbuildrc
|
|
conf_print_sbuildrc() {
|
|
fn conf_print_sbuildrc
|
|
req=(release)
|
|
ckreq || return 1
|
|
|
|
cat <<-EOF | sudo tee ~/.sbuildrc
|
|
# sbuild configuration file
|
|
#
|
|
# See sbuild.conf(5) for complete documentation of the file format.
|
|
#
|
|
# Name to use as override in .changes files for the Maintainer: field
|
|
# (mandatory, no default!).
|
|
\$maintainer_name='Your Name <user@ubuntu.com>';
|
|
|
|
# Default distribution to build.
|
|
\$distribution = "${release}";
|
|
# Build arch-all by default.
|
|
\$build_arch_all = 1;
|
|
|
|
# When to purge the build directory afterwards; possible values are "never",
|
|
# "successful", and "always". "always" is the default. It can be helpful
|
|
# to preserve failing builds for debugging purposes. Switch these comments
|
|
# if you want to preserve even successful builds, and then use
|
|
# "schroot -e --all-sessions" to clean them up manually.
|
|
\$purge_build_directory = 'successful';
|
|
\$purge_session = 'successful';
|
|
\$purge_build_deps = 'successful';
|
|
# \$purge_build_directory = 'never';
|
|
# \$purge_session = 'never';
|
|
# \$purge_build_deps = 'never';
|
|
|
|
# Directory for writing build logs to
|
|
\$log_dir=\$ENV{HOME}."/devuan/logs";
|
|
|
|
# don't remove this, Perl needs it:
|
|
1;
|
|
EOF
|
|
}
|
|
# conf_print_sbuildrc | sudo tee ~/.sbuildrc >/dev/null
|
|
|
|
# Create ~/.mk-sbuild.rc:
|
|
conf_print_mk_sbuild_rc() {
|
|
fn conf_print_mk_sbuild_rc
|
|
req=(apt_proxy)
|
|
ckreq || return 1
|
|
|
|
cat <<-EOF
|
|
SCHROOT_CONF_SUFFIX="source-root-users=root,sbuild,admin
|
|
source-root-groups=root,sbuild,admin
|
|
preserve-environment=true"
|
|
# you will want to undo the below for stable releases, read 'man mk-sbuild' for details
|
|
# during the development cycle, these pockets are not used, but will contain important
|
|
# updates after each release of Ubuntu
|
|
SKIP_UPDATES="1"
|
|
SKIP_PROPOSED="1"
|
|
# if you have e.g. apt-cacher-ng around
|
|
# DEBOOTSTRAP_PROXY=${apt_proxy}
|
|
EOF
|
|
}
|
|
# conf_print_mk-sbuild_rc | sudo tee ~/.mk-sbuild.rc >/dev/null
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Create the custom schroot config directory and contents.
|
|
mkdir -p /etc/schroot/${schroot_config}
|
|
|
|
conf_print_chroot_config() {
|
|
fn conf_print_chroot_config
|
|
req=(schoot_config sources_dir sources_dest)
|
|
ckreq || return 1
|
|
|
|
cat <<-EOF | sudo tee /etc/schroot/${schroot_config}/copyfiles
|
|
# Files to copy into the chroot from the host system.
|
|
#
|
|
# <source-and-destination>[ <destination>]
|
|
/etc/resolv.conf
|
|
/etc/hosts
|
|
/etc/sudoers
|
|
~/.Xauthority
|
|
EOF
|
|
|
|
cat <<-EOF | sudo tee /etc/schroot/${schroot_config}/fstab
|
|
# fstab: static file system information for chroots.
|
|
# Note that the mount point will be prefixed by the chroot path
|
|
# (CHROOT_PATH)
|
|
#
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
/proc /proc none rw,bind 0 0
|
|
/sys /sys none rw,bind 0 0
|
|
/dev /dev none rw,bind 0 0
|
|
/dev/pts /dev/pts none rw,bind 0 0
|
|
${sources_dir} ${sources_dest} none rw,bind 0 0
|
|
/tmp /tmp none rw,bind 0 0
|
|
|
|
# It may be desirable to have access to /run, especially if you wish
|
|
# to run additional services in the chroot. However, note that this
|
|
# may potentially cause undesirable behaviour on upgrades, such as
|
|
# killing services on the host.
|
|
#/run /run none rw,bind 0 0
|
|
#/run/lock /run/lock none rw,bind 0 0
|
|
#/dev/shm /dev/shm none rw,bind 0 0
|
|
#/run/shm /run/shm none rw,bind 0 0
|
|
EOF
|
|
|
|
cat <<-EOF | sudo tee /etc/schroot/${schroot_config}/nssdatabases
|
|
# System databases to copy into the chroot from the host system.
|
|
#
|
|
# <database name>
|
|
passwd
|
|
shadow
|
|
group
|
|
gshadow
|
|
services
|
|
protocols
|
|
networks
|
|
hosts
|
|
EOF
|
|
|
|
cat <<-EOF | sudo tee /etc/schroot/${schroot_config}/config
|
|
# Filesystems to mount inside the chroot.
|
|
FSTAB="/etc/schroot/custom/fstab"
|
|
|
|
# Files to copy from the host system into the chroot.
|
|
COPYFILES="/etc/schroot/custom/copyfiles"
|
|
|
|
# System NSS databases to copy into the chroot.
|
|
NSSDATABASES="/etc/schroot/custom/nssdatabases"
|
|
EOF
|
|
}
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# sudo sbuild-createchroot \
|
|
# --arch=${arch} \
|
|
# --make-sbuild-tarball=${location}/${tarball} \
|
|
# ${release} \
|
|
# ${location}/${release} \
|
|
# ${mirror}
|
|
|
|
# this is the file created automatically by the create line above.
|
|
# cat <<-EOF | sudo tee /etc/schroot/chroot.d/daedalus-arm64-sbuild-lNGdIk
|
|
# [daedalus-arm64-sbuild]
|
|
# description=Debian daedalus/arm64 autobuilder
|
|
# groups=root,sbuild
|
|
# root-groups=root,sbuild
|
|
# profile=sbuild
|
|
# type=file
|
|
# file=/srv/chroot/daedalus-sbuild.tgz
|
|
# EOF
|
|
#
|
|
# cat <<-EOF | sudo tee -a /etc/schroot/schroot.d/${release}_${arch}
|
|
# [${release}-file]
|
|
# description=${distro} ${release} (custom)
|
|
# file=/srv/chroot/${release}.tar.gz
|
|
# location=/${location}
|
|
# groups=sbuild
|
|
# EOF
|
|
|
|
conf_print_chroot_d() {
|
|
fn conf_print_chroot_d
|
|
req=(strapdir arch release schroot_config)
|
|
ckreq || return 1
|
|
|
|
cat <<-EOF | sudo tee -a /etc/schroot/schroot.d/${release}_${arch}
|
|
[${release}_${arch}]
|
|
description=${release} (${arch}) for devuan arm-sdk
|
|
type=directory
|
|
directory=${strapdir}
|
|
union-type=overlay # 'aufs', 'overlay' and 'unionfs'
|
|
command-prefix=eatmydata,ccache
|
|
users=default
|
|
source-users=default
|
|
script-config=${schroot_config}/config
|
|
preserve-environment=true
|
|
EOF
|
|
}
|
|
# conf_print_chroot_d | sudo tee /etc/schroot/schroot.d/${release}_${arch} >/dev/null
|
|
|
|
# zfs snapshot examples
|
|
zfs_snapshot="rpool/CHROOT/sid"
|
|
sudo zfs snapshot ${zfs_snapshot}@initial
|
|
sudo zfs create ${zfs_snapshot}
|
|
|
|
sudo sbuild-createchroot \
|
|
--arch=${arch} \
|
|
--include=debhelper,eatmydata,ccache \
|
|
--chroot-mode=schroot \
|
|
--components=main contrib non-free \
|
|
${release} \
|
|
${zfs_snapshot} \
|
|
${mirror}
|
|
|
|
# cat <<-EOF | sudo tee /etc/schroot/chroot.d/sid-zfs-snapshot
|
|
# [sid-zfs-snapshot]
|
|
# description=Devuan sid ZFS snapshot
|
|
# type=zfs-snapshot
|
|
# zfs-dataset=rpool/CHROOT/sid
|
|
# zfs-snapshot=initial
|
|
# groups=root,sbuild
|
|
# root-groups=root,sbuild
|
|
# EOF
|
|
# schroot -c sid-zfs-snapshot
|
|
|
|
# [${UNSTABLE}-znap]
|
|
# type=zfs-snapshot
|
|
# description=Devuan ${UNSTABLE} ZFS snapshot
|
|
# groups=sbuild,root
|
|
# root-users=rleigh
|
|
# root-groups=root,sbuild
|
|
# source-root-users=rleigh
|
|
# zfs-dataset=rpool/CHROOT/${UNSTABLE}
|
|
# mount-options=-o atime,sync,user_xattr
|
|
# zfs-snapshot-options=-o checksum=off
|