Skip to content

Commit 13efe1b

Browse files
committed
test 12
1 parent ce021f5 commit 13efe1b

File tree

1 file changed

+296
-33
lines changed

1 file changed

+296
-33
lines changed

.github/script/dfbsd.sh

Lines changed: 296 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,206 @@
11
#!/bin/sh
2-
pwd
3-
ls -lah
4-
whoami
5-
env
6-
uname -a
7-
env IGNORE_OSVERSION=yes pkg install -y ccache-static
8-
ccache --max-size="200M"
9-
ls /usr/dports
10-
export PORTS_BRANCH="master"
11-
if [ ! -f "/usr/dports/${PORTS_BRANCH}" ] ; then mkdir -p /usr/dports && fetch "https://github.com/dragonflybsd/dports/archive/refs/heads/${PORTS_BRANCH}.tar.gz" -o - | tar xf - -C /usr/dports --strip-components=1 && touch "/usr/dports/${PORTS_BRANCH}" ; fi
12-
echo "WITH_CCACHE_BUILD=yes" >> /etc/make.conf
2+
on_github() {
3+
[ "${GITHUB_ACTIONS}" = "true" ]
4+
}
5+
on_cirrus() {
6+
[ "${CIRRUS_CI}" = "true" ]
7+
}
8+
on_bare() {
9+
! on_github && ! on_cirrus
10+
}
11+
12+
repeat_string() {
13+
char=$1
14+
count=$2
15+
while [ $count -gt 0 ];
16+
do
17+
printf '%s' "$char"
18+
count=$(( $count - 1 ))
19+
done
20+
}
21+
center() {
22+
string=$1
23+
string_len=${#string}
24+
pad_len=$2
25+
pad_r_len=$(( ($pad_len - $string_len)/2 + ($pad_len - $string_len)%2 ))
26+
pad_l_len=$(( ($pad_len - $string_len)/2 ))
27+
28+
repeat_string ' ' $pad_r_len
29+
printf '%s' "$string"
30+
repeat_string ' ' $pad_l_len
31+
}
32+
33+
section() {
34+
text_color=6
35+
border_color=3
36+
on_github && echo "::group::$1"
37+
tput setaf $border_color
38+
echo '/============================================================================\'
39+
printf '%s' "|"
40+
tput setaf $text_color
41+
center "$1" 76
42+
tput setaf $border_color
43+
printf '%s\n' "|"
44+
echo '\============================================================================/'
45+
tput setaf 9
46+
47+
}
48+
section_end() {
49+
text_color=6
50+
border_color=3
51+
on_github && echo "::endgroup::"
52+
tput setaf $border_color
53+
printf '%s' '\================================+'
54+
tput setaf $text_color
55+
printf '%s' 'END-SECTION'
56+
tput setaf $border_color
57+
printf '%s\n' '+===============================/'
58+
tput setaf 9
59+
}
60+
61+
not_defined(){
62+
var_name=$1
63+
var_value=$(eval 'echo "$'$var_name'"')
64+
[ -z "$var_value" ]
65+
}
66+
export_not_defined(){
67+
var_name=$1
68+
value=$2
69+
not_defined "$var_name" && export "$var_name"="$value"
70+
}
71+
72+
env_setup(){
73+
74+
export_not_defined OS_NAME "$(uname -s)"
75+
76+
if not_defined BRANCH
77+
then
78+
on_cirrus && export BRANCH="$CIRRUS_BRANCH"
79+
on_github && export BRANCH="$GITHUB_REF_NAME"
80+
on_bare && export BRANCH="master"
81+
fi
82+
83+
if not_defined PORTS_DIR
84+
then
85+
if [ "$OS_NAME" = "DragonFly" ]
86+
then
87+
export PORTS_DIR="/usr/dports"
88+
elif
89+
export PORTS_DIR="/usr/ports"
90+
fi
91+
fi
92+
93+
if not_defined REPO_URL
94+
then
95+
on_cirrus && export REPO_URL="$CIRRUS_REPO_CLONE_URL"
96+
on_github && export REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git"
97+
on_bare && export REPO_URL="https://github.com/b-aaz/xlibre-ports"
98+
fi
99+
100+
if not_defined PORTS_REPO_URL
101+
then
102+
if [ "$OS_NAME" = "DragonFly" ]
103+
then
104+
export PORTS_REPO_URL="https://github.com/dragonflybsd/dports"
105+
elif
106+
export PORTS_REPO_URL="https://github.com/freebsd/freebsd-ports"
107+
fi
108+
fi
109+
110+
export_not_defined PORTS_BRANCH "master"
111+
export_not_defined CCACHE_SIZE "200M"
112+
export_not_defined CCACHE_DIR "/tmp/.ccache"
113+
export_not_defined CCACHE_COMPRESS 1
114+
export_not_defined CCACHE_STATIC_PREFIX "/usr/local"
115+
export_not_defined CCACHE_NOSTATS 1
116+
export_not_defined CCACHE_TEMPDIR "/tmp"
117+
export_not_defined WITH_CCACHE_BUILD "YES"
118+
119+
export_not_defined DEBUG_CI "NO"
120+
debug_ci && {
121+
env
122+
debug_ci_end
123+
}
124+
}
125+
126+
debug_ci(){
127+
text_color=6
128+
border_color=1
129+
title="DEBUG-SECTION"
130+
[ -n "$1" ] && title="$1"
131+
[ "$DEBUG_CI" = "YES"] &&
132+
{
133+
on_github && echo "::group::$title" &&
134+
tput setaf $border_color &&
135+
printf '%s' '>>>>>>>>>>>>>>' &&
136+
tput setaf $text_color &&
137+
echo "$title" &&
138+
tput setaf 9
139+
}
140+
}
141+
142+
debug_ci_end(){
143+
text_color=6
144+
border_color=1
145+
[ "$DEBUG_CI" = "YES"] &&
146+
{
147+
on_github && echo "::endgroup::"
148+
tput setaf $border_color
149+
echo '<<<<<<<<<<<<<<'
150+
tput setaf $text_color
151+
echo "END-DEBUG-SECTION"
152+
tput setaf 9
153+
}
154+
}
155+
156+
step_0(){
157+
section 'Clone and checkout'
158+
git clone "$REPO_URL"
159+
git switch "$BRANCH"
160+
161+
debug_ci && {
162+
ls .
163+
debug_ci_end
164+
}
165+
166+
section_end
167+
}
168+
step_1(){
169+
section 'Perquisites'
170+
ASSUME_ALWAYS_YES=yes pkg bootstrap -f
171+
pkg install -y git-lite
172+
section_end
173+
}
174+
175+
step_2(){
176+
section 'Ports tree setup'
177+
ls ${PORTS_DIR}
178+
179+
if [ ! -f "${PORTS_DIR}/${PORTS_BRANCH}" ]
180+
then
181+
mkdir -p ${PORTS_DIR} &&
182+
fetch "${PORTS_REPO_URL}/archive/refs/heads/${PORTS_BRANCH}.tar.gz" -o - | tar xf - -C ${PORTS_DIR} --strip-components=1 &&
183+
touch "${PORTS_DIR}/${PORTS_BRANCH}"
184+
fi
185+
debug_ci && {
186+
ls "${PORTS_DIR}"
187+
debug_ci_end
188+
}
189+
section_end
190+
}
191+
192+
step_3(){
193+
section 'ccache setup'
194+
pkg install -y ccache-static
195+
ccache --max-size=${CCACHE_SIZE}
196+
section_end
197+
}
198+
199+
step_4(){
200+
section 'Patch setup'
13201
{
14202
{
15-
patch -N /usr/dports/Mk/bsd.port.subdir.mk << EOF
203+
patch -N ${PORTS_DIR}/Mk/bsd.port.subdir.mk << EOF
16204
@@ -173,6 +173,11 @@
17205
TARGETS+= realinstall
18206
TARGETS+= reinstall
@@ -28,24 +216,99 @@ patch -N /usr/dports/Mk/bsd.port.subdir.mk << EOF
28216
EOF
29217
} || true
30218
}
31-
grep -n '^TARGETS+=' /usr/dports/Mk/bsd.port.subdir.mk
32-
echo 'OVERLAYS=/'"$(pwd)"'/' >> /etc/make.conf
33-
echo 'WITH_DEBUG=yes' >> /etc/make.conf
34-
echo 'DEBUG_FLAGS+= -O0' >> /etc/make.conf
35-
cat /etc/make.conf
36-
make run-depends-list | sort | uniq | grep -v '^==\|xlibre' | cut -d '/' -f 4- | xargs pkg install -y
37-
make build-depends-list | sort | uniq | grep -v '^==\|xlibre\|xorg-macros' | cut -d '/' -f 4- | xargs pkg install -y
38-
make -C /usr/dports/devel/xorg-macros/ clean
39-
make stage
40-
make stage-qa
41-
make check-plist
42-
export PACKAGES="$(pwd)/pkgs/"
43-
mkdir $PACKAGES
44-
make package
45-
export PACKAGES="$(pwd)/pkgs/"
46-
ABI="$(pkg config abi)"
47-
mv $PACKAGES/All $PACKAGES/$ABI
48-
pkg repo -l $PACKAGES/$ABI
49-
pkg install -y tree
50-
cd $PACKAGES/$ABI
51-
tree -h -D -C -H -./ --houtro=/dev/null -T 'XLibre binaries for FreeBSD' ./ > ./index.html
219+
debug_ci && {
220+
grep -n '^TARGETS+=' ${PORTS_DIR}/Mk/bsd.port.subdir.mk
221+
debug_ci_end
222+
}
223+
224+
section_end
225+
}
226+
227+
step_5(){
228+
section 'make.conf setup'
229+
echo 'OVERLAYS=/'"$(pwd)"'/' >> /etc/make.conf
230+
echo 'WITH_DEBUG=yes' >> /etc/make.conf
231+
echo 'DEBUG_FLAGS+= -O0' >> /etc/make.conf
232+
echo "WITH_CCACHE_BUILD=yes" >> /etc/make.conf
233+
debug_ci && {
234+
cat /etc/make.conf
235+
debug_ci_end
236+
}
237+
section_end
238+
}
239+
240+
step_6(){
241+
section 'Install run dependencies'
242+
make run-depends-list | sort | uniq | grep -v '^==\|xlibre' | cut -d '/' -f 4- | xargs pkg install -y
243+
section_end
244+
}
245+
246+
step_7(){
247+
section 'Install build dependencies'
248+
make build-depends-list | sort | uniq | grep -v '^==\|xlibre\|xorg-macros' | cut -d '/' -f 4- | xargs pkg install -y
249+
make -C ${PORTS_DIR}/devel/xorg-macros/ clean
250+
section_end
251+
}
252+
253+
step_8(){
254+
section 'Stage'
255+
make stage
256+
section_end
257+
}
258+
259+
step_9(){
260+
section 'Stage QA'
261+
make stage-qa
262+
section_end
263+
}
264+
265+
step_10(){
266+
section 'Check-plist'
267+
make check-plist
268+
section_end
269+
}
270+
271+
step_10(){
272+
section 'Package'
273+
export PACKAGES="$(pwd)/pkgs/"
274+
mkdir $PACKAGES
275+
make package
276+
debug_ci && {
277+
ls "${PACKAGES}"
278+
debug_ci_end
279+
}
280+
section_end
281+
}
282+
283+
step_11(){
284+
section 'Repo setup'
285+
ABI="$(pkg config abi)"
286+
mv $PACKAGES/All $PACKAGES/$ABI
287+
pkg repo -l $PACKAGES/$ABI
288+
pkg install -y tree
289+
cd $PACKAGES/$ABI
290+
tree -h -D -C -H -./ --houtro=/dev/null -T "XLibre binaries for $OS_NAME" ./ > ./index.html
291+
debug_ci && {
292+
pwd
293+
tree
294+
debug_ci_end
295+
}
296+
section_end
297+
}
298+
299+
{
300+
export DEBUG_CI="YES"
301+
302+
env_setup
303+
304+
if [ -n "$1" ]
305+
then
306+
eval "step_$1"
307+
else
308+
for i in "$(seq 0 11)"
309+
do
310+
eval "step_$1" || exit
311+
done
312+
fi
313+
314+
}

0 commit comments

Comments
 (0)