-
Notifications
You must be signed in to change notification settings - Fork 252
/
build
executable file
·102 lines (84 loc) · 3.11 KB
/
build
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# Linux Live Kit version 7
export PATH=.:./tools:../tools:/usr/sbin:/usr/bin:/sbin:/bin:/
CHANGEDIR=$(dirname $(readlink -f $0))
echo "Changing current directory to $CHANGEDIR"
cd $CHANGEDIR
CWD="$(pwd)"
. ./config || exit 1
. ./livekitlib || exit 1
# only root can continue, because only root can read all files from your system
allow_only_root
# check for xz
if [ "$(xz --help 2>&1 | grep -i "Compress")" = "" ]; then
echo "xz not found or cannot compress"
echo "you may consider installing xz-tools package"
exit 1
fi
# check for mksquashfs with xz compression
if [ "$(mksquashfs 2>&1 | grep "Xdict-size")" = "" ]; then
echo "mksquashfs not found or doesn't support -comp xz, aborting, no changes made"
echo "you may consider installing squashfs-tools package"
exit 1
fi
MKISOFS=$(which mkisofs)
if [ "$MKISOFS" = "" ]; then
MKISOFS=$(which genisoimage)
fi
if [ "$MKISOFS" = "" ]; then
echo "Cannot find mkisofs or genisoimage, stop"
exit 3
fi
# build initramfs image
if [ "$SKIPINITRFS" = "" ]; then
echo "Building initramfs image..."
cd initramfs
INITRAMFS=$(./initramfs_create)
cd ..
fi
# create live kit filesystem (cpio archive)
rm -Rf "$LIVEKITDATA"
BOOT="$LIVEKITDATA"/"$LIVEKITNAME"/boot
mkdir -p "$BOOT"
mkdir -p "$BOOT"/../changes
mkdir -p "$BOOT"/../modules
if [ "$INITRAMFS" != "" ]; then
mv "$INITRAMFS" $BOOT/initrfs.img
fi
# BIOS / MBR booting
cp -r bootfiles/* $BOOT
cat bootfiles/syslinux.cfg | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" > $BOOT/syslinux.cfg
cat bootfiles/bootinst.bat | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" | sed -r "s:\\\\boot\\\\:\\\\$LIVEKITNAME\\\\boot\\\\:" > $BOOT/bootinst.bat
cp $VMLINUZ $BOOT/ || exit
# UEFI booting
mkdir -p $BOOT/EFI/Boot
cp bootfiles/EFI/Boot/syslinux.efi $BOOT/EFI/Boot/bootx64.efi
cp bootfiles/EFI/Boot/{ldlinux.e64,menu.c32,libutil.c32,vesamenu.c32,libcom32.c32} $BOOT/EFI/Boot
cat $BOOT/syslinux.cfg | sed -r "s:/$LIVEKITNAME/boot/vesamenu:vesamenu:" > $BOOT/EFI/Boot/syslinux.cfg
# create compressed 01-core.sb
COREFS=""
for i in $MKMOD; do
if [ -d /$i ]; then
COREFS="$COREFS /$i"
fi
done
if [ "$SKIPCOREMOD" = "" ]; then
mksquashfs $COREFS $LIVEKITDATA/$LIVEKITNAME/modules/01-core.$BEXT -comp xz -b 1024K -Xbcj x86 -always-use-fragments -keep-as-directory || exit
fi
cd "$LIVEKITDATA"
ARCH=$(uname -m)
TARGET=/tmp
cat "$CWD/bootinfo.txt" | fgrep -v "#" | sed -r "s/mylinux/$LIVEKITNAME/" | sed -r "s/\$/\x0D/" > readme.txt
echo cd $LIVEKITDATA '&&' $MKISOFS -o "$TARGET/$LIVEKITNAME-$ARCH.iso" -v -J -R -D -A "$LIVEKITNAME" -V "$LIVEKITNAME" \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b "$LIVEKITNAME"/boot/isolinux.bin -c "$LIVEKITNAME"/boot/isolinux.boot . \
> $TARGET/gen_"$LIVEKITNAME"_iso.sh
chmod o+x $TARGET/gen_"$LIVEKITNAME"_iso.sh
echo cd $LIVEKITDATA '&&' zip -0 -r "$TARGET/$LIVEKITNAME-$ARCH.zip" '*' \
> $TARGET/gen_"$LIVEKITNAME"_zip.sh
chmod o+x $TARGET/gen_"$LIVEKITNAME"_zip.sh
echo "-----------------------------"
echo "Finished. Find your result in $LIVEKITDATA"
echo "To build ISO, run: $TARGET/gen_"$LIVEKITNAME"_iso.sh"
echo "To build ZIP, run: $TARGET/gen_"$LIVEKITNAME"_zip.sh"
cd $CWD