-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast.sh
73 lines (57 loc) · 2.03 KB
/
last.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
#!/bin/bash
# 脚本完整目录(绝对路径,/mnt/.../scripts)
SCRIPT_RealPath=$(readlink -f "${BASH_SOURCE[0]}")
SCRIPT_FullDir=$(dirname "$SCRIPT_RealPath")
OldCD="`pwd`"
# [main.conf]
# 自定义ISO
# NewISO="/mnt/custom/iso"
# 源ISO
# OldISO="/mnt/cd1"
# 脚本目录
# ScriptsDir="/mnt/custom/scripts"
# 输出目录
# OutDir="/mnt/custom/out"
# 加载配置文件
source main.conf
[ -f "${SCRIPT_FullDir}/ISO.conf" ] && source "${SCRIPT_FullDir}/ISO.conf"
# ------[更新元数据]---------------------------------------
cd "${NewISO}"
# 更新Packages
apt-ftparchive -c "${ScriptsDir}/apt.conf" generate "${ScriptsDir}/config_installer"
apt-ftparchive -c "${ScriptsDir}/apt.conf" generate "${ScriptsDir}/config_binary"
# 更新Release
# rm dists/bookworm/Release
# apt-ftparchive -c "${ScriptsDir}/apt.conf" release dists/bookworm > dists/bookworm/Release
rm dists/${DebianCode}/Release
apt-ftparchive -c "${ScriptsDir}/apt.conf" release dists/${DebianCode} > dists/${DebianCode}/Release
# 更新MD5
rm -f md5sum.txt
md5sum `find ! -name "md5sum.txt" ! -path "./isolinux/*" -follow -type f` > md5sum.txt
# ------[生成isohdpfx.bin]---------------------------------------
# dd if=/dev/sr0 bs=1 count=432 of=isohdpfx.bin
cd "${NewISO}"
FILE_isohdpfx="${ScriptsDir}/isohdpfx/${ISOINFO_Str}/isohdpfx.bin"
if [ ! -f "$FILE_isohdpfx" ]; then
# 文件不存在,生成isohdpfx.bin
mkdir -p "${ScriptsDir}/isohdpfx/${ISOINFO_Str}" 2>/dev/null
dd if="${ISOINFO_Device}" bs=1 count=432 of="$FILE_isohdpfx"
[ -f "$FILE_isohdpfx" ] && echo "[Gen] $FILE_isohdpfx"
fi
if [ ! -f "$FILE_isohdpfx" ]; then
echo "[File not exisit] $FILE_isohdpfx"
exit 1
fi
# ------[生成ISO]---------------------------------------
xorriso -as mkisofs -o "${OutDir}/new_debian.iso" \
-rock -J --joliet-long \
-V "Debian Custom" \
-c isolinux/boot.cat \
-b isolinux/isolinux.bin \
-no-emul-boot \
-boot-load-size 4 \
--iso-level 3 \
-boot-info-table \
-isohybrid-mbr "$FILE_isohdpfx" \
"${NewISO}"
cd ${OldCD}