-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·91 lines (78 loc) · 2.45 KB
/
build.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
#!/bin/bash
# shellcheck disable=SC2034
#############################################################
# ATUI build script #
#############################################################
# Archiso variables
iso_name="atui"
iso_version="0.0.1"
iso_label="ATUIISO_001"
iso_publisher="ATUI <https://github.com/PandaFoss/ATUI>"
install_dir="arch"
bootmodes="('bios.syslinux.mbr' 'bios.syslinux.eltorito' 'uefi-x64.systemd-boot.esp' 'uefi-x64.systemd-boot.eltorito')"
arch="x86_64"
pacman_conf="pacman.conf"
# ATUI specific variables
BUILD_DIR="$(pwd)/atui_build"
ARCHISO_DIR="/usr/share/archiso/configs/releng"
# Check root permission
check_root() {
if [ "$(id -u)" -ne 0 ]; then
echo "Please run as root"
exit
fi
}
# Check if archiso is installed
check_archiso() {
if ! sudo pacman -Qqs '^archiso$' >/dev/null \
|| ! sudo pacman -Qqs '^mkinitcpio-archiso$' >/dev/null; then
printf "archiso or mkinitcpio-archiso was not found.\n"
printf "Do you want to install it? [Y/n] "
read -r answer
if [ "${answer}" != "${answer#[Yy]}" ] ;then
sudo pacman -Syy archiso mkinitcpio-archiso --needed
else
echo "archiso and mkinitcpio-archiso are required. Please install it before continuing."
exit 1
fi
exit
fi
}
create_build_dir() {
# Create temporary directory if not exists
[ -d "${BUILD_DIR}" ] || mkdir "${BUILD_DIR}"
# Copy archiso files to tmp dir
sudo cp -r "${ARCHISO_DIR}"/* "${BUILD_DIR}"
# Copy ATUI files to tmp dir
sudo cp -Tr "$(pwd)/src/airootfs/root" "${BUILD_DIR}/airootfs/root"
# Add ATUI packages
cat "$(pwd)/atui-packages.x86_64" >> "${BUILD_DIR}/packages.x86_64"
sort --unique --output="${BUILD_DIR}/packages.x86_64" "${BUILD_DIR}/packages.x86_64"
}
# Generate profiledef.sh file
profiledef_gen() {
[ ! -f "${BUILD_DIR}"/profiledef.sh ] || rm "${BUILD_DIR}/profiledef.sh"
touch "${BUILD_DIR}/profiledef.sh"
cat << EOF > "${BUILD_DIR}/profiledef.sh"
iso_name="${iso_name}"
iso_version="${iso_version}"
iso_label="${iso_label}"
iso_publisher="${iso_publisher}"
install_dir="${install_dir}"
bootmodes=${bootmodes}
arch="${arch}"
pacman_conf="${pacman_conf}"
EOF
}
# Generate ISO image
geniso() {
sudo mkarchiso -v "${BUILD_DIR}" command_iso
}
main() {
check_root
check_archiso
create_build_dir
profiledef_gen
geniso
}
main