forked from hanwckf/build-imou-sn1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-debian.sh
executable file
·68 lines (55 loc) · 2.25 KB
/
build-debian.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
#!/bin/bash
# note: rootfs is mount point
[ "$EUID" != "0" ] && echo "please run as root" && exit 1
set -e
set -o pipefail
os="debian"
os_ver=${debian_ver:-"buster"}
rootsize=1000
source cfg.inc
chroot_prepare() {
if [ -z "$TRAVIS" ]; then
echo "deb https://mirrors.huaweicloud.com/debian/ ${os_ver} main contrib non-free" > $rootfs_mount_point/etc/apt/sources.list
echo "nameserver 119.29.29.29" > $rootfs_mount_point/etc/resolv.conf
else
echo "deb http://httpredir.debian.org/debian/ ${os_ver} main contrib non-free" > $rootfs_mount_point/etc/apt/sources.list
echo "nameserver 8.8.8.8" > $rootfs_mount_point/etc/resolv.conf
fi
}
ext_init_param() {
:
}
chroot_post() {
rm -f $rootfs_mount_point/etc/resolv.conf
cat <<-EOF > $rootfs_mount_point/etc/apt/sources.list
deb https://mirrors.huaweicloud.com/debian/ ${os_ver} main contrib non-free
deb https://mirrors.huaweicloud.com/debian/ ${os_ver}-updates main contrib non-free
deb https://mirrors.huaweicloud.com/debian-security ${os_ver}/updates main contrib non-free
deb https://mirrors.huaweicloud.com/debian/ ${os_ver}-backports main contrib non-free
EOF
}
generate_rootfs() {
local rootfs=$1
mirrorurl="https://mirrors.huaweicloud.com/debian"
if [ -n "$TRAVIS" ]; then
mirrorurl="http://httpredir.debian.org/debian"
fi
echo "generate debian rootfs to $rootfs by debootstrap..."
debootstrap --components=main,contrib,non-free --no-check-certificate --no-check-gpg \
--include=apt-utils --arch=arm64 --variant=minbase --foreign --verbose $os_ver $rootfs $mirrorurl
}
add_services() {
mkdir -p $rootfs_mount_point/etc/systemd/system/basic.target.wants
echo "add resize mmc script"
cp ./tools/systemd/resizemmc.service $rootfs_mount_point/lib/systemd/system/
cp ./tools/systemd/resizemmc.sh $rootfs_mount_point/sbin/
ln -sf /lib/systemd/system/resizemmc.service $rootfs_mount_point/etc/systemd/system/basic.target.wants/resizemmc.service
touch $rootfs_mount_point/root/.need_resize
echo "add sshd keygen service"
cp ./tools/systemd/sshdgenkeys.service $rootfs_mount_point/lib/systemd/system/
ln -sf /lib/systemd/system/sshdgenkeys.service $rootfs_mount_point/etc/systemd/system/basic.target.wants/sshdgenkeys.service
}
gen_new_name() {
echo "$os-$os_ver-$device_name-`date +%Y-%m-%d`"
}
source ./common.sh