-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path_release
executable file
·2485 lines (2322 loc) · 87.5 KB
/
_release
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
#>>> source ${HOME}/.bashrc
#>>> umask 022
################################################################################
if { [[ -z ${_SYSTEMED} ]] || ! ${_SYSTEMED}; }; then
echo -en "\n"
echo -en ">>> THIS SCRIPT IS NOT MEANT TO BE RUN DIRECTLY <<<\n"
echo -en ">>> PLEASE USE THE (_system -v) SCRIPT INSTEAD <<<\n"
echo -en "\n"
exit 1
fi
################################################################################
#NOTE: SCRIPT NAME AND FUNCTION NAMES (${PREPIT}, ${MAKEIT}, ${SHIPIT}) MUST MATCH FOR "_SYSTEM" WRAPPING TO WORK
#NOTE: UPDATE "#SETTINGS" LINES IN "_SYSTEM" SCRIPT WHEN THESE VARIABLES CHANGE
export _GNAME="GaryOS"
export _TITLE="gary-os"
export _VERSN="v8.0"
export _RDATE="$(date --iso=date)"
export _FINAL="${TARGET}/.${_TITLE}-${ESUB}"
export _RAMFS="${_FINAL}/${_TITLE}-${_VERSN}-${ESUB}"
export _GOVLY="/.overlay"
export _GUNPK="/.unpack"
export _GINST="/.install"
export _G_MOD_TINY="tiny"
export _G_MOD="mod"
export _GREAD="readme.md"
export _GPACK="packages.txt"
export _GPASS="p@ssw0rd!"
########################################
#>>> #{isexit} + ${target} = /\t\treturn 0
#>>> pass-through =
#>>> /DOREDO="${DOREDO}"
#>>> /DOFAST="${DOFAST}"
#>>> /DOTEST="${DOTEST}"
#>>> if [[ -z ${TARGET} ]]; then
#>>> _TITLE="${_TITLE}-custom"
#>>> fi
########################################
declare _AUTHOR="Gary B. Genett <[email protected]>"
declare _LOGIN="garybgenett"
declare _GITHUB="ssh://[email protected]/${_LOGIN}/${_TITLE}.git"
declare _SFCODE="ssh://${_LOGIN}@git.code.sf.net/p/${_TITLE}/code"
declare _SFFILE="${_LOGIN}@web.sourceforge.net:/home/frs/project/${_TITLE}"
declare _SFRSSH="${_LOGIN},${_TITLE}@shell.sourceforge.net create"
declare _SFDOWN="https://sourceforge.net/projects/gary-os/files/${_VERSN}"
declare _DOCDIR="/.g/_data/zactive/coding/${_TITLE}"
declare _BLDDIR="/.g/_data/_builds"
declare _SAVDIR="${_BLDDIR}/_${_TITLE}"
declare _RELDIR="${_BLDDIR}/.${_TITLE}"
declare _G_REPO="${_RELDIR}/.${_TITLE}"
declare _OUTDIR="${_RELDIR}.release"
declare _DSTDIR="distfiles"
declare _PAKDIR="packages"
declare _EAMARK="${_FINAL}/_EARLY_ACCESS_DIRECTORY--IN_DEVELOPMENT--UNSUPPORTED.txt"
declare -a RELEASE=
declare -a CMTHASH=
RELEASE[0]="v0.1"; CMTHASH[0]="4d1b46b02798a1d3d3421b1c8087d80a80012a53"
RELEASE[1]="v0.2"; CMTHASH[1]="99c1bafbf1116c1400705803da45e1ac03f3d492"
RELEASE[2]="v0.3"; CMTHASH[2]="6e968d212ea62a1054e3cafa2436b6a98cf8776b"
RELEASE[3]="v1.0"; CMTHASH[3]="f6885f3482b95fe15a688135c441f8f6391c9529"
RELEASE[4]="v1.1"; CMTHASH[4]="9b653e64164e68873333043b41f8bbf23b0fbd55"
RELEASE[5]="v2.0"; CMTHASH[5]="deda452a0aab311f243311b48a39b7ac60ab3fd8"
RELEASE[6]="v3.0"; CMTHASH[6]="35141e1e20259d7d1c2f4b143c6ae4505d7d5045"
RELEASE[7]="v4.0"; CMTHASH[7]="428ed8058597a3530ec2d0207dda6ffed6082c0f"
RELEASE[8]="v5.x"; CMTHASH[8]="c769c14a73b53c741ef95ff21b88d752c18e474e"
RELEASE[9]="v5.0"; CMTHASH[9]="198fea2f4636949dad11ae710192e3fdb59ec446"
RELEASE[10]="v6.0"; CMTHASH[10]="6ab204b331ef4d6a5dc3fcc8c817b72147207af8"
RELEASE[11]="v7.0"; CMTHASH[11]="3e7b42964d34777a8d644b4602ea36132a8a6124"
RELEASE[12]="v8.x"; CMTHASH[12]="b0d58e1bbd67a8d62309725f208c84231a01f023"
RELEASE[13]="v8.0"; CMTHASH[13]="5ff6d062b683165da5bb0310256c07a041076f9b"
declare -a RELEASE_SKIP=(0 1 2 3 4 5 6 7 8 9 10 12)
########################################
declare CMTFIL="_commit"
declare COMMIT=
for FILE in \
${_TITLE} \
.setup \
.static \
; do
NEXT="$(cat /.g/_data/zactive{,/coding}/${FILE}.git/refs/heads/main 2>/dev/null)"
if [[ -n "${NEXT}" ]]; then
COMMIT="${COMMIT}${FILE}: ${NEXT}\n"
fi
done
########################################
declare RELEASE_LICENSES="
linux-fw-redistributable
freedist
OFL
fairuse
free-noncomm
"
################################################################################
declare LASTPIPE="$(shopt lastpipe | ${SED} "s%^.+(on|off)$%\1%g")"
if [[ ${LASTPIPE} == on ]]; then
LASTPIPE="-s"
else
LASTPIPE="-u"
fi
########################################
function variable_parse {
declare VARIABLE="${1}" && shift
declare V_SPACER="${1:- }" && shift
declare V_PREFIX="${1}" && shift
declare V_SUFFIX="${1}" && shift
declare V_CATGRY="${1:-false}" && shift
declare V_SELECT=
declare V_LOOPER=
for V_SELECT in ${VARIABLE}; do
echo "${!V_SELECT}" | ${SED} "s|${V_SPACER}|\n|g" | while read -r V_LOOPER; do
if [[ -n ${V_LOOPER} ]]; then
if ! ${V_CATGRY}; then
V_LOOPER="$(echo "${V_LOOPER}" | ${SED} "s|^[^${PACKDIRS_CSEP}]+[${PACKDIRS_CSEP}]||g")"
fi
echo "${V_PREFIX}${V_LOOPER}${V_SUFFIX}"
fi
done
done
return 0
}
########################################
function variable_match {
declare MARIABLE="${1}" && shift
declare M_SPACER="${1:- }" && shift
declare M_EQUALS="${1}" && shift
declare M_SUBDIR="${1:-false}" && shift
declare M_SELECT=
declare M_LOOPER=
shopt -s lastpipe
for M_SELECT in ${MARIABLE}; do
variable_parse ${M_SELECT} "${M_SPACER}" | while read -r M_LOOPER; do
if {
{ ! ${M_SUBDIR} && [[ "${M_EQUALS}" == "${M_LOOPER}" ]] ; } ||
{ ${M_SUBDIR} && [[ ${M_EQUALS} != ${M_EQUALS/#${M_LOOPER}\/} ]] ; };
}; then
shopt ${LASTPIPE} lastpipe
return 0
fi
done
done
shopt ${LASTPIPE} lastpipe
return 1
}
################################################################################
declare RUFUS_VER="4.4"
declare RUFUS_URL="https://github.com/pbatard/rufus/releases/download/v${RUFUS_VER}/rufus-${RUFUS_VER}p.exe"
########################################
declare SHMEM_SET="$(( 10 *(2**8) ))m"
declare SHMEM_BUF="$(( 3 *(2**8) *(2**20) ))"
declare XZ_MEMLIM="$(( 2 *(2**8) *(2**20) ))"
########################################
declare DU_L="${DU} --summarize --total --block-size 1M"
declare DU_S="${DU} --summarize --apparent-size --block-size 1"
########################################
declare REP_FILE="$(basename ${REPDIR})-repo"
declare CPIO_FILE="${_RAMFS}.cpio"
#note: this is an environment variable for "xz" and is not explicitly used in this script
#note: this is not for direct "xz" commands, but for "tar --xz" archiving
declare XZ_OPT_BASE="--threads=1 --memlimit=${XZ_MEMLIM} --extreme -9"
export XZ_OPT="--verbose ${XZ_OPT_BASE}"
declare XARGS="xargs --max-procs 0 --max-args 1 --null --arg-file ${CPIO_FILE}.nul"
declare CPIO_IN="cpio -v --create --format newc --null --file ${CPIO_FILE} --directory" #>>> ${TARGET}
declare CPIO_OUT="cpio -v --extract --file ${CPIO_FILE} --directory" #>>> ${CPIO_FILE}.dir
declare XZ="xz -vv --compress --stdout --format xz --check crc32"
########################################
declare PATCH="patch --force --strip=1"
declare PATCH_DIR="${ARTDIR}/patches"
declare -a PATCHES
#>>> PATCHES[0]="shmem-add-shmem_size-option-set-filesystem-size.v5.4-rc2.v5.6_updated.patch"
########################################
declare PACKDIRS_LINK="packdir"
declare PACKDIRS_DSEP="--"
declare PACKDIRS_CSEP=":"
declare PACKDIRS_PRNT="50"
#>>> for CHAR in {32..47} {58..64} {91..96} {123..126}; do printf "%3s" "${CHAR}"; printf " [\\$(printf "%0.3o" "${CHAR}")]\n"; done
#note: these must not be "[a-z]" and category names must be "[a-z]+[:]" for regular expressions to work properly
declare PACKDIRS_KEEP="*"
declare PACKDIRS_INST="+"
declare PACKDIRS_PACK="-"
declare PACKDIRS_GONE="|"
declare PACKDIRS_MARK="-"
declare PACKDIRS_DEFL="${PACKDIRS_INST}"
FSUPDT="
rc-service udev restart || true
rc-service modules restart || true
rc-service keymaps restart || true
${FSUPDT}
"
FSUPDT="$(echo "${FSUPDT}" | tr '\n' ';' | ${SED} -e "s|^;+||g" -e "s|;+$||g" -e "s|;| ; |g")"
#note: the "$repdir" and "$ldir" directories are packed in the "prepare_repdir" and "prepare_linux" functions, respectively
#note: adding them here ensures they will be handled properly by functions like "release_reset" and "release_unpack", as though they were regular archives
#note: the "$ldir-*" directories are handled in "$skipdirs" below
for FILE in ${MDIR} ${FDIR} ; do if ! variable_match "FSPACK FSKEEP FSARCH FSEXCL" ";" "${FILE}"; then FSPACK+="; ${_TITLE}:${FILE}"; fi; done
for FILE in ${REPDIR} ${LDIR} ${PDBDIR} ; do if ! variable_match "FSPACK FSKEEP FSARCH FSEXCL" ";" "${FILE}"; then FSKEEP+="; ${_TITLE}:${FILE}"; fi; done
for FILE in ${REPDIR}.git ; do if ! variable_match "FSPACK FSKEEP FSARCH FSEXCL" ";" "${FILE}"; then FSARCH+="; ${_TITLE}:${FILE}"; fi; done
for FILE in $((
find ${TARGET}/boot/{System.map,config,vmlinuz,initramfs}-*
find ${TARGET}/boot/*.old
find ${TARGET}/boot/_*
find ${TARGET}/etc/kernels -mindepth 1 -maxdepth 1
find ${TARGET}${MDIR} -mindepth 1 -maxdepth 1
) 2>/dev/null |
${GREP} -v "${KVER}-gentoo.${_TITLE}(.img)?$" |
${SED} "s|^${TARGET}||g" |
sort -u
) ; do if ! variable_match "FSPACK FSKEEP FSARCH FSEXCL" ";" "${FILE}"; then FSEXCL+="; ${_TITLE}:${FILE}"; fi; done
if ! ${DOTEST}; then
FSPACK="$(variable_parse FSPACK ";" "" "" true | sort -u | tr '\n' ';' | ${SED} -e "s|^;+||g" -e "s|;+$||g" -e "s|;| ; |g")"
FSKEEP="$(variable_parse FSKEEP ";" "" "" true | sort -u | tr '\n' ';' | ${SED} -e "s|^;+||g" -e "s|;+$||g" -e "s|;| ; |g")"
FSARCH="$(variable_parse FSARCH ";" "" "" true | sort -u | tr '\n' ';' | ${SED} -e "s|^;+||g" -e "s|;+$||g" -e "s|;| ; |g")"
FSEXCL="$(variable_parse FSEXCL ";" "" "" true | sort -u | tr '\n' ';' | ${SED} -e "s|^;+||g" -e "s|;+$||g" -e "s|;| ; |g")"
fi
declare PACKDIRS="
$(variable_parse FSPACK ";" "" "" true)
$(variable_parse FSKEEP ";" "" "" true)
$(variable_parse FSARCH ";" "" "" true)
"
declare PACKDIRS_LIST="
${PACKDIRS}
$(variable_parse FSEXCL ";" "" "" true)
"
if ! ${DOTEST}; then
PACKDIRS="$(variable_parse PACKDIRS "" "" "" true | sort -u)"
fi
declare PACKDIRS_HIDE="
${REPDIR}.git
"
declare PACKDIRS_SKIP="
${LDIR}\*/kernel/kheaders_data.tar.xz
/usr/lib/python\*/test/\*.tar.xz
/usr/share/calibre/hyphenation/dictionaries.tar.xz
/usr/share/fwupd/\*.tar.xz
/usr/share/genkernel/distfiles/\*.tar.xz
/usr/share/gettext/\*.tar.xz
"
########################################
declare ROOTFS_NAME="rootfs"
declare ROOTFS_FILE="${_RAMFS}.${ROOTFS_NAME}"
declare ROOTFS_CUST="false"
declare ROOTFS_TYPE="squashfs"
declare ROOTFS_COMP="-comp xz -b $((2**20)) -Xdict-size 100%"
declare ROOTFS_OPTS="-noappend -info -xattrs ${ROOTFS_COMP} -wildcards -ef" #>>> ${ROOTFS_FILE}.exclude"
declare ROOTFS_OPTS_MNT="xino=on"
declare ROOTFS_ROOT="/.${_TITLE}.${ROOTFS_NAME}"
declare ROOTFS_ROOT_SRC="${ROOTFS_ROOT/#\/\./\/${_TITLE}\/}"
declare ROOTFS_ROOT_OPT="groot"
declare ROOTFS_FUNC="rescue"
declare ROOTFS_LDD="${TARGET:+chroot ${TARGET} }ldd"
declare ROOTFS_BUSYBOX="busybox"
declare ROOTFS_COREUTILS="coreutils"
declare ROOTFS_BASH="bash"
declare ROOTFS_ETC="/etc"
declare ROOTFS_BIN="/usr/bin"
declare ROOTFS_LIB="/usr/lib64"
declare ROOTFS_PATH="${ROOTFS_BIN}:/$(basename ${ROOTFS_BIN})"
declare ROOTFS_SROOT="${ROOTFS_BIN}/switch_root"
declare ROOTFS_SHELL="/$(basename ${ROOTFS_BIN})/sh"
#>>> if [[ -n $(${ROOTFS_LDD} ${ROOTFS_BASH} 2>/dev/null | ${GREP} "not a dynamic executable") ]]; then
#>>> ROOTFS_SHELL="/$(basename ${ROOTFS_BIN})/${ROOTFS_BASH}"
#>>> fi
#note: update the "#{rootfs}" markers in "sets/gary-os" whenever "$rootfs_utils" changes
#note: verify accuracy using "${dotest}" in the "release_rootfs_cpio" function
#>>> tftp
declare ROOTFS_UTILS="
${ROOTFS_BASH}
strace
\
grep
make
rsync
sed
tar
wget
xz
\
exfatfsck
fsck
fsck.exfat
fsck.ext2
fsck.ext3
fsck.ext4
fsck.fat
fsck.vfat
mount
mount.exfat
mount.exfat-fuse
mount.fuse
mount.fuse3
mount.ntfs
mount.ntfs-3g
ntfs-3g
ntfsfix
umount
"
declare ROOTFS_FILES="
/.profile
/initrc
${ROOTFS_ETC}/inittab
"
declare ROOTFS_FILE_DIRS="
/run/mount
"
declare ROOTFS_FILE_VARS="
_GNAME
_TITLE
_VERSN
_RDATE
_GOVLY
_GUNPK
_GPACK
_GPASS
FUNTOO
FUNDAT
KVER
\
DOTEST
ROOTFS_NAME
ROOTFS_TYPE
ROOTFS_OPTS_MNT
ROOTFS_ROOT
ROOTFS_ROOT_SRC
ROOTFS_ROOT_OPT
ROOTFS_FUNC
ROOTFS_BASH
ROOTFS_PATH
ROOTFS_SROOT
ROOTFS_SHELL
"
########################################
function realdev {
#note: ported over directly from: https://github.com/garybgenett/runit/blob/master/runit/1
FILE="${1}" && shift
[ ! -d ${FILE}/pts ] && mkdir -m 0755 ${FILE}/pts
[ ! -d ${FILE}/shm ] && mkdir -m 0755 ${FILE}/shm
[ ! -c ${FILE}/console ] && mknod -m 0600 ${FILE}/console c 5 1
[ ! -c ${FILE}/kmsg ] && mknod -m 0666 ${FILE}/kmsg c 1 11
[ ! -c ${FILE}/null ] && mknod -m 0666 ${FILE}/null c 1 3
[ ! -c ${FILE}/random ] && mknod -m 0666 ${FILE}/random c 1 8
[ ! -c ${FILE}/rtc ] && mknod -m 0600 ${FILE}/rtc c 10 135
[ ! -c ${FILE}/tty0 ] && mknod -m 0600 ${FILE}/tty0 c 4 0
[ ! -c ${FILE}/urandom ] && mknod -m 0666 ${FILE}/urandom c 1 9
[ ! -c ${FILE}/zero ] && mknod -m 0666 ${FILE}/zero c 1 5
[ ! -L ${FILE}/core ] && ln -fns /proc/kcore ${FILE}/core
[ ! -L ${FILE}/fd ] && ln -fns /proc/self/fd ${FILE}/fd
[ ! -L ${FILE}/stderr ] && ln -fns /proc/self/fd/2 ${FILE}/stderr
[ ! -L ${FILE}/stdin ] && ln -fns /proc/self/fd/0 ${FILE}/stdin
[ ! -L ${FILE}/stdout ] && ln -fns /proc/self/fd/1 ${FILE}/stdout
return 0
}
declare DEVDIRS="
/dev
/mnt
/proc
/run
/sys
\
/tmp
/var/cache
/var/lock
/var/log
/var/run
/var/tmp
"
declare SKIPDIRS_GOS="
/.gitignore
/${CMTFIL}
\
/${_FINAL/#${TARGET}\/}
/${_RAMFS/#${TARGET}\/}*
\
${_GOVLY}
${_GUNPK}
${_GINST}
\
${ARCDIR}*
${GENDIR}*
"
declare SKIPDIRS_FUN="
${DSTDIR}
${PAKDIR}
\
${LDIR}-*
"
declare SKIPDIRS="
$(variable_parse SKIPDIRS_GOS)
${PACKDIRS_MARK}
$(variable_parse SKIPDIRS_FUN)
${PACKDIRS_MARK}
$(variable_parse PACKDIRS)
${PACKDIRS_MARK}
$(variable_parse FSARCH ";" "" ".tar.xz")
${PACKDIRS_MARK}
$(variable_parse FSEXCL ";")
$(variable_parse FSEXCL ";" "" ".tar.xz")
${PACKDIRS_MARK}
$(variable_parse DEVDIRS "" "" "/.*")
$(variable_parse DEVDIRS "" "" "/*")
"
if ! ${DOTEST}; then
SKIPDIRS="$(variable_parse SKIPDIRS | ${SED} "/^${PACKDIRS_MARK}$/d" | sort -u)"
fi
################################################################################
function common_exists {
declare SRC_FUNC="${1}" && shift
echo -en "\n"
echo -en ">>> THE OUTPUT FILES OF (${SRC_FUNC}) SEEM TO ALREADY EXIST <<<\n"
echo -en ">>> OR THE REQUIRED DIRECTORIES OR FILES ARE MISSING <<<\n"
echo -en "\n"
${LL} --directory "${@}"
echo -en "\n"
return 0
}
########################################
function common_tar {
declare SRC_FILE="${1}" && shift
if [[ ! -f ${SRC_FILE}.tar.xz ]] && [[ -d ${SRC_FILE} ]] && [[ ! -L ${SRC_FILE} ]]; then
tar --xz -cvv \
-C $(dirname ${SRC_FILE}) \
-f ${SRC_FILE}.tar.xz \
"${@}" \
$(basename ${SRC_FILE}) || return 1
else
common_exists ${FUNCNAME} \
${SRC_FILE}.tar.xz ${SRC_FILE} || return 1
fi
return 0
}
########################################
function common_untar {
declare SRC_FILE="${1}" && shift
if [[ -f ${SRC_FILE}.tar.xz ]] && [[ ! -d ${SRC_FILE} ]] && [[ ! -L ${SRC_FILE} ]]; then
FILE="$(dirname ${SRC_FILE})"
${MKDIR} ${FILE} || return 1
tar --xz -vvx \
-C ${FILE} \
-f ${SRC_FILE}.tar.xz \
"${@}" || return 1
else
common_exists ${FUNCNAME} \
${SRC_FILE}.tar.xz ${SRC_FILE} || return 1
fi
return 0
}
########################################
function common_gpkg_tar {
declare GPKG_DIR="image"
declare GPKG_SRC="${1}" && shift
tar -xO \
-f ${GPKG_SRC} \
$(basename ${GPKG_SRC/%.gpkg.tar})/${GPKG_DIR}.tar.xz \
| tar --xz --show-transformed-names --transform="s|^${GPKG_DIR}|.|g" \
-f - \
"${@/#=/${GPKG_DIR}}" || return 1
return 0
}
########################################
function common_packdir {
declare SRC_FILE="${1}" && shift
echo "${_RAMFS/#${_FINAL}\/}.${PACKDIRS_LINK}${SRC_FILE//\//${PACKDIRS_DSEP}}.tar.xz"
return 0
}
########################################
function common_packdirs_list {
${LL} --directory $(
variable_parse PACKDIRS_LIST "" "${TARGET}" | sort -u
variable_parse PACKDIRS_LIST "" "${TARGET}" ".tar.xz" | sort -u
) 2>/dev/null
echo -en "\n"; ${DU_L} $(variable_parse PACKDIRS_LIST "" "${TARGET}" | sort -u) 2>/dev/null
echo -en "\n"; ${DU_L} $(variable_parse PACKDIRS_LIST "" "${TARGET}" ".tar.xz" | sort -u) 2>/dev/null
return 0
}
################################################################################
#NOTE: CONSULT THE "SYSTEM INSTALLATION" TABLE IN "README" FOR THIS SECTION
#note: this is called statically in the "_system" script, under the "$_cfg" option
#note: cross-reference with the "release_install" function any time this changes
function _release_reset { #{ismain}
${RM} ${TARGET}/.gitignore || return 1
${RM} ${TARGET}/${CMTFIL} || return 1
${RM} ${TARGET}/.${_GPACK/%.txt}* || return 1
if [[ -n ${TARGET} ]]; then
${RM} ${TARGET}/.${_TITLE}* || return 1
fi
#note: checking if the output directory is a mounted filesystem or symlink
#note: this is created in the "release_unpack" function
FILE="$(findmnt --noheadings --output TARGET --target ${_FINAL})"
if [[ ${FILE} != ${_FINAL} ]] && [[ ! -L ${_FINAL} ]]; then
${RM} ${_FINAL} || return 1
else
${RM} ${_EAMARK} || return 1
${RM} ${_FINAL}/stage3-* || return 1
${RM} ${_FINAL}/_$(basename ${DSTDIR}) || return 1
${RM} ${_FINAL}/_$(basename ${PAKDIR}) || return 1
${RM} ${_RAMFS}* || return 1
fi
#note: all "prepare_*" functions that "#{isexit}" on "${doredo}"
DOREDO="true" _prepare_config || return 1
DOREDO="true" _prepare_packdirs || return 1
DOREDO="true" _prepare_symlinks || return 1
${RM} ${TARGET}${LDIR} || return 1
${LN} ${KBAS} ${TARGET}${LDIR} || return 1
return 0
}
########################################
function _release_review { #{ismain}
variable_parse SKIPDIRS
sleep 10
#note: initial rootfs size with "$fspack" and "$fskeep" still packed (kernel size)
#note: counting them in reverse, so that embedded packdirs get excluded
eval ${NCDU} $(
variable_parse SKIPDIRS | while read -r FILE; do
if variable_match FSEXCL ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSARCH ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSKEEP ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
if {
variable_match FSPACK ";" "${FILE}" true ||
variable_match FSKEEP ";" "${FILE}" true;
}; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
fi
elif variable_match FSPACK ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
if {
variable_match FSPACK ";" "${FILE}" true ||
variable_match FSKEEP ";" "${FILE}" true;
}; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
fi
else
echo "--exclude=\"${TARGET}${FILE}\""
fi
done
) ${TARGET} || return 1
#note: loaded rootfs size with "$fspack" unpacked and "$fskeep" still packed (memory size)
#note: counting them in reverse, so that embedded packdirs get excluded
eval ${NCDU} $(
variable_parse SKIPDIRS | while read -r FILE; do
if variable_match FSEXCL ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSARCH ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSKEEP ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
if {
variable_match FSKEEP ";" "${FILE}" true;
}; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
fi
elif variable_match FSPACK ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
if {
variable_match FSKEEP ";" "${FILE}" true;
}; then
echo "--exclude=\"${TARGET}${FILE}\""
fi
else
echo "--exclude=\"${TARGET}${FILE}\""
fi
done
) ${TARGET} || return 1
#note: final rootfs size with both "$fspack" and "$fskeep" unpacked (maximum memory size)
#note: counting them in reverse, so that embedded packdirs get excluded
eval ${NCDU} $(
variable_parse SKIPDIRS | while read -r FILE; do
if variable_match FSEXCL ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSARCH ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}\""
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSKEEP ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
elif variable_match FSPACK ";" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
else
echo "--exclude=\"${TARGET}${FILE}\""
fi
done
) ${TARGET} || return 1
#note: total filesystem size with all directories unpacked (completely loaded memory size)
eval ${NCDU} $(
variable_parse SKIPDIRS | while read -r FILE; do
if variable_match PACKDIRS "" "${FILE}"; then
echo "--exclude=\"${TARGET}${FILE}.tar.xz\""
else
echo "--exclude=\"${TARGET}${FILE}\""
fi
done
) ${TARGET} || return 1
echo -en "\n[FSPACK]\n"; variable_parse FSPACK ";" | sort -u
echo -en "\n[FSKEEP]\n"; variable_parse FSKEEP ";" | sort -u
echo -en "\n[FSARCH]\n"; variable_parse FSARCH ";" | sort -u
echo -en "\n[FSEXCL]\n"; variable_parse FSEXCL ";" | sort -u
echo -en "\n"; common_packdirs_list
return 0
}
################################################################################
function _prepare_build { #{doredo} #{dofast} #{dotest}
if ${DOREDO}; then
#note: all "prepare_*" functions that "#{isexit}" on "${doredo}"
#>>> DOREDO="true" _prepare_config || return 1
DOREDO="true" _prepare_packdirs || return 1
#>>> DOREDO="true" _prepare_symlinks || return 1
fi
if ! ${DOFAST}; then
DOREDO="false" _prepare_config || return 1
fi
DOTEST="${DOTEST}" _prepare_docdir || return 1
_prepare_packages || return 1
_prepare_repdir || return 1
_prepare_linux || return 1
DOREDO="false" _prepare_packdirs || return 1
DOREDO="false" _prepare_symlinks || return 1
return 0
}
########################################
function prepare_config_empty {
if [[ -n $(${GREP} "${_GNAME}" ${TARGET}/etc/{issue,mod} 2>/dev/null) ]]; then
return 1
fi
return 0
}
function prepare_config_issue {
${RSYNC_C} --copy-links ${ARTDIR}/files/issue ${TARGET}/etc/issue || return 1
for FILE in ${ROOTFS_FILE_VARS}; do
${SED} -i "s|[$][{]${FILE}[}]|${!FILE}|g" ${TARGET}/etc/issue || return 1
done
if {
{ [[ -z ${COMMIT} ]] || [[ ! -d ${_G_REPO} ]]; } ||
${_MOD};
}; then
#>>> declare BEG="Some helpful notes"
#>>> declare END="Build system"
declare RPL="Happy Hacking"
FILE=" "
#>>> FILE+="\\\e[1;45;37m"
FILE+="\\\e[0;35m"
if ${_MOD}; then
BEG="A couple of commands"
FILE+="THIS IS THE MINIMIZED VERSION OF THE BUILD AND WILL HAVE REDUCED FUNCTIONALITY"
else
FILE+="PLEASE NOTE THAT THIS BUILD HAS BEEN CUSTOMIZED AND IS NOT AN OFFICIAL RELEASE"
fi
FILE+="\\\e[0;37m"
#>>> ${SED} -i "/${BEG}/,/${END}/c\\${FILE}" ${TARGET}/etc/issue || return 1
${SED} -i "s|^(.*${RPL}.*)$|${FILE}\n\n\1|g" ${TARGET}/etc/issue || return 1
fi
if [[ ! -f ${TARGET}/usr/bin/startx ]]; then
${SED} -i "/startx/d" ${TARGET}/etc/issue || return 1
fi
${SED} \
-e "s|[\]e[[]([0-9]+[;])?[0-9]+[;][0-9]+m||g" \
-e "/^[\][a-z]/d" \
${TARGET}/etc/issue >${TARGET}/etc/motd
return 0
}
function prepare_config_restore { #>>>{doredo}
declare PACK="${1}" && shift
declare PFIL="${1}" && shift
declare PSRC="${1}" && shift
FILE="$(ls ${TARGET}${PAKDIR}/${PACK}-[.0-9]*.gpkg.tar 2>/dev/null | sort | tail -n1)"
if {
[[ -n ${PACK} ]] &&
[[ -f ${FILE} ]]
}; then
echo -en "\n"
echo -en ">>> RESTORING (${PFIL}) FROM (${PACK}) PACKAGE FILE <<<\n"
echo -en "\n"
NEXT="${PFIL}"
if [[ -n ${PSRC} ]]; then
NEXT="$(common_gpkg_tar ${FILE} -t --wildcards "*/${PSRC}" | sort | tail -n1)"
NEXT="${NEXT/#\.}"
if [[ -z ${NEXT} ]]; then
return 1
fi
fi
common_gpkg_tar ${FILE} -vvx -C ${TARGET} =${NEXT} || return 1
if [[ -n ${PSRC} ]]; then
if [[ -n $(file ${TARGET}${NEXT} | ${GREP} "bzip2") ]]; then
bzip2 -cd ${TARGET}${NEXT} >${TARGET}${PFIL} || return 1
else
${RSYNC_U} ${TARGET}${NEXT} ${TARGET}${PFIL} || return 1
fi
fi
${RSYNC_U} ${TARGET}${PFIL} ${TARGET}${PFIL}.${_TITLE} || return 1
elif {
[[ -f ${PFIL}.${_TITLE} ]]
}; then
echo -en "\n"
echo -en ">>> RESTORING (${PFIL}) FROM (${PFIL}.${_TITLE}) BACKUP FILE <<<\n"
echo -en "\n"
${RSYNC_U} ${TARGET}${PFIL}.${_TITLE} ${TARGET}${PFIL} || return 1
elif {
[[ -n $(${GREP} "^${PACK}$" ${TARGET}${ETCDIR}/sets/${_PKG}) ]] ||
[[ -n $(safe_env equery list '*' 2>&1 | ${GREP} "^${PACK}-[0-9]") ]]
}; then
echo -en "\n"
echo -en ">>> NO (${PACK}) PACKAGE FILE OR (${PFIL}.${_TITLE}) BACKUP FILE <<<\n"
echo -en ">>> BUT THERE IS A (${PACK}) ENTRY IN THE (${_PKG}) SET OR IT IS INSTALLED <<<\n"
echo -en ">>> LEAVING (${PFIL}) ALONE <<<\n"
echo -en "\n"
else
echo -en "\n"
echo -en ">>> NO (${PACK}) PACKAGE FILE OR (${PFIL}.${_TITLE}) BACKUP FILE <<<\n"
echo -en ">>> NO (${PACK}) ENTRY IN THE (${_PKG}) SET AND IT IS NOT INSTALLED <<<\n"
echo -en ">>> REMOVING (${PFIL}) FILE <<<\n"
echo -en "\n"
${RM} ${TARGET}${PFIL} || return 1
fi
if ${DOREDO}; then
${RM} ${TARGET}${PFIL}.${_TITLE} || return 1
fi
return 0
}
#NOTE: UPDATE THE "SYSTEM INSTALLATION" TABLE IN "README" WHEN MAKING CHANGES HERE
#note: this is called statically in the "_system" script
function _prepare_config { #{isexit} #{doredo}
if {
! ${DOREDO} &&
[[ -z ${TARGET} ]];
}; then
if ! prepare_config_empty; then
prepare_config_issue || return 1
fi
return 0
fi
#note: these are from the "prepare_config_issue" function above
DOREDO="${DOREDO}" prepare_config_restore sys-apps/baselayout /etc/issue || return 1
DOREDO="${DOREDO}" prepare_config_restore "null" /etc/motd || return 1
#note: these are to restore "$cfgscr" customizations
DOREDO="${DOREDO}" prepare_config_restore sys-auth/pambase /etc/pam.d/su || return 1
DOREDO="${DOREDO}" prepare_config_restore app-admin/sudo /etc/sudoers || return 1
#note: these are all directly below
DOREDO="${DOREDO}" prepare_config_restore "null" /init || return 1
DOREDO="${DOREDO}" prepare_config_restore sys-apps/sysvinit /etc/inittab || return 1
DOREDO="${DOREDO}" prepare_config_restore sys-apps/baselayout /etc/fstab fstab || return 1
DOREDO="${DOREDO}" prepare_config_restore sys-apps/locale-gen /etc/locale.gen || return 1
DOREDO="${DOREDO}" prepare_config_restore sys-apps/openrc /etc/conf.d/hostname || return 1
DOREDO="${DOREDO}" prepare_config_restore "null" /etc/profile.d/setterm.sh || return 1
DOREDO="${DOREDO}" prepare_config_restore net-wireless/wpa_supplicant /etc/wpa_supplicant/wpa_supplicant.conf wpa_supplicant.conf.bz2 || return 1
DOREDO="${DOREDO}" prepare_config_restore net-misc/openssh /etc/ssh/sshd_config || return 1
DOREDO="${DOREDO}" prepare_config_restore "null" /etc/env.d/90xsession || return 1
DOREDO="${DOREDO}" prepare_config_restore x11-wm/dwm /etc/X11/Sessions/dwm || return 1
if ${DOREDO}; then
${SED} -i "s|^[#](en_US)|\1|g" ${TARGET}/etc/locale.gen || return 1
safe_env /usr/sbin/locale-gen || return 1
safe_env /usr/sbin/env-update || return 1
return 0
fi
shopt -s lastpipe
variable_parse RCUPDT ";" | while read -r FILE; do
eval safe_env ${FILE} || return 1
done
shopt ${LASTPIPE} lastpipe
prepare_config_issue || return 1
${LN} --relative ${TARGET}/usr/bin/init ${TARGET}/init || return 1
${SED} -i "s|^[#](.+ttyS0.+vt100.*)$|\1|g" ${TARGET}/etc/inittab || return 1
${SED} -i "s|^([^#].+)$|#\1|g" ${TARGET}/etc/fstab || return 1
${RSYNC_C} --copy-links ${ARTDIR}/files/locale.gen ${TARGET}/etc/ || return 1
${SED} -i "s|^(hostname=[\"]?)[^\"]+([\"]?)$|\1${_TITLE}\2|g" ${TARGET}/etc/conf.d/hostname || return 1
echo -en "setterm -blength 0\n" >${TARGET}/etc/profile.d/setterm.sh || return 1
${RSYNC_C} --copy-links ${ARTDIR}/files/wpa_supplicant.conf ${TARGET}/etc/wpa_supplicant/ || return 1
${SED} -i "s|^.*(PermitRootLogin).*$|\1 yes|g" ${TARGET}/etc/ssh/sshd_config || return 1
echo -en "XSESSION=\"${WINMGR}\"\n" >${TARGET}/etc/env.d/90xsession || return 1
FILE= || return 1
FILE+="xset -b\n" || return 1
FILE+="xsetroot -mod 3 3 -fg '#000000' -bg '#404040'\n" || return 1
${SED} -i \
-e "/xset[ ][-]b/d" \
-e "/xsetroot[ ][-]mod/d" \
-e "s|^(exec[ ].*)$|${FILE}\1|g" \
${TARGET}/etc/X11/Sessions/dwm || return 1
${SED} -i "s|^(.*xsetroot[ ][-]name[ ]).*$|\1\"${WMHELP}\"|g" ${TARGET}/etc/X11/Sessions/dwm || return 1
safe_env /usr/sbin/locale-gen || return 1
safe_env /usr/sbin/env-update || return 1
echo -en "${_GPASS}\n${_GPASS}\n" | safe_env /usr/bin/passwd root || return 1
return 0
}
########################################
#note: cross-reference with the "release_install" function any time this changes
function _prepare_docdir { #{dotest}
if [[ -z ${TARGET} ]]; then
return 0
fi
declare G_REPO_GIT="${_G_REPO}.git"
declare G_REPO_SRC="${_G_REPO}"
declare G_REPO_OPT=
if [[ -n ${COMMIT} ]] && [[ -d ${_G_REPO} ]]; then
if ${DOTEST} && {
[[ -s ${SETDIR}/.gitignore ]] &&
[[ -s ${SETDIR}/Makefile ]];
}; then
G_REPO_SRC="${SETDIR}"
G_REPO_OPT="--copy-links"
fi
elif {
[[ -s ${SETDIR}/.gitignore ]] &&
[[ -s ${SETDIR}/Makefile ]];
}; then
G_REPO_GIT="${SETDIR}/.git"
G_REPO_SRC="${SETDIR}"
G_REPO_OPT=
else
#>>> ${RM} ${TARGET}/.${_TITLE} || return 1
return 0
fi
${MKDIR} ${TARGET}/.${_TITLE} || return 1
#note: cross-reference with the "release_unpack" function any time this changes
eval ${RSYNC_U} ${G_REPO_OPT} --delete-excluded \
--filter="-_/.git" \
--filter="P_/.git" \
$(${GREP} -v -e "^[#]" -e "^$" ${SETDIR}/.gitignore | while read -r FILE; do
echo "--filter=\"-_${FILE/%\/}\""
done) \
--filter="-_/.${_GPACK/%.txt}*" \
--filter="-_/build.${_GINST/#\/.}" \
${G_REPO_SRC}/ ${TARGET}/.${_TITLE} || return 1
if [[ -d ${G_REPO_GIT} ]]
then ${RSYNC_U} ${G_REPO_GIT}/ ${TARGET}/.${_TITLE}/.git || return 1
else ${RM} ${TARGET}/.${_TITLE}/.git || return 1
fi
if [[ -f ${TARGET}/.${_TITLE}/.git/config ]]; then
${SED} -i "/worktree[ ][=]/d" ${TARGET}/.${_TITLE}/.git/config || return 1
fi
#note: set the "makefile" to use "/" as the "$target" by default
${RM} ${TARGET}/.${_TITLE}/build || return 1
${LN} "/" ${TARGET}/.${_TITLE}/build || return 1
#note: the configuration files need to match the current state when everything is unpacked
#note: except if this is being called by the "release_install" function
if [[ ${TARGET} != ${_GINST} ]]; then
${SED} -i \
-e "s|^(override DOMODS[[:space:]]+[?][=]).*$|\1 ${DOMODS}|g" \
-e "s|^(override P[[:space:]]+[?][=]).*$|\1 ${_PKG}|g" \
${TARGET}/.${_TITLE}/Makefile || return 1
portage_file ${TARGET}/.${_TITLE}/gentoo || return 1
fi
return 0
}
########################################
function _prepare_packages {
if [[ -z ${TARGET} ]]; then
${RM} ${TARGET}/.${_GPACK} || return 1
return 0
fi
cat /dev/null >${TARGET}/.${_GPACK} || return 1
for FILE in $(
cd ${TARGET}${PAKDIR} &&
find ./ -mindepth 2 -maxdepth 2 -type f |
${SED} "s|^[.][/]||g" |
sort -u
); do
declare PKG_DB="$(cd ${TARGET}${PDBDIR} && ${LS} -d ${FILE/%.gpkg.tar} 2>/dev/null)" || return 1
declare PKG_DU="$(cd ${TARGET}${PAKDIR} && ${DU} -ks ${FILE} 2>/dev/null)" || return 1
if [[ -n ${PKG_DB} ]]; then
echo -en "${PKG_DU} (installed)\n" | tee -a ${TARGET}/.${_GPACK} || return 1
else
echo -en "${PKG_DU} (packaged)\n" | tee -a ${TARGET}/.${_GPACK} || return 1
fi
done
declare PACK_FILE="${_RAMFS}.kernel.${_GPACK}"
if ${_MOD}; then
PACK_FILE="${_RAMFS}.${_G_MOD}.kernel.${_GPACK}"
elif ${ROOTFS_CUST}; then
PACK_FILE="${_RAMFS}.rootfs.${_GPACK}"
fi
${MKDIR} ${_FINAL} || return 1
${RSYNC_U} ${TARGET}/.${_GPACK} ${PACK_FILE} || return 1
return 0
}
########################################
function _prepare_repdir {
if [[ -z ${TARGET} ]]; then
return 0
fi
declare ARC_FILE="${TARGET}${ARCDIR}/${REP_FILE}"
if [[ -f ${ARC_FILE}.tar.xz ]] && [[ -f ${ARC_FILE}.git.tar.xz ]]; then
${RSYNC_U} ${ARC_FILE}.tar.xz ${TARGET}${REPDIR}.tar.xz || return 1
${RSYNC_U} ${ARC_FILE}.git.tar.xz ${TARGET}${REPDIR}.git.tar.xz || return 1
fi
if [[ ! -f ${TARGET}${REPDIR}.tar.xz ]] || [[ ! -f ${TARGET}${REPDIR}.git.tar.xz ]]; then
${RM} ${ARC_FILE}{,.git}.tar.xz || return 1
${RM} ${TARGET}${REPDIR}{,.git}{,.tar.xz} || return 1
if [[ -d ${GITDIR} ]]; then
${MKDIR} ${TARGET}${REPDIR}.git || return 1
${RSYNC_U} ${GITDIR}/ ${TARGET}${REPDIR}.git || return 1
fi
safe_env ${MYSELF} ${QUIET_OPT} ${TOOR} ${AUTO} -U ${FUNTOO} || return 1
common_tar ${TARGET}${REPDIR} || return 1
common_tar ${TARGET}${REPDIR}.git || return 1
fi
if [[ ! -d ${TARGET}${REPDIR} ]] || [[ ! -d ${TARGET}${REPDIR}.git ]]; then
${RM} ${TARGET}${REPDIR}{,.git} || return 1
common_untar ${TARGET}${REPDIR} || return 1
common_untar ${TARGET}${REPDIR}.git || return 1
fi
if [[ ! -f ${ARC_FILE}.tar.xz ]] || [[ ! -f ${ARC_FILE}.git.tar.xz ]]; then
${RSYNC_U} ${TARGET}${REPDIR}.tar.xz ${ARC_FILE}.tar.xz || return 1
${RSYNC_U} ${TARGET}${REPDIR}.git.tar.xz ${ARC_FILE}.git.tar.xz || return 1
fi
return 0
}