mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 21:26:49 +00:00
*bootloader/image: use mktemp. cleanup
This commit is contained in:
parent
5caa20bd43
commit
f2966ccbce
@ -23,16 +23,17 @@
|
|||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
echo "image: cleanup..."
|
echo "image: cleanup..."
|
||||||
umount /tmp/oe_image_install &>/dev/null || :
|
umount "$OE_TMP" &>/dev/null || :
|
||||||
losetup -d "$LOOP"
|
losetup -d "$LOOP"
|
||||||
[ -f /tmp/oe_image_install/ldlinux.sys ] && chattr -i /tmp/oe_image_install/ldlinux.sys || :
|
[ -f "$OE_TMP/ldlinux.sys" ] && chattr -i "$OE_TMP/ldlinux.sys" || :
|
||||||
rm -rf /tmp/oe_image_install
|
rm -rf "$OE_TMP"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup SIGINT
|
trap cleanup SIGINT
|
||||||
|
|
||||||
# set variables
|
# set variables
|
||||||
|
OE_TMP=$(mktemp -d)
|
||||||
SYSTEM_SIZE=128
|
SYSTEM_SIZE=128
|
||||||
# 3STORAGE_SIZE must be >= 32 !
|
# 3STORAGE_SIZE must be >= 32 !
|
||||||
STORAGE_SIZE=32
|
STORAGE_SIZE=32
|
||||||
@ -41,19 +42,17 @@ trap cleanup SIGINT
|
|||||||
LOOP=$(losetup -f)
|
LOOP=$(losetup -f)
|
||||||
|
|
||||||
# ensure loopX not in use
|
# ensure loopX not in use
|
||||||
echo "image: next two errors can be ignored..."
|
umount "$OE_TMP" &>/dev/null || :
|
||||||
umount /tmp/oe_image_install >/dev/null || :
|
|
||||||
umount "$LOOP" &>/dev/null >/dev/null || :
|
umount "$LOOP" &>/dev/null >/dev/null || :
|
||||||
losetup -d "$LOOP" &>/dev/null >/dev/null || :
|
losetup -d "$LOOP" &>/dev/null >/dev/null || :
|
||||||
rm -rf /tmp/oe_image_install &>/dev/null
|
|
||||||
|
|
||||||
# create an image
|
# create an image
|
||||||
echo "image: creating new image: $DISK..."
|
echo "image: creating image: $DISK..."
|
||||||
dd if=/dev/zero of="$DISK" bs=1M count="$DISK_SIZE"
|
dd if=/dev/zero of="$DISK" bs=1M count="$DISK_SIZE"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# write a disklabel
|
# write a disklabel
|
||||||
echo "image: creating partition table: $DISK..."
|
echo "image: creating partition table on $DISK..."
|
||||||
losetup "$LOOP" "$DISK"
|
losetup "$LOOP" "$DISK"
|
||||||
parted -s "$LOOP" mklabel msdos
|
parted -s "$LOOP" mklabel msdos
|
||||||
sync
|
sync
|
||||||
@ -80,23 +79,22 @@ trap cleanup SIGINT
|
|||||||
sync
|
sync
|
||||||
|
|
||||||
# mount partition
|
# mount partition
|
||||||
echo "image: mounting part1 on /tmp/oe_image_install..."
|
echo "image: mounting part1 on $OE_TMP..."
|
||||||
mkdir -p /tmp/oe_image_install
|
mount "$LOOP" "$OE_TMP"
|
||||||
mount "$LOOP" /tmp/oe_image_install
|
|
||||||
|
|
||||||
# create bootloader configuration
|
# create bootloader configuration
|
||||||
echo "image: creating bootloader configuration..."
|
echo "image: creating bootloader configuration..."
|
||||||
cat >/tmp/oe_image_install/cmdline.txt << EOF
|
cat >"$OE_TMP/cmdline.txt" << EOF
|
||||||
boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet
|
boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# copy files
|
# copy files
|
||||||
echo "image: copying files to part1..."
|
echo "image: copying files to part1..."
|
||||||
cp $RELEASE_DIR/3rdparty/bootloader/bootcode.bin /tmp/oe_image_install
|
cp $RELEASE_DIR/3rdparty/bootloader/bootcode.bin "$OE_TMP"
|
||||||
cp $RELEASE_DIR/3rdparty/bootloader/fixup.dat /tmp/oe_image_install
|
cp $RELEASE_DIR/3rdparty/bootloader/fixup.dat "$OE_TMP"
|
||||||
cp $RELEASE_DIR/3rdparty/bootloader/start.elf /tmp/oe_image_install
|
cp $RELEASE_DIR/3rdparty/bootloader/start.elf "$OE_TMP"
|
||||||
cp $TARGET_IMG/$IMAGE_NAME.kernel /tmp/oe_image_install/kernel.img
|
cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/kernel.img"
|
||||||
cp $TARGET_IMG/$IMAGE_NAME.system /tmp/oe_image_install/SYSTEM
|
cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
|
||||||
|
|
||||||
# unmount part1
|
# unmount part1
|
||||||
echo "image: unmounting part1..."
|
echo "image: unmounting part1..."
|
||||||
@ -113,9 +111,9 @@ EOF
|
|||||||
sync
|
sync
|
||||||
|
|
||||||
# add resize mark
|
# add resize mark
|
||||||
echo "image: mounting part2 on /tmp/oe_image_install..."
|
echo "image: mounting part2 on $OE_TMP..."
|
||||||
mount "$LOOP" /tmp/oe_image_install
|
mount "$LOOP" "$OE_TMP"
|
||||||
touch /tmp/oe_image_install/.please_resize_me
|
touch "$OE_TMP/.please_resize_me"
|
||||||
echo "image: unmounting part2..."
|
echo "image: unmounting part2..."
|
||||||
umount "$LOOP"
|
umount "$LOOP"
|
||||||
sync
|
sync
|
||||||
|
@ -23,16 +23,17 @@
|
|||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
echo "image: cleanup..."
|
echo "image: cleanup..."
|
||||||
umount /tmp/oe_image_install &>/dev/null || :
|
umount "$OE_TMP" &>/dev/null || :
|
||||||
losetup -d "$LOOP"
|
losetup -d "$LOOP"
|
||||||
[ -f /tmp/oe_image_install/ldlinux.sys ] && chattr -i /tmp/oe_image_install/ldlinux.sys || :
|
[ -f "$OE_TMP/ldlinux.sys" ] && chattr -i "$OE_TMP/ldlinux.sys" || :
|
||||||
rm -rf /tmp/oe_image_install
|
rm -rf "$OE_TMP"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup SIGINT
|
trap cleanup SIGINT
|
||||||
|
|
||||||
# set variables
|
# set variables
|
||||||
|
OE_TMP=$(mktemp -d)
|
||||||
SYSTEM_SIZE=256
|
SYSTEM_SIZE=256
|
||||||
# 3STORAGE_SIZE must be >= 32 !
|
# 3STORAGE_SIZE must be >= 32 !
|
||||||
STORAGE_SIZE=32
|
STORAGE_SIZE=32
|
||||||
@ -41,19 +42,17 @@ trap cleanup SIGINT
|
|||||||
LOOP=$(losetup -f)
|
LOOP=$(losetup -f)
|
||||||
|
|
||||||
# ensure loopX not in use
|
# ensure loopX not in use
|
||||||
echo "image: next two errors can be ignored..."
|
umount "$OE_TMP" &>/dev/null || :
|
||||||
umount /tmp/oe_image_install >/dev/null || :
|
|
||||||
umount "$LOOP" &>/dev/null >/dev/null || :
|
umount "$LOOP" &>/dev/null >/dev/null || :
|
||||||
losetup -d "$LOOP" &>/dev/null >/dev/null || :
|
losetup -d "$LOOP" &>/dev/null >/dev/null || :
|
||||||
rm -rf /tmp/oe_image_install &>/dev/null
|
|
||||||
|
|
||||||
# create an image
|
# create an image
|
||||||
echo "image: creating new empty image: $DISK..."
|
echo "image: creating image: $DISK..."
|
||||||
dd if=/dev/zero of="$DISK" bs=1M count="$DISK_SIZE"
|
dd if=/dev/zero of="$DISK" bs=1M count="$DISK_SIZE"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# write a disklabel
|
# write a disklabel
|
||||||
echo "image: creating new partition table: $DISK..."
|
echo "image: creating partition table on $DISK..."
|
||||||
losetup "$LOOP" "$DISK"
|
losetup "$LOOP" "$DISK"
|
||||||
parted -s "$LOOP" mklabel msdos
|
parted -s "$LOOP" mklabel msdos
|
||||||
sync
|
sync
|
||||||
@ -90,13 +89,12 @@ trap cleanup SIGINT
|
|||||||
sync
|
sync
|
||||||
|
|
||||||
# mount partition
|
# mount partition
|
||||||
echo "image: mounting part1 on /tmp/oe_image_install..."
|
echo "image: mounting part1 on $OE_TMP..."
|
||||||
mkdir -p /tmp/oe_image_install
|
mount "$LOOP" "$OE_TMP"
|
||||||
mount "$LOOP" /tmp/oe_image_install
|
|
||||||
|
|
||||||
# create bootloader configuration
|
# create bootloader configuration
|
||||||
echo "image: creating bootloader configuration..."
|
echo "image: creating bootloader configuration..."
|
||||||
cat >/tmp/oe_image_install/syslinux.cfg << EOF
|
cat >"$OE_TMP"/syslinux.cfg << EOF
|
||||||
UI vesamenu.c32
|
UI vesamenu.c32
|
||||||
PROMPT 0
|
PROMPT 0
|
||||||
MENU TITLE Boot Menu
|
MENU TITLE Boot Menu
|
||||||
@ -139,16 +137,16 @@ EOF
|
|||||||
|
|
||||||
# install extlinux
|
# install extlinux
|
||||||
echo "image: installing extlinux to part1..."
|
echo "image: installing extlinux to part1..."
|
||||||
$EXTLINUX_DIR/extlinux/extlinux.host --heads=4 --sector=32 -i /tmp/oe_image_install
|
$EXTLINUX_DIR/extlinux/extlinux.host --heads=4 --sector=32 -i "$OE_TMP"
|
||||||
|
|
||||||
# copy files
|
# copy files
|
||||||
echo "image: copying files to part1..."
|
echo "image: copying files to part1..."
|
||||||
cp $TARGET_IMG/$IMAGE_NAME.kernel /tmp/oe_image_install/KERNEL
|
cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/KERNEL"
|
||||||
cp $TARGET_IMG/$IMAGE_NAME.system /tmp/oe_image_install/SYSTEM
|
cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
|
||||||
cp $RELEASE_DIR/splash.png /tmp/oe_image_install
|
cp $RELEASE_DIR/splash.png "$OE_TMP"
|
||||||
cp $EXTLINUX_DIR/com32/menu/vesamenu.c32 /tmp/oe_image_install
|
cp $EXTLINUX_DIR/com32/menu/vesamenu.c32 "$OE_TMP"
|
||||||
cp $EXTLINUX_DIR/com32/lib/libcom32.c32 /tmp/oe_image_install
|
cp $EXTLINUX_DIR/com32/lib/libcom32.c32 "$OE_TMP"
|
||||||
cp $EXTLINUX_DIR/com32/libutil/libutil.c32 /tmp/oe_image_install
|
cp $EXTLINUX_DIR/com32/libutil/libutil.c32 "$OE_TMP"
|
||||||
|
|
||||||
# unmount part1
|
# unmount part1
|
||||||
echo "image: unmounting part1..."
|
echo "image: unmounting part1..."
|
||||||
@ -165,9 +163,9 @@ EOF
|
|||||||
e2fsck -n "$LOOP"
|
e2fsck -n "$LOOP"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
echo "image: mounting part2 on /tmp/oe_image_install..."
|
echo "image: mounting part2 on $OE_TMP..."
|
||||||
mount "$LOOP" /tmp/oe_image_install
|
mount "$LOOP" "$OE_TMP"
|
||||||
touch /tmp/oe_image_install/.please_resize_me
|
touch "$OE_TMP/.please_resize_me"
|
||||||
echo "image: unmounting part2..."
|
echo "image: unmounting part2..."
|
||||||
umount "$LOOP"
|
umount "$LOOP"
|
||||||
sync
|
sync
|
||||||
|
Loading…
x
Reference in New Issue
Block a user