-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript
196 lines (175 loc) · 6.9 KB
/
script
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
function check {
echo -ne "$*\t"
}
function ok {
echo -e "[ \e[38;5;32msuccess\e[0m ]"
}
function nok {
echo -e "[ \e[38;5;31mfailure\e[0m ]"
}
function warn {
echo -e "[ \e[38;5;33mwarning\e[0m ]"
}
function format {
awk -F'\t' '{ printf "%-60s %s\n",$1,$2 }'
}
function slowcat {
[[ -z "${3}" ]] && echo usage: $0 file chunksize waittime && return 1
local c=0
local b=$(wc -c <${1})
while [ ${c} -lt ${b} ]; do
dd if=${1} bs=1 count=${2} skip=${c} 2>/dev/null
(( c = c + ${2} ))
sleep ${3}
done
}
function index {
echo "<HTML><HEAD><TITLE>LINKS</TITLE></HEAD><BODY><ul>" >index.html
for file in $(ls|grep -v index.html); do \
(\
printf '<li><a href="' ; \
printf "${file}" ; \
printf '">' ; \
printf "${file}" ; \
printf '</a></li>\n' \
) >>index.html ; \
done
echo "</ul></BODY></HTML>" >>index.html
}
function push {
git init
git config user.name "${USER}"
git config user.email "${GHP_MAIL}"
git add .
git commit -m "Deploy to GitHub Pages"
git push --force --quiet https://${GHP_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git master:gh-pages
}
wd=$(pwd)
ver_a_loc=https://dugoh.github.io/386bsd0.1/
qemu_loc=https://dugoh.github.io/oldqemu/qemu.tar.bz2
(
check checking wget; wget --help >/dev/null 2>&1 && ok || nok
check checking ncurses; ls -l /usr/include/ncurses.h >/dev/null 2>&1 && ok || nok
check fetching version a; wget -r -np -nd "${ver_a_loc}" # >/dev/null 2>&1 && ok || nok
check extract disk; cat disk.part-aa disk.part-ab disk.part-ac \
|bunzip2 >disk.img && ok || nok
check extract bochs; bunzip2 -c bochs.tar.bz2|tar -xvf - >/dev/null 2>&1 && ok || nok
check checking bochs directory; cd bochs >/dev/null 2>&1 && ok || nok
check installing bochs; sudo make install >/dev/null 2>&1 && ok || nok
check setting bochs capabilities; sudo setcap \
CAP_NET_ADMIN,CAP_NET_RAW=eip \
/usr/local/bin/bochs >/dev/null 2>&1 && ok || nok
cd "${wd}"
check bochs config present; ls bochsrc >/dev/null 2>&1 && ok || nok
check set time to 1st patch kit date; sed -i -e 's/time0=.*/time0=735327993/' bochsrc >/dev/null 2>&1 && ok || nok
check fetching qemu; sudo -i wget "${qemu_loc}" >/dev/null 2>&1 && ok || nok
check extract qemu; sudo -i -- bash -c \
'bunzip2 -c qemu.tar.bz2 | tar -xvf -' >/dev/null 2>&1 && ok || nok
check installing qemu; sudo -i -- bash -c 'cd qemu; make install' >/dev/null 2>&1 && ok || nok
check setting qemu capabilities; sudo setcap \
CAP_NET_ADMIN,CAP_NET_RAW=eip \
/usr/local/bin/qemu >/dev/null 2>&1 && ok || nok
)|format
cd "${wd}"
# second third boot (fsck due to clock shift) #############
touch out
(sleep 20; echo)|TERM=vt100 bochs -q -f bochsrc |tee -a out
mv out out_3b.txt
###########################################################
cat >4 <<"__EOF4__"
root
exec sh
cat >/to_pk023.sh <<"__EOF"
#!/bin/sh
cd /
tar -xvf pk023.tar
mv patch dist
cd dist/bin
./mkpatchdirs
(echo y; echo; echo; echo IALL; echo y ; echo ; echo q)|./patches
./afterinstall.sh
rm -r /sys/compile/*
cd /sys/i386/conf
config GENERICISA
cd /sys/compile/GENERICISA
make depend
make
mv /386bsd /386bsd.old
cp 386bsd /386bsd
sync; sync; sync
shutdown -rf now
__EOF
chmod +x /to_pk023.sh
/to_pk023.sh
__EOF4__
# fourth boot #############################################
touch out
(
until egrep -q 'login:|console' out ; do
sleep 5;
done
sleep 5
slowcat ./4 4 1
)| TERM=vt100 bochs -q -f bochsrc |tee -a out
mv out out_4.txt
###########################################################
(
check add 2 hours to clock; sed -i -e's/time0=.*/time0=735335193/' bochsrc >/dev/null 2>&1 && ok || nok
)|format
cat >5 <<"__EOF5__"
root
exec sh
cat >/buildworld_pk023.sh <<"__EOF"
#!/bin/sh
cd /patch/bin
./buildworld.sh
sync; sync; sync
shutdown -rf now
__EOF
chmod +x /buildworld_pk023.sh
/buildworld_pk023.sh
__EOF5__
(
check convert disk; qemu-img convert \
-f raw -O qcow2 disk.img qdisk.img >/dev/null 2>&1 && ok || nok
)|format
# fifth boot ##############################################
touch out
(
until egrep -q 'login:|console' out ; do
sleep 5;
done
sleep 5
slowcat ./5 1 .5
)| TERM=vt100 script -f -c 'qemu \
-L /usr/local/share/qemu/ \
-curses \
-hda qdisk.img \
-M isapc \
-net nic \
-no-reboot \
-m 64 \
-startdate "1994-04-21"' \
|tee -a out \
|tr -cd 'c' \
|fold -w 120
mv out out_5.txt
###########################################################
echo;echo ====;echo;echo
fold out_5.txt|head -150
echo;echo ====;echo;echo
fold out_5.txt|tail -150
echo;echo ====;echo;echo
(
check creating gh-pages; mkdir gh-pages ; cd gh-pages >/dev/null 2>&1 && ok || nok
check add the hard disk; mv ../qdisk.img ./ >/dev/null 2>&1 && ok || nok
check compress the disk; bzip2 --best qdisk.img >/dev/null 2>&1 && ok || nok
check split the disk in parts; split -b 50m "qdisk.img.bz2" "qdisk.part-" >/dev/null 2>&1 && ok || nok
check remove the unsplit disk; rm qdisk.img.bz2 >/dev/null 2>&1 && ok || nok
check add the floppy disk; mv ../boot.img ./ >/dev/null 2>&1 && ok || nok
check add the bochs config; mv ../bochsrc ./ >/dev/null 2>&1 && ok || nok
check add the TUN config; mv ../tunconfig ./ >/dev/null 2>&1 && ok || nok
check add the screen output; mv ../out_* ./ >/dev/null 2>&1 && ok || nok
check create an index page; index >/dev/null 2>&1 && ok || nok
check push to gh-pages; push >/dev/null 2>&1 && ok || nok
)|format