mirror of
git://soft.sys114.com/odroid-stamper
synced 2025-12-19 01:48:42 +09:00
Add to OEM customizable partition layout
Signed-off-by: Dongjin Kim <tobetter@gmail.com> Change-Id: Ib07e525ef2ede94f4b7aaf9555b283c84de2b318
This commit is contained in:
7
custom/templates/oem/config
Normal file
7
custom/templates/oem/config
Normal file
@@ -0,0 +1,7 @@
|
||||
BOARD=odroidc4
|
||||
ARCH=arm64
|
||||
DISTRO=focal
|
||||
FLAVOUR=server
|
||||
DEFAULT_USER=odroid
|
||||
DEFAULT_PASSWD=odroid
|
||||
ALLOW_ROOT_LOGIN=false
|
||||
4
custom/templates/oem/fixups/S70-bootscript
Executable file
4
custom/templates/oem/fixups/S70-bootscript
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -r -i "s/#\s+(setenv console)/\1/" /usr/share/flash-kernel/ubootenv.d/upstream/10-console
|
||||
sed -r -i "s/quiet\s+//g" /etc/default/flash-kernel
|
||||
2
custom/templates/oem/hooks/mount
Normal file
2
custom/templates/oem/hooks/mount
Normal file
@@ -0,0 +1,2 @@
|
||||
oem_mount 5 var/app/oem
|
||||
oem_mount 6 var/lib/oem
|
||||
3
custom/templates/oem/hooks/partition
Normal file
3
custom/templates/oem/hooks/partition
Normal file
@@ -0,0 +1,3 @@
|
||||
oem_mkfs_ext4 5 app
|
||||
oem_mkfs_ext4 6 lib
|
||||
oem_mkfs_ext4 7 etc ${rootfs_mnt}/etc
|
||||
2
custom/templates/oem/hooks/umount
Normal file
2
custom/templates/oem/hooks/umount
Normal file
@@ -0,0 +1,2 @@
|
||||
oem_umount var/lib/oem
|
||||
oem_umount var/app/oem
|
||||
1
custom/templates/oem/overlay/var/app/oem/README
Normal file
1
custom/templates/oem/overlay/var/app/oem/README
Normal file
@@ -0,0 +1 @@
|
||||
This file is from /var/app/oem
|
||||
1
custom/templates/oem/overlay/var/lib/oem/README
Normal file
1
custom/templates/oem/overlay/var/lib/oem/README
Normal file
@@ -0,0 +1 @@
|
||||
This file is from /var/lib/oem
|
||||
1
custom/templates/oem/part5/README
Normal file
1
custom/templates/oem/part5/README
Normal file
@@ -0,0 +1 @@
|
||||
This file is from /var/app/oem
|
||||
1
custom/templates/oem/part6/README
Normal file
1
custom/templates/oem/part6/README
Normal file
@@ -0,0 +1 @@
|
||||
This file is from /var/lib/oem
|
||||
4
custom/templates/oem/partitions
Normal file
4
custom/templates/oem/partitions
Normal file
@@ -0,0 +1,4 @@
|
||||
TOTAL_SECTORS=15523840
|
||||
PART[0]=500
|
||||
PART[1]=500
|
||||
PART[2]=50
|
||||
24
fdiskcmd.sh
Executable file
24
fdiskcmd.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
[ -f "${1}" ] || exit 0
|
||||
. ${1}
|
||||
|
||||
do_fdisk_commands() {
|
||||
|
||||
TOTAL=0
|
||||
for (( p = 0 ; p < ${#PART[@]} ; p++ )); do
|
||||
TOTAL=$((${TOTAL} + ${PART[p]} * 1024 * 1024 / 512))
|
||||
done
|
||||
EXT_START=$((${TOTAL_SECTORS} - ${TOTAL}))
|
||||
|
||||
CMD="n\ne\n3\n${EXT_START}\n\n"
|
||||
for (( p = 0 ; p < ${#PART[@]} - 1 ; p++ )); do
|
||||
CMD="${CMD}n\nl\n\n+${PART[p]}M\n"
|
||||
done
|
||||
CMD="${CMD}n\nl\n\n\nw\n"
|
||||
|
||||
echo ${CMD}
|
||||
}
|
||||
|
||||
cmd=$(do_fdisk_commands ${1})
|
||||
echo ${cmd}
|
||||
68
functions
68
functions
@@ -11,6 +11,10 @@ do_unmount() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/hooks/umount ]; then
|
||||
. ${TOPDIR}/custom/${CUSTOMOS}/hooks/umount
|
||||
fi
|
||||
|
||||
umount -f ${rootfs_mnt}/sys 2>/dev/null
|
||||
umount -f ${rootfs_mnt}/proc 2>/dev/null
|
||||
umount -f ${rootfs_mnt}/dev/pts 2>/dev/null
|
||||
@@ -20,6 +24,11 @@ do_unmount() {
|
||||
|
||||
cleanup() {
|
||||
do_unmount
|
||||
|
||||
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/hooks/umount ]; then
|
||||
. ${TOPDIR}/custom/${CUSTOMOS}/hooks/umount
|
||||
fi
|
||||
|
||||
umount -f ${boot_mnt} ${rootfs_mnt} 2>/dev/null
|
||||
rm -rf ${boot_mnt} ${rootfs_mnt}
|
||||
}
|
||||
@@ -77,6 +86,14 @@ get_part_root() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_part_ext() {
|
||||
if [ ! -b ${TARGET_DEVICE} ]; then
|
||||
echo "${LOOPBACK}p${1}"
|
||||
else
|
||||
echo "${TARGET_DEVICE}-part${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
get_kernel_cmdline_defaults() {
|
||||
echo ""
|
||||
}
|
||||
@@ -104,6 +121,33 @@ get_lookback_device() {
|
||||
echo `losetup -a | grep ${1} | cut -d':' -f1`
|
||||
}
|
||||
|
||||
oem_mount() {
|
||||
local src=${TOPDIR}/custom/${CUSTOMOS}/part${1}
|
||||
local dst=${rootfs_mnt}/${2}
|
||||
|
||||
mkdir -p ${src}
|
||||
mkdir -p ${dst}
|
||||
mount -o bind ${src} ${dst}
|
||||
}
|
||||
|
||||
oem_umount() {
|
||||
umount -f ${rootfs_mnt}/${1} 2>/dev/null
|
||||
}
|
||||
|
||||
oem_mkfs_ext4() {
|
||||
local src=${3}
|
||||
local part=$(get_part_ext ${1})
|
||||
local label=""
|
||||
|
||||
[ "x${2}" = "x" ] || label="-L ${2}"
|
||||
[ "x${src}" = "x" ] && src=${TOPDIR}/custom/oem/part${1}
|
||||
|
||||
if [ -d ${src} ]; then
|
||||
sudo mkfs.ext4 -F ${label} -d ${src} ${part} 2>/dev/null \
|
||||
|| panic "failed to create partition '${part}'"
|
||||
fi
|
||||
}
|
||||
|
||||
do_mount() {
|
||||
echo "I: mounting to ${rootfs_mnt}"
|
||||
|
||||
@@ -118,6 +162,10 @@ do_mount() {
|
||||
mount -o bind /dev/pts ${rootfs_mnt}/dev/pts
|
||||
mount -o bind /proc ${rootfs_mnt}/proc
|
||||
mount -o bind /sys ${rootfs_mnt}/sys
|
||||
|
||||
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/hooks/mount ]; then
|
||||
. ${TOPDIR}/custom/${CUSTOMOS}/hooks/mount
|
||||
fi
|
||||
}
|
||||
|
||||
get_uuid_by_path() {
|
||||
@@ -177,6 +225,11 @@ do_create_partition() {
|
||||
local blocks=$((${boot_pstart} + ${boot_blk} + ${root_blk} + 81920 * 4))
|
||||
local boot_pend=$((${boot_pstart} + ${boot_blk}))
|
||||
|
||||
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/partitions ]; then
|
||||
. ${TOPDIR}/custom/${CUSTOMOS}/partitions
|
||||
blocks=${TOTAL_SECTORS}
|
||||
fi
|
||||
|
||||
if [ ! -b ${disk} ]; then
|
||||
echo "I: creating the disk image file '${disk}' ($((${blocks} * 512))KiB)"
|
||||
dd if=/dev/zero bs=512 count=${blocks} \
|
||||
@@ -194,6 +247,12 @@ do_create_partition() {
|
||||
[ "${BASH_VERSION}" = "" ] || BACKSLASH_ESCAPE="-e"
|
||||
|
||||
echo "I: creating a partition table to '${disk}'"
|
||||
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/partitions ]; then
|
||||
echo ${BACKSLASH_ESCAPE} \
|
||||
$(${TOPDIR}/fdiskcmd.sh ${TOPDIR}/custom/${CUSTOMOS}/partitions) \
|
||||
| fdisk ${disk} >/dev/null
|
||||
fi
|
||||
|
||||
echo ${BACKSLASH_ESCAPE} \
|
||||
"n\np\n\n${boot_pstart}\n${boot_pend}\n" \
|
||||
"n\np\n\n$((${boot_pend} + 1))\n\n" \
|
||||
@@ -206,6 +265,10 @@ do_create_partition() {
|
||||
echo ${LOOPBACK}
|
||||
fi
|
||||
|
||||
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/hooks/partition ]; then
|
||||
. ${TOPDIR}/custom/${CUSTOMOS}/hooks/partition
|
||||
fi
|
||||
|
||||
UUID_BOOT=$(get_uuid_by_path "/boot")
|
||||
UUID_ROOT=$(get_uuid_by_path "/")
|
||||
|
||||
@@ -236,7 +299,8 @@ do_preinstall() {
|
||||
|
||||
[ -d ${TOPDIR}/fixups ] && rsync -a ${TOPDIR}/fixups/* ${rootfs_mnt}/${fixups_dir}
|
||||
[ -d ${WORKDIR}/fixups ] && rsync -a ${WORKDIR}/fixups/* ${rootfs_mnt}/${fixups_dir}
|
||||
[ -d custom/${CUSTOMOS}/fixups ] && rsync -a custom/${CUSTOMOS}/fixups/* ${rootfs_mnt}/${fixups_dir}
|
||||
[ -d ${TOPDIR}/custom/${CUSTOMOS}/fixups ] \
|
||||
&& rsync -a ${TOPDIR}/custom/${CUSTOMOS}/fixups/* ${rootfs_mnt}/${fixups_dir}
|
||||
|
||||
FIXUPS=`ls -A1 ${rootfs_mnt}${fixups_dir}/*`
|
||||
for fixup in ${FIXUPS}; do
|
||||
@@ -271,6 +335,8 @@ do_preinstall() {
|
||||
|
||||
[ -d ${TOPDIR}/overlay ] && rsync -a ${TOPDIR}/overlay/* ${rootfs_mnt}/
|
||||
[ -d ${WORKDIR}/overlay ] && rsync -a ${WORKDIR}/overlay/* ${rootfs_mnt}/
|
||||
[ -d ${TOPDIR}/custom/${CUSTOMOS}/overlay ] \
|
||||
&& rsync -a ${TOPDIR}/custom/${CUSTOMOS}/overlay/* ${rootfs_mnt}/
|
||||
}
|
||||
|
||||
do_postinstall() {
|
||||
|
||||
Reference in New Issue
Block a user