syslinux: move image makescript out of package, merge with scripts/ and /scripts/image

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2013-12-27 21:39:15 +01:00
parent 3bc998dd25
commit 3e1730b120
4 changed files with 70 additions and 72 deletions

View File

@ -9,7 +9,7 @@ release:
./scripts/image release ./scripts/image release
image: image:
BUILD_IMAGE=yes ./scripts/image release ./scripts/image mkimage
noobs: noobs:
./scripts/image noobs ./scripts/image noobs

View File

@ -32,20 +32,3 @@ mkdir -p $RELEASE_DIR/3rdparty/syslinux/win32
mkdir -p $RELEASE_DIR/3rdparty/syslinux/win64 mkdir -p $RELEASE_DIR/3rdparty/syslinux/win64
cp -PR $BUILD/syslinux-*/win64/syslinux64.exe $RELEASE_DIR/3rdparty/syslinux/win64 cp -PR $BUILD/syslinux-*/win64/syslinux64.exe $RELEASE_DIR/3rdparty/syslinux/win64
if [ "$BUILD_IMAGE" = "yes" -a -x "$BOOTLOADER_DIR/image" ] ; then
# variables used in image script must be passed
EXTLINUX_DIR=$(ls -d $ROOT/$BUILD/syslinux-*/)
UUID_SYSTEM=$(uuidgen)
UUID_STORAGE=$(uuidgen)
sudo env \
PATH="$PATH" \
TARGET_IMG="$TARGET_IMG" \
IMAGE_NAME="$IMAGE_NAME" \
RELEASE_DIR="$RELEASE_DIR" \
EXTLINUX_DIR="$EXTLINUX_DIR" \
UUID_SYSTEM="$UUID_SYSTEM" \
UUID_STORAGE="$UUID_STORAGE" \
$BOOTLOADER_DIR/image
fi

View File

@ -204,7 +204,7 @@ IMAGE_NAME="$DISTRONAME-$TARGET_VERSION"
chmod 0644 $TARGET_IMG/$IMAGE_NAME.system chmod 0644 $TARGET_IMG/$IMAGE_NAME.system
chmod 0644 $TARGET_IMG/$IMAGE_NAME.kernel chmod 0644 $TARGET_IMG/$IMAGE_NAME.kernel
if [ "$1" = "release" ]; then if [ "$1" = "release" -o "$1" = "mkimage" ]; then
RELEASE_DIR="target/$IMAGE_NAME" RELEASE_DIR="target/$IMAGE_NAME"
@ -266,6 +266,11 @@ IMAGE_NAME="$DISTRONAME-$TARGET_VERSION"
# create release tarball # create release tarball
tar cf $TARGET_IMG/$IMAGE_NAME.tar -C target $IMAGE_NAME tar cf $TARGET_IMG/$IMAGE_NAME.tar -C target $IMAGE_NAME
# create image files if requested
if [ "$1" = "mkimage" -a -f $SCRIPTS/mkimage-$BOOTLOADER ]; then
. $SCRIPTS/mkimage-$BOOTLOADER
fi
# cleanup release dir # cleanup release dir
rm -rf $RELEASE_DIR rm -rf $RELEASE_DIR

View File

