-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrelease.sh
More file actions
158 lines (130 loc) · 4.18 KB
/
release.sh
File metadata and controls
158 lines (130 loc) · 4.18 KB
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
set -ex
source tools/filething.sh
UPLOAD_SERVER="https://filething.toxicfox.de"
UPLOAD_AUTH_TOKEN="$MICROOS_UPLOAD_TOKEN"
WEBHOOK_URL="$MESSAGE_WEBHOOK"
BUILD_TOKEN="$MICROOS_BUILD_TOKEN"
function do_release {
if [[ "$#" -lt 10 ]]; then
echo "Usage: release <name> <cdrom> <cdromMinimal> <libs> <message> <screenshot> <kernel> <symbols> <initrd> <initrd-install>"
exit 1
fi
local name="$1"
local cdrom="$2"
local cdromMinimal="$3"
local libs="$4"
local message="$5"
local screenshot="$6"
local kernel="$7"
local symbols="$8"
local initrd="$9"
local initrd_install="${10}"
echo "Releasing: $name"
send_webhook "$name" "$cdrom" "$cdromMinimal" "$libs" "$message" "$screenshot" "$kernel" "$symbols" "$initrd"
trigger_build "$name" "$kernel" "$symbols" "$initrd_install"
}
function send_webhook {
local name="$1"
local cdrom="$2"
local cdromMinimal="$3"
local libs="$4"
local message="$5"
local screenshot="$6"
local kernel="$7"
local symbols="$8"
local initrd="$9"
curl -s -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"username": "Website",
"embeds": [
{
"title": "New release (${name})",
"fields": [
{ "name": "cdrom", "value": "${cdrom}" },
{ "name": "cdrom (no packages)", "value": "${cdromMinimal}" },
{ "name": "libs", "value": "${libs}" },
{ "name": "message", "value": "${message}" },
{ "name": "screenshot", "value": "${screenshot}" },
{ "name": "kernel", "value": "${kernel}" },
{ "name": "symbols", "value": "${symbols}" },
{ "name": "initrd", "value": "${initrd}" }
],
"image": { "url": "${screenshot}" }
}
]
}
EOF
}
function trigger_build {
local name="$1"
local kernel="$2"
local symbols="$3"
local initrd="$4"
response=$(curl -s -w "\n%{http_code}" -X POST \
"https://toxicfox.de/api/v1/microos/build" \
-H "Content-Type: application/json" \
-H "Authentication: ${BUILD_TOKEN}" \
-d @- <<EOF
{
"preset": "${name}",
"kernel": "${kernel}",
"symbols": "${symbols}",
"initrd": "${initrd}"
}
EOF
)
body=$(echo "$response" | head -n1)
status=$(echo "$response" | tail -n1)
echo "Build trigger response: $status $body"
}
function applyPreset {
deno run -A config/config.ts --clean --auto --load config/presets/$1.kernel.json config/kernel.json
deno run -A config/config.ts --clean --auto --load config/presets/$1.libc.json config/libc.json
deno run -A config/config.ts --clean --auto --mode makefile --load config/presets/$1.build.json config/build.json
}
function screenshot {
make run_vnc &>/dev/null & disown
sleep 45
vncsnapshot localhost:1 $1
killall qemu-system-i386
}
function release {
# deno run -A release.ts screenshot::$(upload_file microos.jpg) name::$1 cdrom::$(upload_file cdrom.iso) cdromMinimal::$(upload_file cdrom.minimal.iso) libs::$(upload_file libs.zip) message::"$2" kernel::$(upload_file mckrnl/core/mckrnl.elf) symbols::$(upload_file mckrnl/core/mckrnl.syms) initrd::$(upload_file res/initrd.saf)
local cdrom=$(upload_file "$2")
local cdrom_minimal=$(upload_file "cdrom.minimal.iso")
local libs=$(upload_file "libs.zip")
local screenshot=$(upload_file "microos.jpg")
local kernel=$(upload_file "mckrnl/core/mckrnl.elf")
local symbols=$(upload_file "mckrnl/core/mckrnl.syms")
local initrd=$(upload_file "res/initrd.saf")
local initrd_install=$(upload_file "res/initrd-install.saf")
do_release "$1" "$cdrom" "$cdrom_minimal" "$libs" "$2" "$screenshot" "$kernel" "$symbols" "$initrd" "$initrd_install"
}
function install_pkgs_initrd {
make -C tools/microemu -B
(
cp res/initrd res/initrd-install -rv
cd res/initrd-install
../../tools/microemu/microemu root:/bin/init.mex bin/terminal.mex <<EOF
cd pkgs
terminal all.msh
pwr off
EOF
rm -rf pkgs
)
./res/saf/saf-make ./res/initrd-install ./res/initrd-install.saf
}
applyPreset $1
make iso libs.zip
cp cdrom.iso cdrom.minimal.iso
(
cd pkgs
bash build.sh
bash clean.sh
)
make iso
screenshot microos.jpg
install_pkgs_initrd
release $1 "$2"