Skip to content

Commit 1c3e786

Browse files
author
Patrick Yavitz
committed
Debian Image Builder
The builder now creates a profile.txt file, which `make config` will read as your default choices. `nano profile.txt` and uncomment and edit what applies to you. Profile: 1.0 Builder: 6.1 Signed-off-by: Patrick Yavitz <[email protected]>
1 parent 0ac66f3 commit 1c3e786

File tree

5 files changed

+111
-76
lines changed

5 files changed

+111
-76
lines changed

lib/dialog/config

+34-63
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
#!/bin/bash
22

3-
# builder version
4-
BUILDER="6.0"
3+
source lib/function/config
4+
# builder and profile versions
5+
BUILDER="6.1"
6+
PROFILE="1.0"
57

6-
# script
8+
# depends
9+
if [[ `command -v curl` ]]; then :; else sudo apt install curl; fi
710
if [[ `curl -I https://github.com 2>&1 | grep 'HTTP/2 200'` ]]; then
811
:;
912
else
1013
echo -e "The builder requires a internet connection."
11-
exit 0;
14+
exit 0
1215
fi
16+
17+
# dynamic variables
1318
URL="https://kernel.org"
1419
LTS1=$(curl -s $URL | grep -A1 longterm: -n1 | egrep -o '>[^<]+' | egrep -o '[^>]+' | grep -w "5.15")
1520
LTS2=$(curl -s $URL | grep -A1 longterm: -n1 | egrep -o '>[^<]+' | egrep -o '[^>]+' | grep -w "6.1")
@@ -19,6 +24,7 @@ STABLE=$(curl -s $URL/releases.json | jq '.latest_stable.version' -r)
1924
GCC=`ls -ls /usr/bin/gcc | sed 's/.*\(..\)/\1/' | sed 's/ //g'`
2025
MYNAME=`echo $USER | sed -e "s/\b\(.\)/\u\1/g"`
2126

27+
# userdata dot txt
2228
NAME="$MYNAME"
2329
USERNAME="$USER"
2430
PASSWORD="board"
@@ -30,12 +36,17 @@ RTL88XXAU="1"
3036
USERACCT="0"
3137
USER_PKGS="htop libsensors-dev"
3238
LOCALE="en_US.UTF-8"
39+
LOCALE_LC_ALL="C.UTF-8"
3340
TIMEZONE="America/New_York"
34-
USER_NAMESERVER1="8.8.8.8"
35-
USER_NAMESERVER2="8.8.4.4"
41+
NAMESERVER1="8.8.8.8"
42+
NAMESERVER2="8.8.4.4"
43+
# profile dot txt
3644
if [[ -f "profile.txt" ]]; then
37-
# source user profile
3845
. profile.txt
46+
if [[ -n "$USER_PROFILE" ]]; then :; else rm -f profile.txt; fi
47+
if [[ "$PROFILE" == "$USER_PROFILE" ]]; then :; else profile_txt; fi
48+
else
49+
profile_txt
3950
fi
4051
HOSTNAME="default"
4152
DISTRO="debian"
@@ -48,14 +59,13 @@ CUSTOM_DEFCONFIG="0"
4859
MYCONFIG=""
4960
LOGGING="0"
5061
VERBOSE="0"
51-
DEVROOTFS="1"
5262
COMPRESS_IMG="0"
5363
USCRIPTS="0"
5464

5565
# open fd
5666
exec 3>&1
5767

