@@ -18,13 +18,12 @@ if [ ! -b "$PINE64_SD" ]; then
18
18
fi
19
19
20
20
resources_path=" ${SKIFF_CURRENT_CONF_DIR} /resources"
21
- outp_path=" ${BUILDROOT_DIR} /output"
22
- images_path=" ${outp_path} /images"
21
+ IMAGES_DIR=${BUILDROOT_DIR} /images
23
22
24
- img_path=" ${images_path } /Image"
25
- zimg_path=" ${images_path } /zImage"
26
- uinit_path=" ${images_path } /rootfs.cpio.uboot"
27
- dtb_path=$( find ${images_path } / -name ' *.dtb' -print -quit)
23
+ img_path=" ${IMAGES_DIR } /Image"
24
+ zimg_path=" ${IMAGES_DIR } /zImage"
25
+ uinit_path=" ${IMAGES_DIR } /rootfs.cpio.uboot"
26
+ dtb_path=$( find ${IMAGES_DIR } / -name ' *.dtb' -print -quit)
28
27
29
28
source ${SKIFF_CURRENT_CONF_DIR} /scripts/determine_config.sh
30
29
58
57
}
59
58
trap cleanup EXIT
60
59
61
- boot_dir=" ${WORK_DIR} /boot"
62
- rootfs_dir=" ${WORK_DIR} /rootfs"
63
- persist_dir=" ${WORK_DIR} /persist"
64
-
65
60
PINE64_SD_SFX=$PINE64_SD
66
61
if [ -b ${PINE64_SD} p1 ]; then
67
- PINE64_SD_SFX=${PINE64_SD} p
62
+ PINE64_SD_SFX=${PINE64_SD} p
68
63
fi
69
64
70
- mkdir -p $boot_dir
71
- echo " Mounting ${PINE64_SD_SFX} 1 to $boot_dir ..."
72
- mounts+=(" $boot_dir " )
73
- mount ${PINE64_SD_SFX} 1 $boot_dir
74
-
75
- echo " Mounting ${PINE64_SD_SFX} 2 to $rootfs_dir ..."
76
- mkdir -p $rootfs_dir
77
- mounts+=(" $rootfs_dir " )
78
- mount ${PINE64_SD_SFX} 2 $rootfs_dir
79
-
80
- echo " Mounting ${PINE64_SD_SFX} 3 to $persist_dir ..."
81
- mkdir -p $persist_dir
82
- mounts+=(" $persist_dir " )
83
- mount ${PINE64_SD_SFX} 3 $persist_dir
84
-
85
- echo " Copying kernel image..."
86
- sync
87
- rsync -rav --no-perms --no-owner --no-group $img_path $boot_dir /
88
- sync
89
-
90
- echo " Copying uInitrd..."
91
- rsync -rav --no-perms --no-owner --no-group $uinit_path $boot_dir /rootfs.cpio.uboot
92
- sync
93
-
94
- if [ -d " $outp_path /images/rootfs_part" ]; then
95
- echo " Copying rootfs_part..."
96
- rsync -rav --no-perms --no-owner --no-group $outp_path /images/rootfs_part/ $rootfs_dir /
97
- sync
98
- fi
65
+ mount_persist_dir=" ${WORK_DIR} /persist"
66
+ BOOT_DIR=${mount_persist_dir} /boot
67
+ ROOTFS_DIR=${mount_persist_dir} /rootfs
68
+ PERSIST_DIR=${mount_persist_dir} /
69
+
70
+ echo " Mounting ${PINE64_SD_SFX} 1 to $mount_persist_dir ..."
71
+ mkdir -p $mount_persist_dir
72
+ mounts+=(" $mount_persist_dir " )
73
+ sudo mount ${PINE64_SD_SFX} 1 $mount_persist_dir
99
74
100
- if [ -d " $outp_path /images/persist_part" ]; then
101
- echo " Copying persist_part..."
102
- rsync -rav --no-perms --no-owner --no-group $outp_path /images/persist_part/ $persist_dir /
103
- sync
75
+ echo " Copying files..."
76
+
77
+ cd ${IMAGES_DIR}
78
+ mkdir -p ${BOOT_DIR} /skiff-init ${ROOTFS_DIR} /
79
+ if [ -d ${IMAGES_DIR} /rootfs_part/ ]; then
80
+ rsync -rav ${IMAGES_DIR} /rootfs_part/ ${ROOTFS_DIR} /
81
+ fi
82
+ if [ -d ${IMAGES_DIR} /persist_part/ ]; then
83
+ rsync -rav ${IMAGES_DIR} /persist_part/ ${PERSIST_DIR} /
84
+ fi
85
+ if [ -f ${SKIFF_CURRENT_CONF_DIR} /resources/resize2fs.conf ]; then
86
+ cp -v ${SKIFF_CURRENT_CONF_DIR} /resources/resize2fs.conf ./skiff-init/resize2fs.conf
87
+ fi
88
+ rsync -rv ./skiff-init/ ${BOOT_DIR} /skiff-init/
89
+ rsync -rv \
90
+ ./* .dtb ./Image \
91
+ ./skiff-release ./rootfs.squashfs \
92
+ ${BOOT_DIR} /
93
+
94
+ if [ -z " $DISABLE_CREATE_SWAPFILE " ]; then
95
+ PERSIST_SWAP=${PERSIST_DIR} /primary.swap
96
+ if [ ! -f ${PERSIST_SWAP} ]; then
97
+ echo " Pre-allocating 2GB swapfile with zeros (ignoring errors)..."
98
+ dd if=/dev/zero of=${PERSIST_SWAP} bs=1M count=2000 || true
99
+ else
100
+ echo " Swapfile already exists, skipping allocation step."
101
+ fi
104
102
fi
105
103
106
104
enable_silent () {
107
- if [ -f " $images_path /.disable-serial-console" ]; then
105
+ if [ -f " $IMAGES_DIR /.disable-serial-console" ]; then
108
106
echo " Disabling serial console and enabling silent mode..."
109
107
sed -i -e " /^setenv condev/s/^/# /" -e " s/# setenv silent/setenv silent/" $1
110
108
fi
111
109
}
112
110
113
111
if [ -n " $boot_conf_extlinux " ]; then
114
- mkdir -p $boot_dir /boot/extlinux/
115
- cp $boot_conf_extlinux $boot_dir /boot/extlinux/extlinux.conf
112
+ mkdir -p $BOOT_DIR /boot/extlinux/
113
+ cp -v $boot_conf_extlinux $BOOT_DIR /boot/extlinux/extlinux.conf
116
114
else
117
115
echo " Compiling boot.txt..."
118
- cp $boot_conf $boot_dir /boot.txt
119
- enable_silent $boot_dir /boot.txt
120
- mkimage -A arm -C none -T script -n ' SkiffOS' -d $boot_dir /boot.txt $boot_dir /boot.scr
116
+ cp $boot_conf $BOOT_DIR /boot.txt
117
+ enable_silent $BOOT_DIR /boot.txt
118
+ mkimage -A arm -C none -T script -n ' SkiffOS' -d $BOOT_DIR /boot.txt $BOOT_DIR /boot.scr
121
119
fi
122
- sync
123
-
124
- echo " Copying device tree..."
125
- rsync -rav --no-perms --no-owner --no-group ${images_path} /* .dtb $boot_dir /
126
- sync
127
-
128
- cleanup
0 commit comments