Skip to content

Commit 5d24515

Browse files
committed
add image building commands
1 parent 5b6cd89 commit 5d24515

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

contrib/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*.o
22
/*.out
33
/*.bin
4-
4+
/squeeze
5+
/*.img

contrib/createimage.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
set -e -u
4+
5+
if false; then
6+
sudo debootstrap \
7+
--variant=minbase \
8+
--include=psmisc,mini-httpd,net-tools,iproute,iputils-ping,procps,netcat-openbsd,telnet,iptables,wget,tcpdump,curl,gdb,binutils,gcc,libc6-dev,lsof,strace \
9+
--exclude=locales,aptitude,gnupg,cron,udev,tasksel,rsyslog,groff-base,manpages,gpgv,man-db,apt,debian-archive-keyring,sysv-rc,sysvinit,insserv,python2.6 \
10+
--arch i386 \
11+
squeeze squeeze \
12+
'http://mirror.yandex.ru/debian'
13+
fi
14+
15+
IMAGE_SIZE=120 # megabytes
16+
#icount=`find squeeze | wc -l`
17+
INODE_COUNT=7000
18+
19+
rm -f hda.img
20+
fallocate --length=${IMAGE_SIZE}M hda.img
21+
mke2fs -F -q -m 0 -N $INODE_COUNT hda.img
22+
23+
ddd=/tmp/outimage
24+
mkdir -p $ddd
25+
26+
echo 'root:qwe' | sudo chroot squeeze chpasswd
27+
sudo unshare -m -- bash -c "
28+
set -x -e -u
29+
mount -n -o loop hda.img -t ext2 $ddd
30+
tar -C squeeze \
31+
--exclude='./var/cache*' \
32+
--exclude='./usr/share/locale*' \
33+
--exclude='./usr/share/zoneinfo*' \
34+
--exclude='./usr/share/doc*' \
35+
--exclude='./usr/share/man*' \
36+
--exclude='./usr/share/info*' \
37+
--exclude='./var/lib/apt*' \
38+
-c . | tar -C $ddd -x
39+
40+
cat show_boot_time.c | chroot $ddd gcc -m32 -xc -s -Os - -o /usr/bin/show_boot_time
41+
42+
rm -f $ddd/sbin/init;
43+
cp -f init.sh $ddd/sbin/init
44+
rm -rf $ddd/root
45+
ln -s /tmp/root $ddd/root
46+
47+
rm -rf $ddd/var/run
48+
ln -s /tmp $ddd/var/run
49+
50+
:>| $ddd/etc/resolv.conf
51+
rm -f $ddd/etc/mtab
52+
ln -s /proc/mounts $ddd/etc/mtab
53+
mknod $ddd/dev/ppp c 108 0
54+
mknod $ddd/dev/clipboard c 10 231
55+
mknod $ddd/dev/ttyS0 c 4 64
56+
mknod $ddd/dev/ttyS1 c 4 65
57+
mknod $ddd/dev/ttyS2 c 4 66
58+
mknod $ddd/dev/ttyS3 c 4 67
59+
mknod $ddd/dev/hda b 3 0
60+
mknod $ddd/dev/hdb b 3 64
61+
mknod $ddd/dev/hdb1 b 3 65
62+
63+
echo -e '#!/bin/sh\necho \$* > /dev/clipboard\n' > $ddd/bin/answer
64+
chmod a+x $ddd/bin/answer
65+
df -h $ddd/
66+
"
67+
rm -rf $ddd
68+
make splitted

contrib/init.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
show_boot_time 2>/dev/null
4+
5+
echo "JSLinux started, initializing..."
6+
7+
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
8+
export HOME=/root
9+
export TERM=vt100
10+
mount -n -t proc /proc /proc
11+
mount -n -t sysfs /sys /sys
12+
mount -n -t devpts devpts /dev/pts
13+
mount -n -t tmpfs /tmp /tmp
14+
mkdir -p "/tmp/root"
15+
ip link set up dev lo
16+
17+
main() {
18+
echo >/dev/clipboard
19+
20+
while :; do
21+
setsid sh -c "exec bash 0<>/dev/ttyS0 1>&0 2>&0"
22+
done
23+
}
24+
25+
. /dev/clipboard
26+
27+
main "$@"

contrib/test_in_kvm.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
kvm -kernel ~/src/linux/arch/i386/boot/bzImage -snapshot -hda hda.img -hdb hda.img -append 'root=/dev/hda console=ttyS0 notsc=1' -serial stdio -net none -M isapc -m 16

0 commit comments

Comments
 (0)