58-
# Store data to $VALUES variable
68+
# store data to $VALUES variable
5969
VALUES=$(dialog --ok-label "Submit" --no-cancel \
6070
--backtitle "DEBIAN IMAGE BUILDER: CONFIG MENU" \
6171
--title "" --form "" 0 40 0 \
@@ -83,10 +93,9 @@ VALUES=$(dialog --ok-label "Submit" --no-cancel \
8393
" User Options" 22 1 "" 22 14 0 0 \
8494
" Logging:" 23 1 "$LOGGING" 23 11 3 0 \
8595
" Verbosity:" 24 1 "$VERBOSE" 24 13 3 0 \
86-
" Devel Rootfs:" 25 1 "$DEVROOTFS" 25 16 3 0 \
87-
" Compress img:" 26 1 "$COMPRESS_IMG" 26 16 3 0 \
88-
" User scripts:" 27 1 "$USCRIPTS" 27 16 3 0 \
89-
" User service:" 28 1 "$USERACCT" 28 16 3 0 \
96+
" Compress img:" 25 1 "$COMPRESS_IMG" 25 16 3 0 \
97+
" User scripts:" 26 1 "$USCRIPTS" 26 16 3 0 \
98+
" User service:" 27 1 "$USERACCT" 27 16 3 0 \
9099
2>&1 1>&3)
91100

92101
# close fd
@@ -111,10 +120,10 @@ echo CUSTOM_DEFCONFIG= >> tmp0
111120
echo MYCONFIG='"' >> tmp0
112121
echo LOGGING= >> tmp0
113122
echo VERBOSE= >> tmp0
114-
echo DEVROOTFS= >> tmp0
115123
echo COMPRESS_IMG= >> tmp0
116124
echo USCRIPTS= >> tmp0
117125
echo USERACCT= >> tmp0
126+
echo 'DEVROOTFS="1"' >> tmp0
118127
echo 'EMMC="0"' >> tmp0
119128
echo 'ROOTPASSWD="0"' >> tmp0
120129
echo USER_PKGS='"'${USER_PKGS}'"' >> tmp0
@@ -124,20 +133,12 @@ echo 'KBUSER="playboy"' >> tmp0
124133
echo 'KBHOST="penguin"' >> tmp0
125134
echo "RTW88=${RTW88}" >> tmp0
126135
echo "RTL88XXAU=${RTL88XXAU}" >> tmp0
127-
echo "set_locales(){" >> tmp0
128-
echo "apt install -y locales" >> tmp0
129-
echo "export LANGUAGE=${LOCALE}" >> tmp0
130-
echo "export LANG=${LOCALE}" >> tmp0
131-
echo "export LC_ALL=C.UTF-8" >> tmp0
132-
echo "locale-gen ${LOCALE}" >> tmp0
133-
echo "}" >> tmp0
134-
echo "set_timezone(){" >> tmp0
135-
echo "ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime" >> tmp0
136-
echo "echo -n '${TIMEZONE}' > /etc/timezone" >> tmp0
137-
echo "}" >> tmp0
138-
echo NAMESERVER1='"'${USER_NAMESERVER1}'"' >> tmp0
139-
echo NAMESERVER2='"'${USER_NAMESERVER2}'"' >> tmp0
140-
echo builder=${BUILDER} >> tmp0
136+
echo LOCALE='"'${LOCALE}'"' >> tmp0
137+
echo LOCALE_LC_ALL='"'${LOCALE_LC_ALL}'"' >> tmp0
138+
echo TIMEZONE='"'${TIMEZONE}'"' >> tmp0
139+
echo NAMESERVER1='"'${NAMESERVER1}'"' >> tmp0
140+
echo NAMESERVER2='"'${NAMESERVER2}'"' >> tmp0
141+
echo BUILDER=${BUILDER} >> tmp0
141142
echo '"' > tmp2
142143
echo '"' >> tmp2
143144
echo '"' >> tmp2
@@ -164,43 +165,13 @@ sed -i '17i### CUSTOM' userdata.txt
164165
sed -i '29i### COMPILER TUNING' userdata.txt
165166
sed -i '32i### WHOAMI AND HOST' userdata.txt
166167
sed -i '35i### EXTRA WIRELESS' userdata.txt
167-
sed -i '38i### LOCALES' userdata.txt
168-
sed -i '46i### TIMEZONE' userdata.txt
169-
sed -i '51i### NAME SERVER' userdata.txt
170-
sed -i '54i### DO NOT EDIT BELOW THIS LINE' userdata.txt
168+
sed -i '38i### LOCALES TIMEZONE AND NAMESERVERS' userdata.txt
169+
sed -i '44i### DO NOT EDIT BELOW THIS LINE' userdata.txt
171170

172-
# customize your image
173-
custom_txt(){
174-
echo "# Boot Partition: true false" > custom.txt
175-
echo 'ENABLE_VFAT="false"' >> custom.txt
176-
echo "" >> custom.txt
177-
echo "# Root Filesystem Types: ext4 btrfs xfs" >> custom.txt
178-
echo 'FSTYPE="ext4"' >> custom.txt
179-
echo "" >> custom.txt
180-
echo "# UEFI Options: true false" >> custom.txt
181-
echo 'ENABLE_EFI="false"' >> custom.txt
182-
echo "" >> custom.txt
183-
echo "# Petitboot (ODROID): true false" >> custom.txt
184-
echo 'ENABLE_PETITBOOT="false"' >> custom.txt
185-
echo "" >> custom.txt
186-
echo "# Image Size: 3072MB 3584MB 4096MB" >> custom.txt
187-
echo 'IMGSIZE="4096MB"' >> custom.txt
188-
echo "" >> custom.txt
189-
echo "# Shrink Image (EXT4 Only): true false" >> custom.txt
190-
echo 'ENABLE_SHRINK="true"' >> custom.txt
191-
echo "" >> custom.txt
192-
echo "# Compression Types: xz zst" >> custom.txt
193-
echo 'IMG_COMPRESSION="xz"' >> custom.txt
194-
echo "" >> custom.txt
195-
echo "### DO NOT EDIT BELOW THIS LINE" >> custom.txt
196-
echo "# CUSTOM=${BUILDER}" >> custom.txt
197-
}
171+
# custom dot txt
198172
if [[ -f "custom.txt" ]]; then
199-
if [[ `grep -w "CUSTOM=${BUILDER}" "custom.txt"` ]]; then
200-
:;
201-
else
202-
custom_txt
203-
fi
173+
. custom.txt
174+
if [[ "$CUSTOM" == "${BUILDER}" ]]; then :; else custom_txt; fi
204175
else
205176
custom_txt
206177
fi

lib/function/config

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# customize your image
4+
custom_txt (){
5+
cat <<EOF > "custom.txt"
6+
# Boot Partition: true false
7+
ENABLE_VFAT="false"
8+
9+
# Root Filesystem Types: ext4 btrfs xfs
10+
FSTYPE="ext4"
11+
12+
# UEFI Options: true false
13+
ENABLE_EFI="false"
14+
15+
# Petitboot (ODROID): true false
16+
ENABLE_PETITBOOT="false"
17+
18+
# Image Size: 3072MB 3584MB 4096MB
19+
IMGSIZE="4096MB"
20+
21+
# Shrink Image (EXT4 Only): true false
22+
ENABLE_SHRINK="true"
23+
24+
# Compression Types: xz zst
25+
IMG_COMPRESSION="xz"
26+
27+
### DO NOT EDIT BELOW THIS LINE
28+
CUSTOM="$BUILDER"
29+
EOF
30+
}
31+
32+
profile_txt (){
33+
cat <<EOF > "profile.txt"
34+
# User data defaults
35+
#NAME="$MYNAME"
36+
#USERNAME="$USER"
37+
#PASSWORD="board"
38+
#VERSION="$LTS2"
39+
#CCACHE="$CCACHE"
40+
#NETWORKMANAGER="$NETWORKMANAGER"
41+
#RTW88="$RTW88"
42+
#RTL88XXAU="$RTL88XXAU"
43+
#USERACCT="$USERACCT"
44+
#USER_PKGS="$USER_PKGS"
45+
#LOCALE="$LOCALE"
46+
#LOCALE_LC_ALL="$LOCALE_LC_ALL"
47+
#TIMEZONE="$TIMEZONE"
48+
#NAMESERVER1="$NAMESERVER1"
49+
#NAMESERVER2="$NAMESERVER2"
50+
51+
### DO NOT EDIT BELOW THIS LINE
52+
USER_PROFILE="$PROFILE"
53+
EOF
54+
sed -i "s/^#VERSION=.*/#VERSION="'"$LTS2"'"/" profile.txt
55+
}

lib/source

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@ HOST_ARCH=`uname -m`
1616

1717
# validate
1818
validation(){
19-
BUILDER=`grep "builder=" "userdata.txt" | sed 's/builder=//g'`
20-
UD="userdata.txt"
21-
if [ -f "$UD" ]; then
19+
BUILDER=`grep "BUILDER=" "userdata.txt" | sed 's/BUILDER=//g'`
20+
if [[ -f "userdata.txt" ]]; then
2221
echo -e ""
2322
else
2423
echo -e ""
25-
echo -e "Create a $UD file"
24+
echo -e "Create a userdata.txt file"
2625
while [ true ]; do
2726
read -t 10 -n 1
2827
if [ $? = 0 ]; then exit 0; fi
2928
done
3029
fi
31-
if [[ "$BUILDER" == "6.0" ]]; then
30+
if [[ "$BUILDER" == "6.1" ]]; then
3231
:;
3332
else
34-
echo -e "The ${WHT}$UD${FIN} file has expired. Please create a new one."
33+
echo -e "The ${WHT}userdata.txt${FIN} file has expired. Please create a new one."
3534
exit 0
3635
fi
3736
}

scripts/rootfs-extra

+10-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ fi
2222
apt-get update
2323
apt-get install -y apt-utils
2424

25-
# Locales
26-
set_locales
27-
28-
# Timezone
29-
set_timezone
25+
# locales
26+
apt install -y locales
27+
export LANGUAGE=${LOCALE}
28+
export LANG=${LOCALE}
29+
export LC_ALL=${LOCALE_LC_ALL}
30+
locale-gen ${LOCALE}
31+
32+
# timezone
33+
ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
34+
echo -n "${TIMEZONE}" > /etc/timezone
3035

3136
apt upgrade -y
3237
apt dist-upgrade -y

scripts/stage2

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ apt-get update
4040
apt-get install -y apt-utils
4141

4242
# locales
43-
set_locales
43+
apt install -y locales
44+
export LANGUAGE=${LOCALE}
45+
export LANG=${LOCALE}
46+
export LC_ALL=${LOCALE_LC_ALL}
47+
locale-gen ${LOCALE}
4448

4549
# timezone
46-
set_timezone
50+
ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
51+
echo -n "${TIMEZONE}" > /etc/timezone
4752

4853
apt upgrade -y
4954
apt dist-upgrade -y

0 commit comments

Comments
 (0)