-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·148 lines (131 loc) · 3 KB
/
build.sh
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
#!/bin/bash
#
# Copyright (c) Roberto A. Foglietta, 2022-2023
#
# Authors:
# Roberto A. Foglietta <roberto.foglietta@gmail.com>
#
# SPDX-License-Identifier: MIT
#
kasyml="kas.yml"
#kasopt="--no-proxy-from-env"
function print_images() {
sed -e "s,^eval-image-\(.*\).bb, - \\1," README.txt
}
function show_current() {
local rf=$(readlink -e eval-image.bb)
test ! -f "$rf" && rm -f eval-image.bb
basename "$rf" | sed -e "s,eval-image-\(.*\).bb,\\1,"
}
function print_current() {
local vm
show_current | sed -e "s,\(.*\),${1:-current}: \\1 $vm,"
}
if [ "$(whoami)" == "root" ]; then
echo
echo "ERROR: this script should not run as root, abort!"
echo
exit 1
fi
cd $(dirname $0)
doimg=0
topdir=$PWD
fn="$topdir/wic/debx86.wks"
fl="$topdir/wic/debx86-110GiB-vmdk.wks"
for i in pigz pzstd; do
if ! which $i >/dev/null; then
echo
echo "ERROR: the command '$i' is missing, install it"
echo
exit 1
fi
done
mkdir -p build/downloads/dash
for i in $(ls -1 dash/dash-*.static); do
ln -Pf $i build/downloads/dash
done 2>/dev/null
cd recipes-core/images ########################################################
if [ "$1" == "--help" -o "$1" == "-h" ]; then
echo
echo "USAGE: $(basename $0) <one-target-here-below>"
echo
print_images
echo
print_current
echo
exit 1
fi
if [ -e "eval-image-$1.bb" ]; then
set -- "eval-image-$1.bb"
doimg=1
elif [ -e "$1.bb" ]; then
set -- "$1.bb"
doimg=1
elif [ -e "$1" ]; then
doimg=1
fi
if [ "$1" == "" -a ! -e eval-image.bb ]; then
echo
echo "ERROR: no any target defined, choose one:"
echo
print_images
echo
exit 1
elif [ "$doimg" == "1" ]; then
if [ -e "$1" ]; then
# if [ -e "$1" -a -e "$topdir/build" ]; then
if [ "$(show_current)" != "" ]; then
echo
print_current
echo
fi
if [ "$1" == "eval-image-$(show_current).bb" ]; then
true
elif ln -s "$1" eval-image.bb 2>/dev/null; then
echo
print_current setanew
echo
else
ln -sf "$1" eval-image.bb
print_current updated
echo
echo -n "A target exists, clean isar? (y/N) "
read key && echo
[ "$key" == "y" ] && ${topdir}/clean.sh isar
fi
else
ln -sf "$1" eval-image.bb
echo
print_current
echo
fi
set --
elif [ "$1" != "" ]; then
echo
echo "target: $1"
echo
else
echo
print_current
echo
fi
cd - >/dev/null ###############################################################
if false; then
for i in git.functions colors.shell; do
repo_uri="https://raw.githubusercontent.com/robang74/git-functions/main"
wget -q --background ${repo_uri}/$i -O $i
done
fi
ipaddr=$(ip addr show dev docker0 | sed -ne "s, *inet \([0-9.]*\).*,\\1,p")
for i in $(env | grep -e "_proxy="); do
export ${i/127.0.0.1/$ipaddr}
done
echo "WARNING: the proxy enviroment variables are unset"
unset no_proxy ftp_proxy https_proxy http_proxy
cd $topdir >/dev/null
if [ ! -d isar/.git ]; then
time ./kas-container $kasopt checkout "$kasyml" || exit $?
test "$1" == "isar" && exit 0
echo
fi
time ./kas-container $kasopt build ${1:+--target $1} "$kasyml"