@ -18,31 +18,38 @@
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>. # along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################ ################################################################################
cleanup() . config/options $1
{
echo "image: cleanup..." $SCRIPTS/build syslinux:host
umount "$OE_TMP" &>/dev/null || :
losetup -d "$LOOP" # set variables
[ -f "$OE_TMP/ldlinux.sys" ] && chattr -i "$OE_TMP/ldlinux.sys" || : UUID_SYSTEM=$(uuidgen)
rm -rf "$OE_TMP" UUID_STORAGE=$(uuidgen)
exit OE_TMP=$(mktemp -d)
} LOOP=$(losetup -f)
SYSTEM_SIZE=256
STORAGE_SIZE=32 # STORAGE_SIZE must be >= 32 !
DISK_SIZE=$(( $SYSTEM_SIZE + $STORAGE_SIZE ))
DISK="$TARGET_IMG/$IMAGE_NAME.img"
# functions
cleanup() {
echo "image: cleanup..."
sudo umount "$OE_TMP" &>/dev/null || :
sudo losetup -d "$LOOP"
[ -f "$OE_TMP/ldlinux.sys" ] && sudo chattr -i "$OE_TMP/ldlinux.sys" || :
sudo rm -rf "$OE_TMP"
exit
}
trap cleanup SIGINT trap cleanup SIGINT
# set variables
OE_TMP=$(mktemp -d)
SYSTEM_SIZE=256
# 3STORAGE_SIZE must be >= 32 !
STORAGE_SIZE=32
DISK_SIZE=$(( $SYSTEM_SIZE + $STORAGE_SIZE ))
DISK="$TARGET_IMG/$IMAGE_NAME.img"
LOOP=$(losetup -f)
# ensure loopX not in use # ensure loopX not in use
umount "$OE_TMP" &>/dev/null || : sudo umount "$OE_TMP" &>/dev/null || :
umount "$LOOP" &>/dev/null >/dev/null || : sudo umount "$LOOP" &>/dev/null >/dev/null || :
losetup -d "$LOOP" &>/dev/null >/dev/null || : sudo losetup -d "$LOOP" &>/dev/null >/dev/null || :
# create an image # create an image
echo "image: creating image: $DISK..." echo "image: creating image: $DISK..."
@ -51,48 +58,49 @@ trap cleanup SIGINT
# write a disklabel # write a disklabel
echo "image: creating partition table on $DISK..." echo "image: creating partition table on $DISK..."
losetup "$LOOP" "$DISK" sudo losetup "$LOOP" "$DISK"
parted -s "$LOOP" mklabel msdos sudo parted -s "$LOOP" mklabel msdos
sync sync
# create part1 # create part1
echo "image: creating part1 on $DISK..." echo "image: creating part1 on $DISK..."
SYSTEM_PART_END=$(( $SYSTEM_SIZE * 1024 * 1024 / 512 + 64 )) SYSTEM_PART_END=$(( $SYSTEM_SIZE * 1024 * 1024 / 512 + 64 ))
parted -s "$LOOP" -a min unit s mkpart primary ext4 64 $SYSTEM_PART_END sudo parted -s "$LOOP" -a min unit s mkpart primary ext4 64 $SYSTEM_PART_END
parted -s "$LOOP" set 1 boot on sudo parted -s "$LOOP" set 1 boot on
# create part2 # create part2
echo "image: creating part2 on $DISK..." echo "image: creating part2 on $DISK..."
STORAGE_PART_START=$(( $SYSTEM_PART_END + 1 )) STORAGE_PART_START=$(( $SYSTEM_PART_END + 1 ))
parted -s "$LOOP" -a min unit s mkpart primary ext4 $STORAGE_PART_START 100% sudo parted -s "$LOOP" -a min unit s mkpart primary ext4 $STORAGE_PART_START 100%
sync sync
# write mbr # write mbr
echo "image: writing mbr..." echo "image: writing mbr..."
MBR="$EXTLINUX_DIR/mbr/mbr.bin" MBR="$ROOT/$TOOLCHAIN/share/syslinux/mbr.bin"
if [ -n "$MBR" ]; then if [ -n "$MBR" ]; then
dd bs=440 count=1 conv=notrunc if="$MBR" of="$LOOP" sudo dd bs=440 count=1 conv=notrunc if="$MBR" of="$LOOP"
fi fi
sync sync
# create filesystem on part1 # create filesystem on part1
losetup -d "$LOOP" sudo losetup -d "$LOOP"
echo "image: creating filesystem on part1..." echo "image: creating filesystem on part1..."
OFFSET=$(( 64 * 512 )) OFFSET=$(( 64 * 512 ))
SIZELIMIT=$(( $SYSTEM_SIZE * 1024 * 1024 )) SIZELIMIT=$(( $SYSTEM_SIZE * 1024 * 1024 ))
losetup -o $OFFSET --sizelimit $SIZELIMIT "$LOOP" "$DISK" sudo losetup -o $OFFSET --sizelimit $SIZELIMIT "$LOOP" "$DISK"
mke2fs -q -t ext4 -m 0 "$LOOP" sudo mke2fs -q -t ext4 -m 0 "$LOOP"
tune2fs -U $UUID_SYSTEM "$LOOP" sudo tune2fs -U $UUID_SYSTEM "$LOOP"
e2fsck -n "$LOOP" sudo e2fsck -n "$LOOP"
sync sync
# mount partition # mount partition
echo "image: mounting part1 on $OE_TMP..." echo "image: mounting part1 on $OE_TMP..."
mount "$LOOP" "$OE_TMP" sudo mount "$LOOP" "$OE_TMP"
# create bootloader configuration # create bootloader configuration
echo "image: creating bootloader configuration..." echo "image: creating bootloader configuration..."
cat >"$OE_TMP"/syslinux.cfg << EOF # cat >"$OE_TMP"/syslinux.cfg << EOF
cat << EOF | sudo tee "$OE_TMP"/syslinux.cfg
UI vesamenu.c32 UI vesamenu.c32
PROMPT 0 PROMPT 0
MENU TITLE Boot Menu MENU TITLE Boot Menu
@ -123,50 +131,52 @@ MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #ff868787 #00000000 std MENU COLOR tabmsg 31;40 #ff868787 #00000000 std
LABEL installer LABEL installer
MENU LABEL Run OpenELEC Installer MENU LABEL Run $DISTRONAME Installer
KERNEL /KERNEL KERNEL /KERNEL
APPEND boot=UUID=$UUID_SYSTEM installer quiet tty vga=current APPEND boot=UUID=$UUID_SYSTEM installer quiet tty vga=current
LABEL live LABEL live
MENU LABEL Run OpenELEC Live MENU LABEL Run $DISTRONAME Live
KERNEL /KERNEL KERNEL /KERNEL
APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE quiet vga=current APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE quiet vga=current
EOF 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 "$OE_TMP" sudo $ROOT/$TOOLCHAIN/bin/extlinux --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 "$OE_TMP/KERNEL" sudo cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/KERNEL"
cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM" sudo cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
cp $RELEASE_DIR/splash.png "$OE_TMP" sudo cp $RELEASE_DIR/splash.png "$OE_TMP"
cp $EXTLINUX_DIR/com32/menu/vesamenu.c32 "$OE_TMP" sudo cp $ROOT/$TOOLCHAIN/share/syslinux/vesamenu.c32 "$OE_TMP"
cp $EXTLINUX_DIR/com32/lib/libcom32.c32 "$OE_TMP" sudo cp $ROOT/$TOOLCHAIN/share/syslinux/libcom32.c32 "$OE_TMP"
cp $EXTLINUX_DIR/com32/libutil/libutil.c32 "$OE_TMP" sudo cp $ROOT/$TOOLCHAIN/share/syslinux/libutil.c32 "$OE_TMP"
# unmount part1 # unmount part1
echo "image: unmounting part1..." echo "image: unmounting part1..."
umount "$LOOP"
sync sync
sudo umount "$LOOP"
# create filesystem on part2 # create filesystem on part2
losetup -d "$LOOP" sudo losetup -d "$LOOP"
echo "image: creating filesystem on part2..." echo "image: creating filesystem on part2..."
OFFSET=$(( $STORAGE_PART_START * 512 )) OFFSET=$(( $STORAGE_PART_START * 512 ))
losetup -o $OFFSET "$LOOP" "$DISK" sudo losetup -o $OFFSET "$LOOP" "$DISK"
mke2fs -q -t ext4 -m 0 "$LOOP" sudo mke2fs -q -t ext4 -m 0 "$LOOP"
tune2fs -U $UUID_STORAGE "$LOOP" sudo tune2fs -U $UUID_STORAGE "$LOOP"
e2fsck -n "$LOOP" sudo e2fsck -n "$LOOP"
sync sync
echo "image: mounting part2 on $OE_TMP..." echo "image: mounting part2 on $OE_TMP..."
mount "$LOOP" "$OE_TMP" sudo mount "$LOOP" "$OE_TMP"
touch "$OE_TMP/.please_resize_me" sudo touch "$OE_TMP/.please_resize_me"
# unmount part2
echo "image: unmounting part2..." echo "image: unmounting part2..."
umount "$LOOP"
sync sync
sudo umount "$LOOP"
# gzip # gzip
echo "image: compressing..." echo "image: compressing..."