-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunypkg-base-build-stage1.sh
1778 lines (1298 loc) · 54.4 KB
/
unypkg-base-build-stage1.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
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC2154
## This is the unypkg base system build script - stage 1
## Created by michacassola mich@casso.la
######################################################################################################################
######################################################################################################################
# Run as root on Ubuntu LTS
cat <<EOF
######################################################################################################################
######################################################################################################################
Stage 1 - Setting up the build system
######################################################################################################################
######################################################################################################################
EOF
if [[ $EUID -gt 0 ]]; then
echo "Not root, exiting..."
exit
fi
### Getting Variables from files
UNY_AUTO_PAT="$(cat UNY_AUTO_PAT)"
export UNY_AUTO_PAT
GH_TOKEN="$(cat GH_TOKEN)"
export GH_TOKEN
apt update && apt install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
python3-dev autoconf automake libtool libtool-bin gawk curl bzip2 xz-utils unzip zstd \
patch libstdc++6 rsync gh git meson ninja-build gettext autopoint libsigsegv-dev pkgconf
######################################################################################################################
######################################################################################################################
### Installing the unypkg script
wget -qO- uny.nu/pkg | bash
### unypkg functions
source /uny/git/unypkg/fn
uny_build_date
uny_auto_github_conf
set -xv
### Setup the Shell
ln -fs /bin/bash /bin/sh
export UNY=/uny
tee >/root/.bash_profile <<EOF
export UNY=/uny
PS1='\u:\w\$ '
#if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
#if [ -f "$HOME/.bashrc" ]; then
# . "$HOME/.bashrc"
#fi
#fi
EOF
[ ! -e /etc/bash.bashrc ] || mv -v /etc/bash.bashrc /etc/bash.bashrc.NOUSE
# shellcheck source=/dev/null
source /root/.bash_profile
### Add uny user
groupadd uny
useradd -s /bin/bash -g uny -m -k /dev/null uny
### Create uny chroot skeleton
mkdir -pv "$UNY"/home
mkdir -pv "$UNY"/sources/unygit
chmod -v a+wt "$UNY"/sources
mkdir -pv "$UNY"/{etc,var} "$UNY"/usr/{bin,lib,sbin}
mkdir -pv "$UNY"/uny/build/logs
for i in bin lib sbin; do
ln -sv usr/$i "$UNY"/$i
done
case $(uname -m) in
x86_64) mkdir -pv "$UNY"/lib64 ;;
esac
mkdir -pv "$UNY"/tools
chown -R uny:uny "$UNY"/* #{usr{,/*},lib,var,etc,bin,sbin,tools}
case $(uname -m) in
x86_64) chown -v uny "$UNY"/lib64 ;;
esac
######################################################################################################################
######################################################################################################################
### Download sources
cat <<EOF
######################################################################################################################
######################################################################################################################
Downloading sources
######################################################################################################################
######################################################################################################################
EOF
cd "$UNY"/sources || exit
######################################################################################################################
######################################################################################################################
######################################################################################################################
### glibc
pkgname="glibc"
pkggit="https://sourceware.org/git/glibc.git refs/heads/release/*/master"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --heads --sort="v:refname" $pkggit | tail --lines=1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=4)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
## To-Do: Make test with git diff --binary for glibc-2.37 release and with security backports from release/2.37/master
repo_clone_version_archive
newesttimedatafile="$(curl https://data.iana.org/time-zones/releases/ | grep -Eo "\"tzdata[0-9]+[a-z]+.tar.gz\"" | sed 's|"||g' | sort --version-sort | tail -n 1)"
wget https://data.iana.org/time-zones/releases/"$newesttimedatafile"
######################################################################################################################
### Binutils
pkgname="binutils"
pkggit="https://sourceware.org/git/binutils-gdb.git refs/heads/binutils-$(git ls-remote --refs --sort="v:refname" https://sourceware.org/git/binutils-gdb.git refs/tags/binutils-[0-9_]* | tail -n 1 | grep -Eo "[0-9_]*" | tail -n 1 | grep -Eo "[0-9]_[0-9]*")-branch"
gitdepth="--depth=25"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --heads --sort="v:refname" $pkggit | tail --lines=1)"
latest_ver="$(echo "$latest_head" | grep -o "[0-9_]*" | tail -n 1 | sed "s|_|.|")"
check_for_repo_and_create
git_clone_source_repo
latest_commit_id="$(git -C "$pkg_git_repo_dir" log --perl-regexp --author='^((?!GDB Administrator).*)$' -n 1 | grep "commit" | cut -d" " -f 2)"
git -C "$pkg_git_repo_dir" checkout "$latest_commit_id"
rm -r "$pkg_git_repo_dir"/{contrib,djunpack.bat,gdb,gdb*,libbacktrace,libdecnumber,multilib.am,readline,sim}
version_details
archiving_source
######################################################################################################################
### GCC + GCC-Shared
pkgname="gcc"
pkggit="https://gcc.gnu.org/git/gcc.git refs/tags/releases/gcc-13.2.0"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | tail --lines=1)"
# shellcheck disable=SC2086
#latest_ver="$(git ls-remote --refs --sort="v:refname" $pkggit | grep -oE "gcc-[^0-9]*(([0-9]+\.)*[0-9]+)" | sed "s|gcc-||" | sort -n | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=4 | sed "s|gcc-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
#pkgname="gcc"
#version_details
######################################################################################################################
######################################################################################################################
### Exit if Glibc, Binutils or GCC are not newer
#if [[ -f vdet-glibc-new || -f vdet-binutils-new || -f vdet-gcc-new ]]; then
# echo "Continuing"
#else
# echo "No new version of Glibc, Binutils or GCC found, exiting..."
# exit
#fi
######################################################################################################################
### Linux API Headers
pkgname="linux-api-headers"
pkggit="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git refs/heads/linux-rolling-stable"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --heads --sort="v:refname" $pkggit | tail --lines=1)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
## To-Do: Make test with git diff --binary for glibc-2.37 release and with security backports from release/2.37/master
check_for_repo_and_create
git_clone_source_repo
# shellcheck disable=SC2086,SC2154
latest_ver="$(git ls-remote --refs --tags --sort="v:refname" $pkg_git_repo | grep -Ev "\-rc[0-9]" | grep -oE "[0-9]*(([0-9]+\.)*[0-9]+)" | tail -n 1)"
version_details
archiving_source
######################################################################################################################
### M4
pkgname="m4"
pkggit="https://git.savannah.gnu.org/r/m4.git refs/tags/v1.4*"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --sort="v:refname" $pkggit | tail --lines=1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/m4/m4-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Ncurses
pkgname="ncurses"
pkggit="https://github.com/ThomasDickey/ncurses-snapshots.git refs/tags/*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --sort="v:refname" $pkggit | grep -E "v[0-9]_[0-9]+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed -e "s|v||" -e "s|_|.|")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Bash
pkgname="bash"
pkggit="https://git.savannah.gnu.org/git/bash.git refs/*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --tags --refs --sort="v:refname" $pkggit | grep -E "bash-[0-9].[0-9]$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed -e "s|bash-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Coreutils
pkgname="coreutils"
pkggit="https://git.savannah.gnu.org/git/coreutils.git refs/tags/v*"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --sort="v:refname" $pkggit | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/coreutils/coreutils-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Diffutils
pkgname="diffutils"
pkggit="https://git.savannah.gnu.org/git/diffutils.git refs/tags/v*"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/diffutils/diffutils-"$latest_ver".tar.xz
version_details
######################################################################################################################
### File
pkgname="file"
pkggit="https://github.com/file/file.git refs/tags/FILE*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed -e "s|FILE||" -e "s|_|.|")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
git_clone_source_repo
cd "$pkg_git_repo_dir" || exit
autoreconf -i
cd /uny/sources || exit
version_details
archiving_source
######################################################################################################################
### Findutils
pkgname="findutils"
pkggit="https://git.savannah.gnu.org/git/findutils.git refs/tags/v*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/findutils/findutils-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Gawk
pkgname="gawk"
pkggit="https://git.savannah.gnu.org/git/gawk.git refs/tags/gawk-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "gawk-[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|gawk-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Grep
pkgname="grep"
pkggit="https://git.savannah.gnu.org/git/grep.git refs/tags/v*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9].[0-9]+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/grep/grep-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Gzip
pkgname="gzip"
pkggit="https://git.savannah.gnu.org/git/gzip.git refs/tags/v*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9].[0-9]+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/gzip/gzip-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Make
pkgname="make"
pkggit="https://git.savannah.gnu.org/git/make.git refs/tags/[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/make/make-"$latest_ver".tar.gz
version_details
######################################################################################################################
### Patch
pkgname="patch"
pkggit="https://git.savannah.gnu.org/git/patch.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/patch/patch-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Sed
pkgname="sed"
pkggit="https://git.savannah.gnu.org/git/sed.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/sed/sed-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Tar
pkgname="tar"
pkggit="https://git.savannah.gnu.org/git/tar.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/tar/tar-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Xz
pkgname="xz"
pkggit="https://git.tukaani.org/xz.git refs/tags/v5.2.7"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
git_clone_source_repo
cd "$pkg_git_repo_dir" || exit
./autogen.sh
cd /uny/sources || exit
version_details
archiving_source
######################################################################################################################
### Gettext
pkgname="gettext"
pkggit="https://git.savannah.gnu.org/git/gettext.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/gettext/gettext-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Bison
pkgname="bison"
pkggit="https://git.savannah.gnu.org/git/bison.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/bison/bison-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Perl
pkgname="perl"
pkggit="https://github.com/Perl/perl5.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
# shellcheck disable=SC2086
versubnums="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 20 | grep -Eo "[^v0-9][.0-9]+\." | sed "s|\.||g" | sort -u)"
versubnum_even="$(for i in $versubnums; do if [[ $((i % 2)) -eq 0 ]]; then echo "$i"; fi; done)"
versubnum_even_latest="$(echo "$versubnum_even" | tail -n 1)"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" https://github.com/Perl/perl5.git refs/tags/v[0-9]."$versubnum_even_latest".* | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Python
pkgname="python"
pkggit="https://github.com/python/cpython.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9](.[0-9]+)[^a-z]+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Texinfo
pkgname="texinfo"
pkggit="https://git.savannah.gnu.org/git/texinfo.git refs/tags/texinfo-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "texinfo-[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|texinfo-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/texinfo/texinfo-"$latest_ver".tar.xz
version_details
######################################################################################################################
### zLib
pkgname="zlib"
pkggit="https://github.com/madler/zlib.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Bzip2
pkgname="bzip2"
pkggit="https://gitlab.com/bzip2/bzip2.git refs/tags/bzip2-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "bzip2-[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|bzip2-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Zstd
pkgname="zstd"
pkggit="https://github.com/facebook/zstd.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Readline
pkgname="readline"
pkggit="https://git.savannah.gnu.org/git/readline.git refs/tags/readline-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "readline-[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|readline-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Bc
pkgname="bc"
pkggit="https://github.com/gavinhoward/bc.git refs/tags/[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Flex
pkgname="flex"
pkggit="https://github.com/westes/flex.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://github.com/westes/flex/releases/download/v"$latest_ver"/flex-"$latest_ver".tar.gz
version_details
######################################################################################################################
### Tcl
pkgname="tcl"
pkggit="https://github.com/tcltk/tcl.git refs/tags/core-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "core-[0-9](-[0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed -e "s|core-||" -e "s|-|.|g")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Expect
pkgname="expect"
expectver="5.45.4"
curl -LO https://prdownloads.sourceforge.net/expect/expect"$expectver".tar.gz
tar xf expect"$expectver".tar.gz
rm expect"$expectver".tar.gz
chown -R root:root expect"$expectver"
mv expect"$expectver" expect-"$expectver"
XZ_OPT="--threads=0" tar -cJpf expect-"$expectver".tar.xz expect-"$expectver"
latest_ver="$expectver"
latest_commit_id="$expectver"
check_for_repo_and_create
version_details
######################################################################################################################
### DejaGNU
pkgname="dejagnu"
pkggit="https://git.savannah.gnu.org/git/dejagnu.git refs/tags/dejagnu-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "dejagnu-[0-9](\.[0-9]+)+-release$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed -e "s|dejagnu-||" -e "s|-release||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### GMP
pkgname="gmp"
latest_pkg="$(curl -L https://ftp.gnu.org/gnu/gmp/ | tac | tac | grep -oE "gmp-.*.tar.xz\"" | sed "s|\"||" | sort --version-sort | tail -n 1)"
latest_ver="$(echo "$latest_pkg" | cut --delimiter='-' --fields=2 | sed "s|.tar.xz||")"
latest_commit_id="$latest_ver"
curl -LO https://ftp.gnu.org/gnu/gmp/"$latest_pkg"
tar xf "$latest_pkg"
chown -R root:root gmp-*
check_for_repo_and_create
version_details
######################################################################################################################
### MPFR
pkgname="mpfr"
pkggit="https://gitlab.inria.fr/mpfr/mpfr.git refs/tags/[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
git_clone_source_repo
cd "$pkg_git_repo_dir" || exit
autoreconf -i
cd /uny/sources || exit
version_details
archiving_source
######################################################################################################################
### MPC
pkgname="mpc"
pkggit="https://gitlab.inria.fr/mpc/mpc.git refs/tags/[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
git_clone_source_repo
cd "$pkg_git_repo_dir" || exit
autoreconf -i
cd /uny/sources || exit
version_details
archiving_source
######################################################################################################################
### Attr
pkgname="attr"
pkggit="https://git.savannah.gnu.org/git/attr.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://download.savannah.nongnu.org/releases/attr/attr-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Acl
pkgname="acl"
pkggit="https://git.savannah.gnu.org/git/acl.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://download.savannah.gnu.org/releases/acl/acl-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Libcap
pkgname="libcap"
pkggit="https://git.kernel.org/pub/scm/libs/libcap/libcap.git refs/tags/libcap-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "libcap-[0-9]\.[0-9]+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|libcap-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
repo_clone_version_archive
######################################################################################################################
### Libxcrypt
pkgname="libxcrypt"
pkggit="https://github.com/besser82/libxcrypt.git refs/tags/v*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "[0-9]\.([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://github.com/besser82/libxcrypt/releases/download/v"$latest_ver"/libxcrypt-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Shadow
pkgname="shadow"
pkggit="https://github.com/shadow-maint/shadow.git refs/tags/[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "[0-9]\.([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3)"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://github.com/shadow-maint/shadow/releases/download/"$latest_ver"/shadow-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Pkg-config
pkgname="pkgconf"
pkggit="https://github.com/pkgconf/pkgconf refs/tags/pkgconf-[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "pkgconf-[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|pkgconf-||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
git_clone_source_repo
cd "$pkg_git_repo_dir" || exit
autoreconf -i
cd /uny/sources || exit
version_details
archiving_source
######################################################################################################################
### Libtool
libtool_stable_ver="$(
curl -L https://ftp.gnu.org/gnu/libtool/ | tac | tac | grep -oE "libtool-.*.tar.xz\"" |
sed -e "s|.tar.xz\"||" -e "s|libtool-||" | sort --version-sort | tail -n 1
)"
pkgname="libtool"
pkggit="https://git.savannah.gnu.org/git/libtool.git refs/tags/v${libtool_stable_ver}*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/libtool/libtool-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Less
pkgname="less"
pkggit="https://github.com/gwsw/less.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
git_clone_source_repo
cd "$pkg_git_repo_dir" || exit
make -f Makefile.aut distfiles
cd /uny/sources || exit
version_details
archiving_source
######################################################################################################################
### Autoconf
pkgname="autoconf"
pkggit="https://git.savannah.gnu.org/git/autoconf.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/autoconf/autoconf-"$latest_ver".tar.xz
version_details
######################################################################################################################
### Automake
# shellcheck disable=SC2034
pkgname="automake"
pkggit="https://git.savannah.gnu.org/git/automake.git refs/tags/v[0-9.]*"
# shellcheck disable=SC2034
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
check_for_repo_and_create
wget https://ftp.gnu.org/gnu/automake/automake-"$latest_ver".tar.xz
version_details
######################################################################################################################
######################################################################################################################
### Run the next part as uny user
cat <<EOF
######################################################################################################################
######################################################################################################################
Building temporary system as uny user
######################################################################################################################
######################################################################################################################
EOF
# Change ownership to uny
chown -R uny:uny "$UNY"/*
sudo -i -u uny bash <<"EOFUNY"
set -vx
######################################################################################################################
######################################################################################################################
### Functions
source /uny/git/unypkg/fn
######################################################################################################################
######################################################################################################################
cat >~/.bash_profile <<"EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat >~/.bashrc <<"EOF"
set +h
umask 022
UNY=/uny
LC_ALL=POSIX
UNY_TGT=$(uname -m)-uny-linux-gnu
PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$UNY/tools/bin:$PATH
CONFIG_SITE=$UNY/usr/share/config.site
export UNY LC_ALL UNY_TGT PATH CONFIG_SITE
MAKEFLAGS="-j$(nproc)"
source /uny/git/unypkg/fn
EOF
EOFUNY
sudo -i -u uny bash <<"EOFUNY"
set -vx
source ~/.bashrc
######################################################################################################################
######################################################################################################################
### Start timing