-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·125 lines (108 loc) · 2.9 KB
/
install.sh
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
#!/bin/bash
set -e
# check if the needed tools exist
mksquashfs -version | grep 'mksquashfs version'
xorriso -version 2>/dev/null | grep 'xorriso version'
ROOTDIR="$(dirname $(realpath "$0"))"
WORKDIR=/tmp/work
ISO="$(realpath "$1")"
MIRROR=
DESKTOP=nox
COMP=xz
shift
while [ -n "$1" ]; do
case "$1" in
--mirror)
shift
MIRROR="$1"
shift
;;
--mirror=*)
MIRROR="${1/--mirror=}"
shift
;;
--desktop)
shift
DESKTOP="$1"
shift
;;
--desktop=*)
DESKTOP="${1/--desktop=}"
shift
;;
--comp)
shift
COMP="$1"
shift
;;
--comp=*)
COMP="${1/--comp=}"
shift
;;
*)
;;
esac
done
mkdir -p "${WORKDIR}/mnt"
if test -d /var/cache/pacman/pkg
then
PKGDIR=/var/cache/pacman/pkg
else
mkdir -p "${WORKDIR}/pkg"
PKGDIR=pkg
fi
cd "${WORKDIR}"
mount "$ISO" mnt
# copy all iso files to target/
mkdir -p target/arch/x86_64
cp -a mnt/{EFI,syslinux,loader} target/
cp -a mnt/arch/boot target/arch/
unsquashfs mnt/arch/x86_64/airootfs.sfs
#mount -t proc none squashfs-root/proc
#mount --bind /dev squashfs-root/dev
#mount -t sysfs none squashfs-root/sys
mount --bind "${PKGDIR}" squashfs-root/var/cache/pacman/pkg
mkdir -p squashfs-root/aur
mount --bind -o ro "${ROOTDIR}/aur-packages" squashfs-root/aur
#cp -L /etc/resolv.conf squashfs-root/etc/resolv.conf
cp "${ROOTDIR}/chroot-install.sh" squashfs-root/
#install -D "${ROOTDIR}/archiso.preset" squashfs-root/etc/mkinitcpio.d/
cd squashfs-root
systemd-nspawn /usr/bin/env MIRROR="${MIRROR}" DESKTOP="${DESKTOP}" \
/bin/bash /chroot-install.sh
cd "${WORKDIR}"
rm squashfs-root/chroot-install.sh
install "${ROOTDIR}/syncarch" squashfs-root/usr/local/bin/syncarch
install "${ROOTDIR}/xinitrc" squashfs-root/home/arch/.xinitrc
chroot squashfs-root chown -R arch:arch \
/home/arch/.xinitrc
cat "${ROOTDIR}/motd" >> squashfs-root/etc/motd
mv squashfs-root/boot/vmlinuz-linux target/arch/boot/x86_64/
mv squashfs-root/boot/initramfs-linux.img target/arch/boot/x86_64/
#mv squashfs-root/boot/*-ucode.img target/arch/boot/
rm -f squashfs-root/boot/initramfs*
umount squashfs-root/aur
umount squashfs-root/var/cache/pacman/pkg
rmdir squashfs-root/aur
mv squashfs-root/opt/*.pkg.tar* squashfs-root/var/cache/pacman/pkg/
#umount squashfs-root/sys
#umount squashfs-root/dev
#umount squashfs-root/proc
mksquashfs squashfs-root target/arch/x86_64/airootfs.sfs -comp $COMP
umount mnt
_label_line=$(grep -m 1 -o 'archisolabel=ARCH_[0-9]*' target/syslinux/archiso_sys-linux.cfg)
iso_label=${_label_line/archisolabel=}
xorriso -as mkisofs \
-iso-level 3 \
-full-iso9660-filenames \
-volid "${iso_label}" \
-eltorito-boot syslinux/isolinux.bin \
-eltorito-catalog syslinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-isohybrid-mbr target/syslinux/isohdpfx.bin \
-output "gloriousarch-${DESKTOP}.iso" \
target/
echo "gloriousarch.iso is at ${WORKDIR}/gloriousarch-${DESKTOP}.iso"
printf 'clean up...'
rm -rf squashfs-root target
echo 'done'