-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsubmitqc
executable file
·1975 lines (1621 loc) · 65.9 KB
/
submitqc
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
#!/bin/sh
###>>>
###>>> Tiny Core Extension audit script - www.tinycorelinux.net
###>>>
###>>> Copyright (C) 2015 The Core Project & Tiny Core Linux Team (www.tinycorelinux.net)
###>>>
###>>> This program is free software; you can redistribute it and/or
###>>> modify it under the terms of the GNU General Public License
###>>> as published by the Free Software Foundation; either version 2
###>>> of the License, or (at your option) any later version.
###>>>
###>>> This program is distributed in the hope that it will be useful,
###>>> but WITHOUT ANY WARRANTY; without even the implied warranty of
###>>> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
###>>> GNU General Public License for more details.
###>>>
###>>> You should have received a copy of the GNU General Public License
###>>> along with this program; if not, write to the Free Software
###>>> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
###>>>
#<<
#<< CHANGES
#<<
#<< 20101206 - original written and managed by JasonW
#<< 2010-20140210 - many updates made by coreplayer2 and gordonselfish
#<< 20150708 - various changes by dentonlt
#<< query version/arch, comment code, use DEPLIST for ext loading by TC version,
#<< move md5 check to subroutine; work from squashfs; check net connection;
#<< added usage/help text, check dep file with base (not after), fix kernel grep pattern,
#<< re-order checking/reporting routines
#<< 20150917 - fix grep (add -m1) in checkinfo(); kudos to gordon64 for the bug report
#<< 20150919 - fix/rewrite perms/user/grp checking on files & dirs;
#<< add "--fix" option to force repair/change to file perms on scan
#<< kudos to gordon64 for the bug report leading to these changes; dentonlt
#<< 20150920 - fix Title check to ensure TESTING stays when present; check that
#<< binaries have been stripped; add --strip, add -c/--color; misc cleanup; dentonlt
#<< 20150921 - fixes to checkfileperms(); checkdiff as checklist; remove checkbasedir;
#<< rewrite checkinfo; add rotdash for processes that may take awhile; fix list-making
#<< code (drop opening .); add checkcopyright; add checkbuilddep; dentonlt
#<< 20151002 - remove code block in loadextensions, add dep file (thanks to coreplayer2 for
#<< bug reports leading to these changes); add check for copyright files in full
#<< extension tree (thanks coreplayer2 for this code); rm bin.list after checkstripping;
#<< swap order of checkmaintainer and checkinfo for clarity; dentonlt
#<< 20151004 - fix checkfileperms() where chmod would fail; various typos fixed; adjust/ensure
#<< skip network checks when appropriate; fix startup script/dir permissions (kudos
#<< to coreplayer2 for the bug report here, too!); dentonlt
#<< 20151005 - adjust rotdash placement in checkfileperms; add extension checking to
#<< checkdeps; dentonlt
#<< 20151007 - fix traps; create cleanonsignal(); adjust checkinfo to grep for
#<< "Extension[-_]by"; dentonlt
#<< 20151010 - checkinfo(): use both coreutils du and busybox du for size check;
#<< checkdeps(): check file structure (one dep per line); dentonlt
#<< 20151013 - add checklibs() for dynamic library checking; dentonlt
#<< 20151017 - move info/dep checks to before squashfs cks - dep ck req'd for
#<< accurate checklibs(); add checkempty(); var checklibs fixes; add core/arch options
#<< add changes & license options (GPLv2 was in Jason W's original info file); bugfix
#<< cleanonsignal (was leaving squashfs dir); dentonlt
#<< 20160204 - updated version checking; juanito
#<< 20160316 - add armv7l to ARCH testing, fix ARCH assignment bug (kudos andyj);
#<< change release text to 'unstable', request feedback on ARM; begin
#<< selfpackage() for cross-repo submission/updates; dentonlt
#<< 20190218 - bugfix (Rich) at lines 657, 834 (juanito)
#<< 20201109 - add aarch64 by polikuo (juanito)
#<< 20230308 - ensure correct ownerships and permissions (gnuser)
#<< 20230309 - fix startup script permissions in one place only (gnuser)
#<< 20230310 - 775 perm on startup script (cosmetic, to match wiki recommendation), fix version string (gnuser)
#<< 20230318 - rebuild squashfs only if necessary (gnuser)
#<< 20230826 - versioning, add logs for better tracking, VERSIONSTRING test adjusted;
#<< coding style, remove trailing white space, indention adjusted - no more tabs (polikuo)
#<< 20230827 - bugfix - tc:staff --> root:staff (polikuo)
#<< 20230828 - tune architecture detection, enable zsync for armv7 (polikuo)
#<< 20230831 - add function prepareinfo(), adjust everything accordingly. (polikuo)
#<< rewrite checkfileperms() for speed
#<< remove duplicate: checkbasicfileperms(), is a duplicate to checkfileperms()
#<< review check list - STUFF TO DO
#<< * Check that checkstartup applies changes BEFORE moving on to checkfileperms
#<< checked
#<< * if there is no startup file, but the current repository extension has one ... warn.
#<< checked
#<< * check for PPI compatibility [deprecated?]
#<< checked, it's deprecated
#<< 20230907 - minor bug fix, default behavior for permission check: warn --> fix (polikuo)
#<< 20240118 - checkinfo needs to ensure "Tags:" field exists, added --no-load flag (gnuser)
#<< 20240212 - cleanup fix/don't fix logic (gnuser)
#<< 20240528 - add --blocksize flag (gnuser)
#<< 20240915 - broader recognition of executable text files (gnuser)
#<< 20241215 - check for redundant dependencies (extension families) and remove them (make a backup) (Sashank999)
#<< 20241218 - redundant dependency check reimplemented in awk (Sashank999)
#<< 20241219 - add zsync to required deps, check source.tgz file contents, fetch .info file from repo if not present locally (Sashank999)
#<< 20250118 - add -KERNEL substitution to library dependency checking, remove SUID bits from directories, add error log for /lib64 dependency linking (Sashank999)
#<<
#<< STUFF TO DO
#<<
#<< * if usr/local/share/applications/ is included, expect $F.desktop and icon
#<< * if usr/local/share/pixmaps/ included, expect $F.png (icon file)
#<< * checktgz should check the content and structure of the tgz file (should this be xz?)
#<< * since this is a large script with many functions ...
#<< consider splitting it into smaller scripts (eg tc-ext-perms, tc-ext-startup, etc)
#<< that each check an area of settings and make adjustments as needed. Then use
#<< submitqc to call on those other scripts (and refer user to other scripts
#<< to check and fix individual issues/areas)
#<<
####################
# SETUP
####################
RUNDIR="$PWD"
SCRIPT=$(basename $0)
VERSIONSTRING="20241219"
[ $(echo "$VERSIONSTRING" | grep "$(date '+%Y%m%d')") ] && VERSIONSTRING="SOURCE RUN"
. /etc/init.d/tc-functions
COLOR=0
# handle cmdline args
for i in $*
do
case $i in
-c) COLOR=1 ;;
--color) COLOR=1 ;;
--kernel=*) KVER="${i#--kernel=}"; KERNELFORCE=1 ;;
--core=*) TCVER="${i#--core=}" ;;
--arch=*) ARCH="${i#--arch=}" ;;
--nonet) INET="nonet" ;;
--libs) LIBCHECK=1 ;;
-?) USAGE=1 ;;
-h) USAGE=1 ;;
--help) USAGE=1 ;;
--tcz=*) TCZLIST="$(basename ${i#--tcz=} .tcz).tcz" ;;
--no-fix) NOFIX=1 ;;
--strip) STRIP=1 ;;
--self-package) PACKAGING=1 ;;
--changes) cat $(which $0) | grep "^#<<" | sed 's/^#<<//' ; exit ;;
--license) cat $(which $0) | grep "^###>>>" | sed 's/^###>>>//' ; exit ;;
--no-load) NOLOAD=1 ;;
--blocksize=*) BLOCKSIZE="${i#--blocksize=}" ;;
*) # might be an extension filename/base
[ -e $(basename ${i} .tcz).tcz ] && TCZLIST=$(basename ${i} .tcz).tcz
;;
esac
done
# Reset color code variables unless --color is explicitly enabled.
# This is done in order to stay compatible with the old behaviour,
# which did not source /etc/init.d/tc-functions causing colors
# to just be ignored. Now it is sourced always, causing colored
# output as default behaviour.
if [ $COLOR = 0 ]; then
CRE=""
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
WHITE=""
NORMAL=""
fi
# set up list of extensions to check
if [ "$TCZLIST" ] && [ "$(dirname $TCZLIST)" != "." ]; then
echo "Run $SCRIPT in the same directory as your extension(s)."
exit 1
fi
[ -z "$TCZLIST" ] && TCZLIST="$(find -maxdepth 1 -name "*.tcz" | sed 's/^\.\///')"
[ -z "$KVER" ] && KVER="$(uname -r)"
[ -z "$TCVER" ] && TCVER="$(version | sed 's/\..*//')"
# [ -z "$TCVER_INT" ] && TCVER_INT="$(version | grep -o '^[0-9]*')"
[ -z "$BLOCKSIZE" ] && BLOCKSIZE=4096
TCVER=${TCVER%%.*}.x
# output usage
if [ ! "$PACKAGING" ]; then
if [ ! "${TCZLIST}" ] || [ "$USAGE" ]; then
echo ""
echo "submitqc is the Tiny Core extension submission quality testing tool."
echo "This unstable release ($VERSIONSTRING) is UNDER TESTING for TC5+, x86/x86_64/armv7."
echo "In particular, feedback/testing on Pi/ARM usage is welcome!"
echo ""
echo "Usage: $SCRIPT [-?|-h|--help] [--kernel=KVER] [--nonet] [--no-fix] \
[--tcz=TCZFILE] [TCZFILE] [--changes] [--license] [--no-load] [--blocksize=BLOCKSIZE]" | fmt -w 75 -u -t
echo ""
echo "Run $SCRIPT in the same directory as your extension(s). It will find & \
test tcz files in the run directory." | fmt -w 75 -ut
echo ""
echo "Options:"
echo ""
echo -e " -c --color\t\tUse colored text output"
echo -e " --kernel=KVER\t\tTest modules using KVER (default: \`uname -r\`)"
echo -e " --core=TCVER\t\tRefer to online repo for core TCVER (default: \`version\`)"
echo -e " --arch=ARCH\t\tRefer to online repo for architecture ARCH (default: \`uname -m\`)"
echo -e " --libs\t\tTry dynamic library inclusion tests (unstable; time-consuming)"
echo -e " --nonet\t\tDisable network-based checks"
echo -e " --no-fix\t\tDon't fix chmod/chown inconsistencies (default: fix)"
echo -e " --strip\t\tStrip any unstripped binaries (default: warn)"
echo -e " --changes\t\tView change and planning details"
echo -e " --self-package\tSelf-package under /tmp/${SCRIPT}-pkg/"
echo -e " --license\t\tView license details (GNU GPLv2)"
echo -e " --no-load\t\tDon't load any required extensions (coreutils, squashfs-tools, etc.)"
echo -e " --blocksize=BLOCKSIZE\tBlocksize in Bytes (default: 4096) (only for 64-bit)"
echo ""
echo "$SCRIPT is distributed under the terms of the GNU GPLv2. see --license."
echo ""
exit 0
fi
fi
# library/dep checking variables
# [ -z "$ARCH" ] && ARCH=$(uname -m)
# safest way to set ARCH
[ -z "$ARCH" ] && ARCH=$(. /etc/init.d/tc-functions; getBuild)
RAND="$(date +%s | md5sum | head -c4)"
REPO=/etc/sysconfig/tcedir/optional
REQLOG=/tmp/$SCRIPT/$$-$RAND.req # libs req'd
INCLOG=/tmp/$SCRIPT/$$-$RAND.dep # libs in deps
REPOLOG=/tmp/$SCRIPT/$$-$RAND.repo # libs in repo missing from extension
MIRROR="$(cat /opt/tcemirror)"
unset LIBS
unset CHECKLIST
# prepare TEMPLIST - used during signal trap cleanup
TEMPLIST="$REQLOG $INCLOG $REPOLOG *.dep-mirror"
# this is used during checklibs() to ignore dependency on system libs
BASELIBS='ANSI_X3.110.so ISO8859-15.so ISO8859-1.so ISO8859-2.so ld-2.20.so ld-linux-aarch64.so.1 ld-linux-armhf.so.3 ld-linux.so.2 ld-linux-x86-64.so.2 libanl-2.20.so libanl.so libanl.so.1 libblkid.so libblkid.so.1 libblkid.so.1.1.0 libc-2.20.so libcom_err.so libcom_err.so.2 libcom_err.so.2.1 libcrypt-2.20.so libcrypt.so libcrypt.so.1 libc.so.6 libdl-2.20.so libdl.so libdl.so.2 libe2p.so libe2p.so.2 libe2p.so.2.3 libext2fs.so libext2fs.so.2 libext2fs.so.2.4 libgcc_s.so libgcc_s.so.1 libm-2.20.so libm.so libm.so.6 libnsl-2.20.so libnsl.so libnsl.so.1 libnss_compat-2.20.so libnss_compat.so libnss_compat.so.2 libnss_dns-2.20.so libnss_dns.so libnss_dns.so.2 libnss_files-2.20.so libnss_files.so libnss_files.so.2 libpthread-2.20.so libpthread.so.0 libresolv-2.20.so libresolv.so libresolv.so.2 librt-2.20.so librt.so librt.so.1 libstdc++.so libstdc++.so.6 libstdc++.so.6.0.20 libsudo_noexec.so libsysfs.so libsysfs.so.2 libsysfs.so.2.0.1 libutil-2.20.so libutil.so libutil.so.1 libuuid.so libuuid.so.1 libuuid.so.1.3.0 libz.so libz.so.1 libz.so.1.2.8 linux-gate.so.1 linux-vdso.so.1 sudo_noexec.so UNICODE.so'
# case "$ARCH" in
# i686) ARCH="x86" ;;
# x86_64) [ -f /lib/ld-linux-x86-64.so.2 ] || ARCH="x86" ;;
# armv6*) ARCH="armv6";;
# armv7*)
# # Use raspi cpu revision to detect board
# # REV 1=BCM2836, 2=BCM2837, 3=BCM2711
# REV=$(cat /proc/cpuinfo | awk '/Revision/ {print $3}')
# REV=${REV:-6}
# case ${REV:2:1} in
# 1|2) ARCH="armv7";;
# 3) ARCH="armv7l";;
# *) echo "$SCRIPT: Unrecognized armv7 architecture. See --help." && exit 1 ;;
# esac
# ;;
# aarch64) ARCH="aarch64";;
# *) echo "$SCRIPT: Unrecognized architecture '$ARCH'. See --help." && exit 1 ;;
# esac
for KNOWN_ARCH in x86 x86_64 armv6 armv7 armv7l armhf aarch64; do
[ $ARCH = $KNOWN_ARCH ] && FOUND_KNOWN_ARCH=1
done
if [ -z "$FOUND_KNOWN_ARCH" ]; then
echo "$SCRIPT: Unrecognized architecture '$ARCH'. See --help."
exit 1
fi
# other global variables
REPO_URL="$(cat /opt/tcemirror)$TCVER/$ARCH/tcz"
FILE_INFO=$(mktemp -t submitqc.file.XXXXXX) # a temporary file to hold output from the "file" command
FILE_PERM=$(mktemp -t submitqc.perm.XXXXXX) # a temporary file to hold output from the "ls" command
AWK_CACHE=$(mktemp -t submitqc.cache.XXXXXX) # a temporary file for "awk" to hold stuff
CHANGES= # when script makes changes to extension, remember to rebuild
####################
####################
# SUPPORT FXNS
####################
####################
# clean up on failed run
cleanonsignal() {
# remove traps, in case this function fails
trap - SIGHUP SIGINT SIGQUIT SIGTERM SIGSTOP SIGABRT
echo
echo -e "\tCaught interrupt."
echo -en "\tKilling subprocesses ... "
sudo pkill -P $$ # kill any subprocesses (children of this process)
wait $$
echo "Ok."
echo -en "\tCleaning up temp files ... "
rm -f $FILE_INFO $FILE_PERM
[ "$TEMPLIST" ] && \
for E in $TEMPLIST; do
if [ -e /tmp/submitqc/$E ]; then
sudo rm -rf $E || echo -en "\n\tUnknown error removing /tmp/submitqc/$E"
elif [ -e $RUNDIR/$E ]; then
sudo rm -rf $RUNDIR/$E || echo -en "\n\tUnknown error removing $RUNDIR/$E"
fi
done
echo "Ok."
echo -e "\tLogs at /tmp/$SCRIPT will be removed on next run."
echo -e "\tExiting early."
exit 1
}
# announce script
announce() {
echo ""
echo "=============================================================="
echo "This is the Tiny Core extension submission quality testing tool."
# echo "This pre-release is UNDER TESTING for TC5/6 and x86/x86_64."
echo ""
echo "see --help for usage instructions."
echo ""
echo "Release: $VERSIONSTRING"
echo "=============================================================="
echo ""
echo "${GREEN}Checking against Core release $TCVER on $ARCH / $KVER ${NORMAL}"
echo ""
}
# self-packaging - cool!
selfpackage() {
# if [ "$TCVER_INT" -gt 5 ]; then
tce-load -i squashfs-tools
[ $? != 0 ] && echo "Need squashfs-tools!" && exit 1
# else
# tce-load -i squashfs-tools-4.x
# [ $? != 0 ] && echo "Need squashfs-tools-4.x!" && exit 1
# fi
# if [ "${ARCH}" != "armv7" ]; then
tce-load -i zsync
[ $? != 0 ] && echo "Need zsync!" && exit 1
# fi
# package this script for each repo ...
mkdir -p /tmp/${SCRIPT}-pkg
# get info file ... =)
if [ ! -e ${SCRIPT}.info ]; then
wget $(cat /opt/tcemirror)7.x/x86_64/tcz/${SCRIPT}.tcz.info
[ $? != 0 ] && echo "$SCRIPT: error fetching .info file - can't package!" && return 1
else
cp -f $SCRIPT.info /tmp/${SCRIPT}-pkg/$SCRIPT.tcz.info
fi
echo "Changes must be manually entered into the script itself. Info file editing, however,"
echo "is automated here."
read -p "Text for 'Current:' line in info file (enter single space for no change to info file): " APPEND
for CPU in armv7 x86 x86_64; do
for VER in 5 6 7; do
# no armv7 5.x repo
set -x
[ "$VER" -lt 6 ] && [ "$CPU" = "armv7" ] && continue
set +x
# clean out old packages ...
rm -rf /tmp/${SCRIPT}/$CPU/$VER
rm -rf /tmp/${SCRIPT}-pkg/$CPU/$VER
# place script
mkdir -p /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/bin/
cp -f ${0} /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/bin/
sudo chown root:root /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/bin/${SCRIPT}
sudo chmod 755 /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/bin/${SCRIPT}
# place copyright text
mkdir -p /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/share/doc/${SCRIPT}
cat ${0} | grep "###>>>" | sed 's/^###>>>//' > \
/tmp/${SCRIPT}/$CPU/$VER/root/usr/local/share/doc/${SCRIPT}/COPYING
sudo chown root:root /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/share/doc/${SCRIPT}/COPYING
sudo chmod 644 /tmp/${SCRIPT}/$CPU/$VER/root/usr/local/share/doc/${SCRIPT}/COPYING
#set dir perms ...
find /tmp/${SCRIPT}/$CPU/$VER/root -type d \
-exec sudo chown root:root {} \;
find /tmp/${SCRIPT}/$CPU/$VER/root -type d \
-exec sudo chmod 755 {} \;
# create DEP file ...
DEPLIST="file diffutils wget coreutils grep binutils"
if [ "$VER" -gt "5" ]; then
DEPLIST="$DEPLIST squashfs-tools"
else
DEPLIST="$DEPLIST squashfs-tools-4.x"
fi
if [ "$CPU" != "arm" ]; then
DEPLIST="$DEPLIST zsync"
fi
for F in $DEPLIST; do
echo "$F.tcz" >> /tmp/submitqc/$CPU/$VER/submitqc.tcz.dep
done
# make squashfs
mksquashfs /tmp/${SCRIPT}/$CPU/$VER/root /tmp/${SCRIPT}/$CPU/$VER/submitqc.tcz -b "$BLOCKSIZE"
# make file list
cd /tmp/${SCRIPT}/$CPU/$VER/root/
find -not -type d > ../${SCRIPT}.tcz.list
sed -i 's/^\.//' ../${SCRIPT}.tcz.list # drop opening '.'
cd -
# remove installation tree
sudo rm -rf /tmp/${SCRIPT}/$CPU/$VER/root
# make md5sum ...
cd /tmp/${SCRIPT}/$CPU/$VER
md5sum ${SCRIPT}.tcz > /tmp/${SCRIPT}/$CPU/$VER/${SCRIPT}.tcz.md5.txt
cd -
# if [ "$ARCH" != "armv7" ]; then
# make zsync
cd /tmp/${SCRIPT}/$CPU/$VER
zsyncmake -u ${SCRIPT}.tcz ${SCRIPT}.tcz
cd -
# fi
if [ "$APPEND" ] && [ ! "$APPEND" = " " ]; then
# append updated change details to info file ...
grep -v "Current:" ${SCRIPT}.tcz.info > \
/tmp/${SCRIPT}/$CPU/$VER/${SCRIPT}.tcz.info
echo -e "\t\t\t\t$(grep "Current:" $SCRIPT.tcz.info | \
sed 's/^Current:[ \t]*//')" >> \
/tmp/${SCRIPT}/$CPU/$VER/$SCRIPT.tcz.info
echo -e "\nCurrent:\t\t$(date +%Y/%m/%d) $APPEND" >> \
/tmp/${SCRIPT}/$CPU/$VER/$SCRIPT.tcz.info
else
cp /tmp/${SCRIPT}-pkg/${SCRIPT}.tcz.info /tmp/${SCRIPT}/$CPU/$VER/
fi
# create tar ...
cd /tmp/$SCRIPT/$CPU/$VER/
tar -czf ${SCRIPT}.tar.gz *
cd -
done # per TC repo
mv /tmp/$SCRIPT/$CPU /tmp/${SCRIPT}-pkg/
done # per arch
rm /tmp/${SCRIPT}-pkg/${SCRIPT}.tcz.info
echo
echo "${SCRIPT}: Ok! See /tmp/${SCRIPT}-pkg subdirectories for individual extensions."
return 0
}
# load extensions
loadextensions() {
echo -n "${BLUE}$SCRIPT: loading required extensions ... ${NORMAL}"
# load dependencies
# if [ "$TCVER_INT" -gt "5" ]; then
# DEPLIST="file diffutils squashfs-tools wget coreutils grep"
# else
# DEPLIST="file diffutils squashfs-tools-4.x wget coreutils grep"
# fi
# TC is removing the 4.x release, do we still need this checker ?
DEPLIST="file diffutils squashfs-tools wget coreutils grep zsync"
# not available on arm at 20160316
# totally fine now 20230828
# [ ! "$ARCH" = "armv7" ] && DEPLIST="$DEPLIST zsync binutils"
for FILE in $DEPLIST; do
if [ ! -e "/usr/local/tce.installed/$FILE" ]; then
tce-load -i $FILE
[ $? != 0 ] && echo "${RED}$SCRIPT: Error in tce-load. Halting ${NORMAL}" && exit 1
fi
done
echo "${GREEN}Done.${NORMAL}"
}
# remove/clear old log files ...
cleanuplogs() {
echo -n "${BLUE}$SCRIPT: removing old log files. ${NORMAL}"
rm -rf /tmp/submitqc
echo "${GREEN}Ok.${NORMAL}"
echo -n "${BLUE}$SCRIPT: making space for new log files. ${NORMAL}"
mkdir -p /tmp/submitqc/missingdeps
echo "${GREEN}Done.${NORMAL}"
}
# check that network connection (mirror) is up
checknetwork() {
# test for network connection - needed for for checking against repository ...
if [ "$INET" = "nonet" ]; then
echo -n "${YELLOW}$SCRIPT: '--nonet': networking disabled on command line. ${NORMAL}"
INET=
return
fi
INFO_LST_URL=${REPO_URL}/info.lst.gz
DEP_DB_URL=${REPO_URL}/dep.db.gz
OLDLIST="$TEMPLIST"
TEMPLIST="$TEMPLIST cnxn.test"
(
echo -n "${BLUE}$SCRIPT: checking $(cat /opt/tcemirror) (timeout 3 sec) ... ${NORMAL}"
wget --spider -q --timeout=3 ${INFO_LST_URL} 2>&1 > /dev/null
if [ $? = 0 ]; then echo "exists" > /tmp/submitqc/cnxn.test
else echo "down" > /tmp/submitqc/cnxn.test
fi
) &
rotdash $!
[ -e "/tmp/submitqc/cnxn.test" ] && \
[ -n "$(grep "exists" /tmp/submitqc/cnxn.test)" ] && INET=1
rm -f /tmp/submitqc/cnxn.test
TEMPLIST="$OLDLIST"
# download list of available extensions
if [ $INET ]; then
echo "${GREEN}Connected!${NORMAL}"
{
echo -n "${BLUE}$SCRIPT: fetching info.lst.gz and dep.db.gz ... ${NORMAL}"
wget -q -O /tmp/submitqc/.info.lst.gz ${INFO_LST_URL} &&\
gunzip /tmp/submitqc/.info.lst.gz && \
sed -i 's:.tcz::g' /tmp/submitqc/.info.lst
wget -q -O /tmp/submitqc/.dep.db.gz ${DEP_DB_URL} &&\
gunzip /tmp/submitqc/.dep.db.gz
} || {
echo -e "\n${YELLOW}Error in fetch - some tests will be skipped.${NORMAL}"
INET=
}
echo "${GREEN}Ok.${NORMAL}"
else
echo -e "\n\t${YELLOW}Connection or mirror down - some tests will be skipped.${NORMAL}"
fi
}
# check that the extension mounts alright
checkmount() {
echo -n "${BLUE}$SCRIPT: ${F} mountable? ${NORMAL}"
# if SQUASHDIR it just happens to already exist ... get rid of it
df | grep "$SQUASHDIR" > /dev/null 2>&1 && sudo umount "$SQUASHDIR"
rm -rf /tmp/submitqc/"$SQUASHDIR"
# if file is not a squashfs ... skip it.
if [ "$(file ${F} | grep 'Squashfs' | cut -f1 -d':')" != "$F" ]; then
echo "${RED} Not a valid tcz - not squashfs. Remake.${NORMAL}"
echo $F >> /tmp/submitqc/corrupttcz
return 1
fi
# try to mount
(
mkdir -p "${SQUASHDIR}"
sudo mount -o loop ${F} ${SQUASHDIR} 2>&1 > /dev/null
if [ $? != 0 ]; then
echo "${RED}Error mounting - remake.${NORMAL}"
echo "$F" >> /tmp/submitqc/corrupttcz
return 1
fi
# umount
sudo umount -d "$SQUASHDIR"
sleep 2
rm -rf "$SQUASHDIR"
) &
rotdash $!
echo "${GREEN}Passed mount check.${NORMAL}"
return 0
}
# check that blocksize is what user expects (4096 B is default)
checkblock() {
echo -n "${BLUE}$SCRIPT: ${F} correct block size? ${NORMAL}"
if ! unsquashfs -s "$F" | grep "Block size" | grep "$BLOCKSIZE" > /dev/null; then
echo "${YELLOW}Not in $BLOCKSIZE block size. Extension will be rebuilt.${NORMAL}"
CHANGES=1
else
echo "${GREEN}Yes.${NORMAL}"
fi
} # end checkblock()
# check that squashfs has something in it
checkempty() {
echo -n "${BLUE}$SCRIPT: ${F} squashfs tree has files in it? ${NORMAL}"
if [ "$(unsquashfs -ls $F | grep squashfs-root | wc -l)" = "1" ]; then
echo -e "\n\t${RED}It appears $F is empty! Remake.${NORMAL}"
echo "$F" >> /tmp/submitqc/emptysquashfs
return 1
fi
echo "${GREEN}Ok.${NORMAL}"
return 0
}
# check for excess (or missing) file trees inside of squashfs
checkappend() {
echo -n "${BLUE}$SCRIPT: ${F} squashfs tree ok? ${NORMAL}"
if [ "$(find -maxdepth 1 -name 'usr_')" ]; then
echo "${RED} It appears $F contains more than one squashfs tree. Remake.${NORMAL}"
echo "$F" >> /tmp/submitqc/appendeddata
return 1
fi
echo "${GREEN}Ok.${NORMAL}"
return 0
} # end checkappend()
# if ext has a startup file, check startup name, permissions, location, etc.
checkstartup() {
echo -n "${BLUE}${SCRIPT}: ${F} startup files ok? ${NORMAL}"
local DIRERROR SSDIR SS
if ! grep -q 'usr/local/tce.installed' $FILE_PERM; then
echo "${GREEN}None present. Ok, I think.${NORMAL}"
return # no startup script
fi
# count files in startup script dir; get name of startup script
SSDIR="usr/local/tce.installed/"
# SS="$(ls -A $SSDIR)"
# COUNT="$(echo "$SS" | wc -l)"
COUNT=$(grep $SSDIR $FILE_PERM | wc -l)
# startup script is a file, not directory
if grep $SSDIR $FILE_PERM | grep -q '^d'; then
echo "${RED}${F}: directories found. Repair manually.${NORMAL}"
grep $SSDIR $FILE_PERM | grep '^d'
echo "${F}: directories found. Repair manually." >> /tmp/submitqc/startupscript
fi
# is there only 1 startup file, named same as extension?
case $COUNT in
0) echo -e "${RED}Has startup folder but no script. Repair manually.${NORMAL}"
echo -e "${F}: startup folder without script. Repair manually." \
>> /tmp/submitqc/startupscript
;;
1) SS=$(grep $SSDIR $FILE_PERM)
SS=${SS##*/}
if [ "${SS}" != "${BASENAME}" ]; then
echo -ne "\n${YELLOW}script name ($SS) is incorrect. Renaming ${BASENAME}. ${NORMAL}"
echo "$F startup named $SS renamed $BASENAME" >> /tmp/submitqc/wrongstartscriptname
# SS="$(find $SSDIR -not -type d | tail -n 1)"
# mv "${SS}" "${SSDIR}${BASENAME}"
mv "./usr/local/tce.installed/${SS}" "./usr/local/tce.installed/${BASENAME}"
echo "${YELLOW}Done.${NORMAL}"
CHANGES=1
fi
;;
*) echo -e "${RED}Multiple startup files, none named $F. Repair manually.${NORMAL}"
echo -e "${F}: multiple startup files, none named $F. Repair manually." \
>> /tmp/submitqc/startupscript
;;
esac
DIRERROR=
if [ ! "$(stat -c%a ${SSDIR})" = 775 ]; then
sudo chmod 775 "usr/local/tce.installed"
echo -ne "\n\t${YELLOW}Startup directory permissions were corrected.${NORMAL}"
DIRERROR=1
fi
if [ "$(stat -c'%U %G' ${SSDIR})" != "root staff" ]; then
sudo chown root:staff "${SSDIR}"
echo -ne "\n\t${YELLOW}Startup directory ownership was corrected.${NORMAL}"
DIRERROR=1
fi
if [ ! "$(stat -c%a ${SSDIR}/$BASENAME)" = 775 ]; then
sudo chmod 775 "${SSDIR}/$BASENAME"
echo -ne "\n\t${YELLOW}Startup script permissions were corrected.${NORMAL}"
DIRERROR=1
fi
if [ ! "$(stat -c'%U %G' ${SSDIR}/$BASENAME)" = "root staff" ]; then
sudo chown root:staff "${SSDIR}/$BASENAME"
echo -ne "\n\t${YELLOW}Startup script ownership was corrected.${NORMAL}"
DIRERROR=1
fi
if [ $DIRERROR ]; then
echo "$F" >> /tmp/submitqc/wrongstartscriptperms
CHANGES=1
echo
else
echo "${GREEN}Ok.${NORMAL}"
fi
} # end checkstartup()
# look for COPYING or other text file at usr/local/share/doc/$BASENAME
checkcopyright() {
echo -n "${BLUE}$SCRIPT: $F includes copyright notice? ${NORMAL}"
E=${BASENAME##*-}
[ ${E} = "doc" ] || [ ${E} = "locale" ] || [ ${E} = "dev" ] && \
echo "${GREEN}Not needed for -${F##*-}. Done.${NORMAL}" && return
COPYRIGHTFILES="/tmp/submitqc/$F.copyrightfiles"
# look for copyright dir + files. If missing, no good.
if [ ! -e "usr/local/share/doc/$BASENAME" ] \
|| [ "$(find usr/local/share/doc/$BASENAME -type f | wc -l)" = 0 ]; then
MISSING=1
fi
if [ "$MISSING" ]; then
echo -e "\n\t${YELLOW}Copyright notice not found at usr/local/share/doc/$BASENAME${NORMAL}"
echo -e "\t${YELLOW}Confirm that this is not needed.${NORMAL}"
# courtesy: look for copyright info in tree (kudos coreplayer2 for this)
# LICENSEFILES="license copying copyright"
# for c in ${LICENSEFILES}; do
# find . -type f -iname "${c}*" >> $COPYRIGHTFILES
# done
# (polikuo) don't use "for loop"
grep -i 'license\|copying\|copyright' $FILE_INFO | cut -d ' ' -f 4 >> $COPYRIGHTFILES
# remove any blank lines from COPYRIGHTFILES list
sed -i '/^$/d' $COPYRIGHTFILES
if [ "$(cat $COPYRIGHTFILES | wc -l)" != 0 ]; then
echo -e "\n\t${YELLOW}Possible copyright files found:${NORMAL}"
echo -e "${YELLOW}$(cat $COPYRIGHTFILES | sed 's/^/\t\t/g')${NORMAL}"
else
rm $COPYRIGHTFILES
fi
unset FOUND
if [ $INET ]; then
# courtesy: check if it's in the repo copy ...
echo -e "\t${YELLOW}Checking repo for copyright statement in $F ...${NORMAL}"
REPOLIST="/tmp/submitqc/${F}.repolist"
wget -O ${REPOLIST} "$REPO_URL"/"$F".list > /dev/null 2>&1
if [ $? = 0 ]; then
if [ "$(grep "usr/local/share/doc/$BASENAME" $REPOLIST)" ]; then
REMOTECOPYRIGHT=1
echo -e "\t${RED}Repository copy of $F includes a copyright statement.${NORMAL}"
else
echo -e "\t${GREEN}Repo copy of $F does NOT include copyright statement.${NORMAL}"
fi
else
echo -e "\t${YELLOW}$F not found on server.${NORMAL}"
fi
fi
echo "$F: copyright information not found at usr/local/share/doc/$BASENAME/" >> \
/tmp/submitqc/copyright
[ $REMOTECCOPYRIGHT ] && echo -e "\tRepository copy includes a copyright statement." >> \
/tmp/submitqc/copyright
else
echo -e "${GREEN}Looks ok.${NORMAL}"
fi
unset MISSING
unset REMOTECOPYRIGHT
} # end checkcopyright
# check permissions of all files/directories
checkfileperms() {
# define the scope of these variables
local D_RR D_755 F_RR F_755 F_644 P_OUT
echo -n "${BLUE}$SCRIPT: $F file/directory ownerships & permissions ok? ${NORMAL}"
LOG="/tmp/submitqc/fileperms"
# the startup directory was tested in checkstartup(). Ignore it at this point.
# Find directories without root:root and/or 755. Skip tce.installed.
# Test all files. root:root. executables 755, others 644. Skip tce.installed.
# D_RR, F_RR, D_755, F_755, F_644
awk '!/tce.installed/' $FILE_PERM > $AWK_CACHE
D_RR=$(awk '/^d/ && $2 $3 != "root" "root" {print $NF}' $AWK_CACHE)
F_RR=$(awk '/^[^d]/ && $2 $3 != "root" "root" {print $NF}' $AWK_CACHE)
D_755=$(awk '/^d/ && !/^drwxr-xr-x/ {print $NF}' $AWK_CACHE)
# The filenames may disrupt with the pattern matching if you simply use /executable/
# For instance, if a file is call "README-about-executable.txt"
# It would go into F_644, which is unwanted behavior
awk '/^[^d]/ && !/^-rwxr-xr-x/ && !/tce.installed/ {print $NF}' $FILE_PERM > $AWK_CACHE
F_755=$(awk -v FS=": " -v cache="$AWK_CACHE" 'BEGIN{while(getline buff < cache)P[buff]=1}
P[$1] && (/: .*executable/ || /: .*script/ || /: .*shared object/) {print $1}' $FILE_INFO)
awk '/^[^d]/ && !/^-rw-r--r--/ && !/tce.installed/ {print $NF}' $FILE_PERM > $AWK_CACHE
F_644=$(awk -v FS=": " -v cache="$AWK_CACHE" 'BEGIN{while(getline buff < cache)P[buff]=1}
P[$1] && !/: .*executable/ && !/: .*script/ && !/: .*shared object/ && !/: .*symbolic link/ {print $1}' $FILE_INFO)
if [ "${D_RR}${F_RR}${D_755}${F_755}${F_644}" ]; then
# if anything
printf "\n\n"
# may contain current directory ".", remove "./" first
# output format should be "usr/local/bin/binary"
# root:root
if [ "${D_RR}${F_RR}" ]; then
P_OUT=$(echo "${D_RR}${F_RR}" | sort -u)
P_OUT=$(echo "$P_OUT" | sed -e '/^[[:blank:]]*$/d' -e 's_^\./__' -e 's_^_\t\t_')
echo -e "\t${YELLOW}Expected root:root ownership:\n${P_OUT}${NORMAL}\n"
fi
# 755
if [ "${F_755}${D_755}" ]; then
P_OUT=$(echo "${F_755}${D_755}" | sort -u)
P_OUT=$(echo "$P_OUT" | sed -e '/^[[:blank:]]*$/d' -e 's_^\./__' -e 's_^_\t\t_')
echo -e "\t${YELLOW}Expected 755 permission:\n${P_OUT}${NORMAL}\n"
fi
# 644
if [ "$F_644" ]; then
P_OUT=$(echo "$F_644" | sort -u | sed -e 's_^\./__' -e 's_^_\t\t_')
echo -e "\t${YELLOW}Expected 644 permission:\n${P_OUT}${NORMAL}\n"
fi
# logging
echo "${F}: Some directory or file permissions were incorrect or non-standard." >> $LOG
[ "$D_RR" ] && echo -e "Directories - Expected root:root:\n${D_RR}\n">> $LOG
[ "$D_755" ] && echo -e "Directories - Expected 755:\n${D_755}\n" >> $LOG
[ "$F_RR" ] && echo -e "Files - Expected root:root:\n${F_RR}\n">> $LOG
[ "$F_755" ] && echo -e "Files - Expected 755:\n${F_755}\n" >> $LOG
[ "$F_644" ] && echo -e "Files - Expected 644:\n${F_644}\n" >> $LOG
# Fixing
if [ -z "$NOFIX" ]; then
# fix permission/ownership errors
echo -e "\t${YELLOW}fixing inconsistencies ... ${NORMAL}"
if [ "${D_RR}${F_RR}" ]; then
echo -e "\t${YELLOW}chown root:root files and directories${NORMAL}"
# sudo chown root:root $D_RR $F_RR
# use '-h' so it affects the links
# guard the command length with awk
echo -e "${D_RR}\n${F_RR}" | sudo awk 'BEGIN{E=0}{
if(length(buff " " $0) > 130000) {
e=system("chown -h root:root" buff)
E = E || e
buff = ""
}
buff = buff " " $0
} END {
if(buff) {
e=system("chown -h root:root" buff)
E = E || e
}
exit E
}'
[ $? != 0 ] && echo -e "\n${RED}Error in chown - halting.${NORMAL}" && exit 1
fi
if [ "${F_755}${D_755}" ]; then
echo -e "\t${YELLOW}chmod 755 executable files and directories${NORMAL}"
# MODETMP=/tmp/submitqc/mode-sample-$(date +%s | head -c4)
# touch $MODETMP # using just chmod 755 doesn't adjust sticky bit
# sudo chmod 755 $MODETMP
# sudo chmod --reference=$MODETMP $D_755 $F_755
# rm -f $MODETMP
# just use 'chmod 0755'
# Using 'chmod 00755' so that sticky bit for directories is also removed.
echo -e "${F_755}\n${D_755}" | sudo awk 'BEGIN{E=0}{
if(length(buff " " $0) > 130000) {
e=system("chmod 00755" buff)
E = E || e
buff = ""
}
buff = buff " " $0
} END {
if(buff) {
e=system("chmod 00755" buff)
E = E || e
}
exit E
}'
[ $? != 0 ] && echo -e "\n${RED}Error in chmod - halting.${NORMAL}" && exit 1
fi
if [ "$F_644" ]; then
echo -e "\t${YELLOW}chmod 644 normal files${NORMAL}"
# sudo chmod 644 $F_644
echo "$F_644" | sudo awk 'BEGIN{E=0}{
if(length(buff " " $0) > 130000) {
e=system("chmod 00644" buff)
E = E || e
buff = ""
}
buff = buff " " $0
} END {
if(buff) {
e=system("chmod 00644" buff)
E = E || e
}
exit E
}'
[ $? != 0 ] && echo -e "\n${RED}Error in chmod - halting.${NORMAL}" && exit 1
fi
echo "${F}: These errors were corrected." >> $LOG
touch /tmp/submitqc/changes # rebuild tcz
echo -e "${GREEN}Ok.${NORMAL}"
else
echo -e "\t${RED}You have warnings. See /tmp/submitqc/fileperms.${NORMAL}"
echo -e "${RED}\tTo set defaults, omit the --no-fix flag.${NORMAL}"
# log it:
echo "To set defaults, omit the --no-fix flag." >> $LOG
fi
else
echo -e "${GREEN}Ok.${NORMAL}"
fi
[ -e /tmp/submitqc/changes ] && CHANGES=1 && rm /tmp/submitqc/changes
}
# Warn elfs linked to /lib64/
checklib64() {
echo -n "${BLUE}$SCRIPT: $F has any /lib64 dependencies?${NORMAL}"
FOUND=false
for file in $(find . -type f); do
if ldd "$file" 2>/dev/null | grep -q "/lib64/"; then
if ! $FOUND; then
echo "${YELLOW}The following ELFs are linked to /lib64.${NORMAL}"
echo "The following ELFs are linked to /lib64." >> /tmp/submitqc/lib64linkerrors
FOUND=true
fi
echo "${YELLOW}$file is linked to /lib64.${NORMAL}"
echo "$file is linked to /lib64." >> /tmp/submitqc/lib64linkerrors
fi
done
if $FOUND; then
echo "${RED}Compiled ELFs are linked to /lib64.${NORMAL}"
echo "${RED}Please link to /lib or /usr/local/lib directories instead.${NORMAL}"
echo "Compiled ELFs are linked to /lib64." >> /tmp/submitqc/lib64linkerrors
echo "Please link to /lib or /usr/local/lib directories instead." >> /tmp/submitqc/lib64linkerrors
else
echo "${GREEN} None.${NORMAL}"
fi
}
# check binaries have been stripped
checkstripping() {
echo -n "${BLUE}$SCRIPT: $F binaries have been stripped? ${NORMAL}"
# get a list of all un-stripped binaries.
# unlikely, but filenames may contain colons ":"
# for compilers, gcc or clang, some object files should not be stripped.
BIN=$(grep 'not stripped' $FILE_INFO | grep -v 'relocatable' | sed 's_: .*__g')
# (
# find -type f -exec file {} \; | grep 'not stripped' | cut -f1 -d: | sort | uniq \
# > /tmp/submitqc/bin.list
# ) &
# rotdash $!
# BIN="$(cat /tmp/submitqc/bin.list)"
if [ "$BIN" ]; then
echo -e "\n\t${YELLOW}Some binaries have not been stripped:${NORMAL}"
echo "${YELLOW}$BIN${NORMAL}" | sed "s_\./_\t_" | sed "2!s_^_\t_"
if [ "$STRIP" ]; then
echo -en "\t${YELLOW}Fixing ... ${NORMAL}"
sudo strip --strip-all ${BIN} # need sudo due to root:root ownership
[ $? != 0 ] && echo -e "\n${RED}Error in strip. Halting.${NORMAL}" && exit 1
echo -e "${YELLOW}Done.${NORMAL}"
# log the fixes
echo "Some unstripped binaries were stripped:" >> /tmp/submitqc/stripping
echo "$BIN" >> /tmp/submitqc/stripping
CHANGES=1 # rebuild tcz
else
echo -e "\t${YELLOW}This may be intentional. Else to strip, use --strip.${NORMAL}"
# log the file list
echo "$F: Some binaries are not stripped:" >> /tmp/submitqc/stripping
echo "$BIN" | sed "s/^/\t/g" >> /tmp/submitqc/stripping