-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·582 lines (365 loc) · 12.2 KB
/
configure.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
#!/bin/bash
#
#*************************************************************************************************
#
# 88 88
# 88 ""
# 88
# 88,dPPPba, ,adPPPba, 8b, ,d8 ,adPPPPba, ,adPPPb,d8 ,adPPPba, 8b,dPPPba, 88 8b, ,d8
# 88P' "88 a8P 88 `P8, ,8P' "" `P8 a8" `P88 a8" "8a 88P' `"88 88 `P8, ,8P'
# 88 88 8PP""""""" )888( ,adPPPPP88 8b 88 8b d8 88 88 88 )888(
# 88 88 "8b, ,aa ,d8" "8b, 88, ,88 "8a, ,d88 "8a, ,a8" 88 88 88 ,d8" "8b,
# 88 88 `"Pbbd8"' 8P' `P8 `"8bbdP"P8 `"PbbdP"P8 `"PbbdP"' 88 88 88 8P' `P8
# aa, ,88
# "P8bbdP"
#
# Sistema Operacional Hexagonix - Hexagonix Operating System
#
# Copyright (c) 2015-2024 Felipe Miguel Nery Lunkes
# Todos os direitos reservados - All rights reserved.
#
#*************************************************************************************************
#
# Português:
#
# O Hexagonix e seus componentes são licenciados sob licença BSD-3-Clause. Leia abaixo
# a licença que governa este arquivo e verifique a licença de cada repositório para
# obter mais informações sobre seus direitos e obrigações ao utilizar e reutilizar
# o código deste ou de outros arquivos.
#
# English:
#
# Hexagonix and its components are licensed under a BSD-3-Clause license. Read below
# the license that governs this file and check each repository's license for
# obtain more information about your rights and obligations when using and reusing
# the code of this or other files.
#
#*************************************************************************************************
#
# BSD 3-Clause License
#
# Copyright (c) 2015-2024, Felipe Miguel Nery Lunkes
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# $HexagonixOS$
# $PORTUGUÊS$
#
# Esse script deve ficar na raiz do projeto
#
# $ENGLISH$
#
# This script must be in the root of the project
function main() {
case $1 in
build) build; exit;;
user) users; exit;;
clean) clean; exit;;
--version) showVersion; exit;;
*) configureBuild; exit;;
esac
}
function verifyDependencies() {
echo -e "Checking dependencies needed to build the system..."
# Now let's check each build engine dependency
# Dependency 1
echo -n " > flat assembler "
if [ -e /usr/bin/fasm ] ; then
echo -e "[\e[32mOk\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Dependency 2
echo -n " > qemu "
if [ -e /usr/bin/qemu-system-i386 ] ; then
echo -e "[\e[32mOk\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;94mYou can start building the system without this dependency\e[0m."
fi
# Dependency 3
echo -n " > nasm "
if [ -e /usr/bin/nasm ] ; then
echo -e "[\e[32mOk\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;94mYou can start building the system without this dependency\e[0m."
fi
# Dependency 4
echo -n " > dd "
if [ -e /usr/bin/dd ] ; then
echo -e "[\e[32mOk\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Dependency 5
echo -n " > chown "
if [ -e /usr/bin/chown ] ; then
echo -e "[\e[32mOk\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;94mYou can start building the system without this dependency\e[0m."
fi
# Dependency 6
echo -n " > cloc "
if [ -e /usr/bin/cloc ] ; then
echo -e "[\e[32mOk\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;94mYou can start building the system without this dependency\e[0m."
fi
finish
# Now let's check if the scripts are available and make them executable
echo -e "Checking utilities and modules needed to build the system..."
# Module 1
echo -n " > System build and run utility (hx) "
if [ -e hx ] ; then
echo -en "[\e[32mOk\e[0m]"
chmod +x hx
echo -e " [\e[94mExecutable\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Module 2
echo -n " > Module for building external utilities (Contrib.sh) "
if [ -e Contrib/Contrib.sh ] ; then
echo -en "[\e[32mOk\e[0m]"
chmod +x Contrib/Contrib.sh
echo -e " [\e[94mExecutable\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Module 3
echo -n " > Unix utilities build module (Unix.sh) "
if [ -e Apps/Unix/Unix.sh ] ; then
echo -en "[\e[32mOk\e[0m]"
chmod +x Apps/Unix/Unix.sh
echo -e " [\e[94mExecutable\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Module 4
echo -n " > Andromeda-Hexagonix application build module (Apps.sh) "
if [ -e Apps/Andromeda/Apps.sh ] ; then
echo -en "[\e[32mOk\e[0m]"
chmod +x Apps/Andromeda/Apps.sh
echo -e " [\e[94mExecutable\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Module 5
echo -n " > Hexagonix font build module (fonts.sh) "
if [ -e Fonts/fonts.sh ] ; then
echo -en "[\e[32mOk\e[0m]"
chmod +x Fonts/fonts.sh
echo -e " [\e[94mExecutable\e[0m]"
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mYou CANNOT start building the system without this dependency\e[0m."
fi
# Now let's install the dependencies already present (no need to obtain)
# Let's test whether or not we can install hx in /usr/bin...
if test "`whoami`" != "root" ; then
echo -e " \e[1;31m[!] Unable to install hx to /usr/bin. Root user privileges required.\e[0m"
echo -e " \e[1;31m[!] Use sudo ./configure.sh to install hx.\e[0m"
fi
if test "`whoami`" == "root" ; then
# Install hx
echo -n " > Installing/updating hx (destination: /usr/bin)... "
cp hx /usr/bin
fi
if [ -e /usr/bin/hx ] ; then
if test "`whoami`" == "root" ; then
echo -en "[\e[32mOk\e[0m]"
chmod +x /usr/bin/hx
echo -e " [\e[94mExecutable\e[0m]"
fi
else
echo -e "[\e[31mNot found\e[0m]"
echo -e " > \e[1;31mVocê deve usar a cópia local de hx para executar as operações\e[0m."
fi
finish
}
function build() {
echo -e "Configuring system build data..."
# First, let's build the base
cd Dist/etc
if [ -e base.ocl ] ; then
echo " > Removing previous build and base version information..."
rm base.ocl
fi
echo -n " > Processing .conf file and setting configuration file... "
echo -e $(cat base.conf)$VERSION"]"$CODENAME'"'$UPDATEPACK"#"$RELEASE"!"$BUILD">" >> base.ocl
echo -e "[\e[32mOk\e[0m]"
if [ -e hexgnix.unx ] ; then
echo " > Removing previous Hexagonix build and version database..."
rm hexgnix.unx
fi
echo -n " > Processing .conf file and creating UNX-XML... "
echo -e $(cat hexgnix.conf)" <version>"$VERSION"</version>" >> hexgnix.unx
echo " <codename>$CODENAME</codename>" >> hexgnix.unx
echo " <updatepack>$UPDATEPACK</updatepack>" >> hexgnix.unx
echo " <branch>$RELEASE</branch>" >> hexgnix.unx
echo " <build>$BUILD</build>" >> hexgnix.unx
echo " <builddate>"$(date)"</builddate>" >> hexgnix.unx
echo "</hexagonix>" >> hexgnix.unx
echo -e "[\e[32mOk\e[0m]"
cd ..
cd ..
finish
}
function host() {
echo -e "Configuring hostname..."
cd Dist/etc
if [ -e host ] ; then
echo " > Removing previous host configuration..."
rm host
fi
echo -n " > Processing .conf file and creating host configuration... "
echo $CODENAME$(cat host.conf) >> host
echo -e "[\e[32mOk\e[0m]"
cd ..
cd ..
finish
}
function shrc() {
echo -e "Configuring shrc..."
cd Dist/etc
if [ -e shrc ] ; then
echo " > Removing previous shrc configuration..."
rm shrc
fi
echo -n " > Creating shrc configuration... "
echo "Welcome to Hexagonix $VERSION ($RELEASE)" >> shrc
echo "Hexagonix is licenced under BSD-3-Clause and comes with no warranty." >> shrc
echo -e "[\e[32mOk\e[0m]"
cd ..
cd ..
finish
}
function users() {
echo -e "Configuring users..."
cd Dist/etc
if [ -e passwd ] ; then
echo " > Removing previous user database..."
rm passwd
fi
echo -n " > Processing .conf file and creating user database... "
echo -e $(cat passwd.conf) >> passwd
echo -e "[\e[32mOk\e[0m]"
cd ..
cd ..
finish
}
function init() {
echo -e "Configuring rc (startup script)..."
cd Dist/etc
if [ -e rc ] ; then
echo " > Removing previous rc (startup script)..."
rm rc
fi
echo -n " > Processing .conf file and creating rc (startup script)... "
echo -e $(cat rc.conf) >> rc
echo -e "[\e[32mOk\e[0m]"
cd ..
cd ..
finish
}
function finish() {
echo -e "[\e[32mStep completed successfully\e[0m]"
}
function clean() {
banner
echo -e "Removing dependencies installed on your computer..."
echo
echo -n " > Removing hx from /usr/bin... "
if [ -e /usr/bin/hx ] ; then
rm -rf /usr/bin/hx
else
echo -e "[\e[94mPreviously removed\e[0m] "
finish
exit
fi
if [ -e /usr/bin/hx ] ; then
echo -en "[\e[1;31mFail\e[0m]"
else
echo -en "[\e[32mOk\e[0m]"
echo -e " [\e[94mRemoved\e[0m]"
fi
finish
}
function configureBuild() {
banner
echo -e "Checking dependencies and configuring system build settings..."
echo
verifyDependencies
build
users
init
host
shrc
echo -e "[\e[32mAll ready!\e[0m]"
}
function banner() {
clear
echo -e "******************************************************************************"
echo
echo -e " ┌┐ ┌┐ \e[1;94mHexagonix Operating System\e[0m"
echo -e " ││ ││"
echo -e " │└─┘├──┬┐┌┬──┬──┬──┬─┐┌┬┐┌┐ \e[1;94mCopyright (c) 2015-2024 Felipe Miguel Nery Lunkes\e[0m"
echo -e " │┌─┐││─┼┼┼┤┌┐│┌┐│┌┐│┌┐┼┼┼┼┘ \e[1;94mAll rights reserved.\e[0m"
echo -e " ││ │││─┼┼┼┤┌┐│└┘│└┘││││├┼┼┐"
echo -e " └┘ └┴──┴┘└┴┘└┴─┐├──┴┘└┴┴┘└┘"
echo -e " ┌─┘│ \e[1;32mConfigure build environment\e[0m"
echo -e " └──┘"
echo
echo -e "******************************************************************************"
echo
}
function showVersion() {
echo "hx build configuration module, version $CONFIGURE_VERSION"
echo
echo -e "\e[0mCopyright (c) 2015-2024 Felipe Miguel Nery Lunkes\e[0m"
echo -e "hx and hx modules are licensed under BSD-3-Clause and comes with no warranty."
}
export CONFIGURE_VERSION="6.0.0"
CONFIGURE1=$2
CONFIGURE2=$3
CONFIGURE3=$4
CONFIGURE4=$5
BUILD=$(uuid -m -v 4)
VERSION=$(cat Dist/etc/version.def)
CODENAME=$(cat Dist/etc/codename.def)
RELEASE=$(cat Dist/etc/release.def)
UPDATEPACK=$(cat Dist/etc/update.def)
main $1