forked from hanwckf/build-catdrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-alpine.sh
executable file
·57 lines (46 loc) · 1.36 KB
/
build-alpine.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
#!/bin/bash
[ "$EUID" != "0" ] && echo "please run as root" && exit 1
set -e
set -o pipefail
os="alpine"
rootsize=700
origin="minirootfs"
target="catdrive"
tmpdir="tmp"
output="output"
rootfs_mount_point="/mnt/${os}_rootfs"
qemu_static="./tools/qemu/qemu-aarch64-static"
cur_dir=$(pwd)
DTB=armada-3720-catdrive.dtb
chroot_prepare() {
if [ -z "$TRAVIS" ]; then
sed -i 's#http://dl-cdn.alpinelinux.org#https://mirrors.tuna.tsinghua.edu.cn#' $rootfs_mount_point/etc/apk/repositories
echo "nameserver 119.29.29.29" > $rootfs_mount_point/etc/resolv.conf
else
echo "nameserver 8.8.8.8" > $rootfs_mount_point/etc/resolv.conf
fi
}
ext_init_param() {
if [ "$BUILD_RESCUE" = "y" ]; then
echo "BUILD_RESCUE=y"
fi
}
chroot_post() {
if [ -n "$TRAVIS" ]; then
sed -i 's#http://dl-cdn.alpinelinux.org#https://mirrors.tuna.tsinghua.edu.cn#' $rootfs_mount_point/etc/apk/repositories
fi
}
add_resizemmc() {
if [ "$BUILD_RESCUE" != "y" ]; then
echo "add resize mmc script"
cp ./tools/${os}/resizemmc.sh $rootfs_mount_point/sbin/resizemmc.sh
cp ./tools/${os}/resizemmc $rootfs_mount_point/etc/init.d/resizemmc
ln -sf /etc/init.d/resizemmc $rootfs_mount_point/etc/runlevels/default/resizemmc
touch $rootfs_mount_point/root/.need_resize
fi
}
gen_new_name() {
local rootfs=$1
echo "`basename $rootfs | sed "s/${origin}/${target}/" | sed 's/.tar.gz$//'`"
}
source ./common.sh