creating parabola packaging environment now
This commit is contained in:
parent
ced9aa0de9
commit
d3e2c189ae
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,5 +10,8 @@
|
|||||||
# build dirs
|
# build dirs
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
# fragments of running VM
|
||||||
|
.boot/
|
||||||
|
|
||||||
# generated ssh keys
|
# generated ssh keys
|
||||||
keys/*
|
keys/*
|
||||||
|
@ -16,12 +16,15 @@ export _outfile=$_builddir/$(basename $OUTFILE)
|
|||||||
# prepare the empty image
|
# prepare the empty image
|
||||||
./src/stage0.sh
|
./src/stage0.sh
|
||||||
|
|
||||||
# install archlinuxarm in the empty image
|
# install a clean archlinuxarm in the empty image
|
||||||
./src/stage1.sh
|
./src/stage1.sh
|
||||||
|
|
||||||
# migrate the installed image to parabola
|
# migrate the installed image to a clean parabola
|
||||||
./src/stage2.sh
|
./src/stage2.sh
|
||||||
|
|
||||||
|
# setup package development environment
|
||||||
|
./src/stage3.sh
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
chown $(logname) $_outfile
|
chown $(logname) $_outfile
|
||||||
mv -v $_outfile $OUTFILE
|
mv -v $_outfile $OUTFILE
|
||||||
|
@ -58,6 +58,10 @@ mv /etc/pacman.conf{.pacnew,}
|
|||||||
pacman --noconfirm -Syuu
|
pacman --noconfirm -Syuu
|
||||||
|
|
||||||
pacman --noconfirm -S your-freedom
|
pacman --noconfirm -S your-freedom
|
||||||
|
|
||||||
|
userdel -r alarm
|
||||||
|
useradd -mU parabola
|
||||||
|
echo 'parabola:parabola' | chpasswd
|
||||||
EOF
|
EOF
|
||||||
chmod +x $_scriptfile
|
chmod +x $_scriptfile
|
||||||
|
|
||||||
|
116
src/stage3.sh
Executable file
116
src/stage3.sh
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
_scriptfile=$_builddir/migrate.sh
|
||||||
|
_pidfile=$_builddir/qemu.pid
|
||||||
|
|
||||||
|
_loopdev=$(sudo losetup -f --show $_outfile)
|
||||||
|
_bootdir=.boot
|
||||||
|
|
||||||
|
# register cleanup handler to stop the started VM
|
||||||
|
function cleanup {
|
||||||
|
test -f $_pidfile && (kill -9 $(cat $_pidfile) || true)
|
||||||
|
rm -f $_pidfile
|
||||||
|
umount ${_loopdev}p1
|
||||||
|
losetup -d $_loopdev
|
||||||
|
rm -rf $_bootdir
|
||||||
|
rm -f $_scriptfile
|
||||||
|
}
|
||||||
|
trap cleanup ERR
|
||||||
|
|
||||||
|
# create the package build preparation script, adapted from
|
||||||
|
# https://wiki.parabola.nu/Package_maintainer_guide
|
||||||
|
(source /etc/makepkg.conf && cat > $_scriptfile << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# setup parabola login keys
|
||||||
|
cat /root/.ssh/authorized_keys >> /home/parabola/.ssh/authorized_keys
|
||||||
|
|
||||||
|
# fix key permissions and ownership
|
||||||
|
chown -R parabola:parabola /home/parabola/{.gnupg,.ssh,.gitconfig}
|
||||||
|
chmod 600 /home/parabola/.ssh/authorized_keys
|
||||||
|
|
||||||
|
# install needed packages
|
||||||
|
pacman --noconfirm -S libretools vim sudo rxvt-unicode-terminfo
|
||||||
|
|
||||||
|
# update configuration
|
||||||
|
sed -i \
|
||||||
|
-e 's_^#PKGDEST.*_PKGDEST="/home/parabola/output/packages_' \
|
||||||
|
-e 's_^#SRCDEST.*_SRCDEST="/home/parabola/output/sources_' \
|
||||||
|
-e 's_^#SRCPKGDEST.*_SRCPKGDEST="/home/parabola/output/srcpackages_' \
|
||||||
|
-e 's_^#LOGDEST.*_LOGDEST="/home/parabola/output/makepkglogs_' \
|
||||||
|
-e 's_^#PACKAGER.*_PACKAGER="$PACKAGER"_' \
|
||||||
|
-e 's_^#GPGKEY.*_GPGKEY="$GPGKEY"_' \
|
||||||
|
/etc/makepkg.conf
|
||||||
|
|
||||||
|
sed -i \
|
||||||
|
-e 's_^CHROOTDIR.*_CHROOTDIR="/home/parabola/build"_' \
|
||||||
|
-e 's_^CHROOTEXTRAPKG.*_CHROOTEXTRAPKG=(vim)_' \
|
||||||
|
/etc/libretools.d/chroot.conf
|
||||||
|
|
||||||
|
# create directories
|
||||||
|
mkdir -p /home/parabola/output/{packages,sources,srcpackages,makepkglogs}
|
||||||
|
chown -R parabola:parabola /home/parabola/output
|
||||||
|
|
||||||
|
# disable systemd-stdin hack...
|
||||||
|
sed -i '/XXX: SYSTEMD-STDIN HACK/,+9d' /usr/bin/librechroot
|
||||||
|
|
||||||
|
# setup work directories
|
||||||
|
su - parabola -c createworkdir
|
||||||
|
librechroot make
|
||||||
|
|
||||||
|
# setup sudo
|
||||||
|
cat > /etc/sudoers.d/parabola << IEOF
|
||||||
|
# grant full permissions to user parabola
|
||||||
|
parabola ALL=(ALL) NOPASSWD: ALL
|
||||||
|
IEOF
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
chmod +x $_scriptfile
|
||||||
|
|
||||||
|
# start the VM
|
||||||
|
mkdir -p $_bootdir
|
||||||
|
mount ${_loopdev}p1 $_bootdir
|
||||||
|
QEMU_AUDIO_DRV=none qemu-system-arm \
|
||||||
|
-M vexpress-a9 \
|
||||||
|
-m 1G \
|
||||||
|
-dtb $_bootdir/dtbs/vexpress-v2p-ca9.dtb \
|
||||||
|
-kernel $_bootdir/zImage \
|
||||||
|
--append "root=/dev/mmcblk0p2 rw roottype=ext4 console=ttyAMA0" \
|
||||||
|
-drive if=sd,driver=raw,cache=writeback,file=$_outfile \
|
||||||
|
-display none \
|
||||||
|
-net user,hostfwd=tcp::2022-:22 \
|
||||||
|
-net nic \
|
||||||
|
-daemonize \
|
||||||
|
-pidfile $_pidfile
|
||||||
|
|
||||||
|
# wait for ssh to be up
|
||||||
|
while ! ssh -p 2022 -i keys/id_rsa root@localhost -o StrictHostKeyChecking=no true 2>/dev/null; do
|
||||||
|
echo -n . && sleep 5
|
||||||
|
done && echo
|
||||||
|
|
||||||
|
# copy the current users keys keys to the VM
|
||||||
|
scp -rP 2022 -i keys/id_rsa $(sudo -iu $(logname) pwd)/.gnupg root@localhost:/home/parabola/
|
||||||
|
scp -rP 2022 -i keys/id_rsa $(sudo -iu $(logname) pwd)/.ssh root@localhost:/home/parabola/
|
||||||
|
scp -rP 2022 -i keys/id_rsa $(sudo -iu $(logname) pwd)/.gitconfig root@localhost:/home/parabola/
|
||||||
|
|
||||||
|
# copy and execute the migration script
|
||||||
|
scp -P 2022 -i keys/id_rsa $_scriptfile root@localhost:
|
||||||
|
ssh -p 2022 -i keys/id_rsa root@localhost "./$(basename $_scriptfile)"
|
||||||
|
|
||||||
|
# open a shell for debugging
|
||||||
|
# ssh -p 2022 -i keys/id_rsa root@localhost
|
||||||
|
|
||||||
|
# stop the VM
|
||||||
|
ssh -p 2022 -i keys/id_rsa root@localhost "nohup shutdown -h now &>/dev/null & exit"
|
||||||
|
while kill -0 $(cat $_pidfile) 2> /dev/null; do echo -n . && sleep 5; done && echo
|
||||||
|
rm -f $_pidfile
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
umount ${_loopdev}p1
|
||||||
|
losetup -d $_loopdev
|
||||||
|
rm -rf $_bootdir
|
||||||
|
rm $_scriptfile
|
3
start.sh
3
start.sh
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
|
||||||
_builddir=build
|
_builddir=build
|
||||||
mkdir -p $_builddir
|
mkdir -p $_builddir
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ while ! ssh -p 2022 -i keys/id_rsa root@localhost $_sshopts true 2>/dev/null; do
|
|||||||
done && echo
|
done && echo
|
||||||
|
|
||||||
# open a session
|
# open a session
|
||||||
ssh -p 2022 -i keys/id_rsa root@localhost
|
ssh -p 2022 -i keys/id_rsa parabola@localhost
|
||||||
|
|
||||||
# shutdown the VM
|
# shutdown the VM
|
||||||
ssh -p 2022 -i keys/id_rsa root@localhost "nohup shutdown -h now &>/dev/null & exit"
|
ssh -p 2022 -i keys/id_rsa root@localhost "nohup shutdown -h now &>/dev/null & exit"
|
||||||
|
Loading…
Reference in New Issue
Block a user