Contents of /trunk/mage-buildserver/helper/buildserver-lint.sh
Parent Directory | Revision Log
Revision 3113 -
(show annotations)
(download)
(as text)
Tue Mar 19 16:12:08 2019 UTC (5 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 3040 byte(s)
Tue Mar 19 16:12:08 2019 UTC (5 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 3040 byte(s)
-place build infos in a subdir named '${PNAME}'
1 | #!/bin/bash |
2 | |
3 | BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" |
4 | SMAGEFILE="$1" |
5 | |
6 | if [ -f /etc/rc.d/init.d/functions ] |
7 | then |
8 | source /etc/rc.d/init.d/functions |
9 | else |
10 | die "/etc/rc.d/init.d/functions not found" |
11 | fi |
12 | if [ -f /etc/mage.rc.global ] |
13 | then |
14 | source /etc/mage.rc.global |
15 | else |
16 | die "/etc/mage.rc.global not found" |
17 | fi |
18 | if [ -f /etc/mage.rc ] |
19 | then |
20 | source /etc/mage.rc |
21 | else |
22 | die "/etc/mage.rc not found" |
23 | fi |
24 | if [ -f ${MLIBDIR}/mage4.functions.sh ] |
25 | then |
26 | source ${MLIBDIR}/mage4.functions.sh |
27 | else |
28 | die "${MLIBDIR}/mage4.functions.sh not found" |
29 | fi |
30 | if [ -f ${MLIBDIR}/smage2.functions.sh ] |
31 | then |
32 | source ${MLIBDIR}/smage2.functions.sh |
33 | else |
34 | die "${MLIBDIR}/smage2.functions.sh not found" |
35 | fi |
36 | |
37 | # do this at least of all includes to prevent path overwrites |
38 | env-rebuild |
39 | source /etc/profile |
40 | |
41 | # export default path |
42 | export PATH="${PATH}:${MLIBDIR}" |
43 | |
44 | die() |
45 | { |
46 | echo "ERROR: $@" |
47 | exit 1 |
48 | } |
49 | |
50 | is_split_target_magefile() |
51 | { |
52 | local mage="$1" |
53 | |
54 | for target_mage in ${MY_SPLIT_TARGET_MAGEFILES} |
55 | do |
56 | if [[ ${mage} = ${target_mage} ]] |
57 | then |
58 | return 0 |
59 | fi |
60 | done |
61 | |
62 | return 1 |
63 | } |
64 | |
65 | lint_checks() |
66 | { |
67 | local dest="$1" |
68 | local rpath |
69 | |
70 | # check deps |
71 | echo |
72 | echo "Autodetect runtime soname dependencies for '${dest}':" |
73 | ${MLIBDIR}/autodepend.sh "${dest}" |
74 | echo |
75 | |
76 | # insecure rpath |
77 | echo |
78 | echo -e "Scanning binaries for insecure rpath in '${COLGREEN}${dest}${COLDEFAULT}'" |
79 | rpath=$(scanelf -qyRF '%r -> %p' "${dest}" | grep -E "(${BUILDDIR}|: |::|^ )") |
80 | if [[ -n ${rpath} ]] |
81 | then |
82 | echo -e "Insecure rpath of '${dest}':" |
83 | echo "${rpath}" |
84 | echo -e "${COLRED}Insecure binaries detected!${COLDEFAULT}" |
85 | echo |
86 | |
87 | echo "DEBUG: paused" |
88 | read |
89 | else |
90 | echo "none found :)" |
91 | fi |
92 | echo |
93 | } |
94 | |
95 | load_mage_features |
96 | mage_setup |
97 | |
98 | if [[ -z ${SMAGEFILE} ]] |
99 | then |
100 | die "no smage file given. call '$(basename $0) with/relative/path/from/buildroot/svn/smage/to/smagefile'" |
101 | fi |
102 | |
103 | if [ -f ${SMAGESCRIPTSDIR}/${SMAGEFILE} ] |
104 | then |
105 | # be silent |
106 | FVERBOSE=off \ |
107 | SILENT=1 \ |
108 | smagesource ${SMAGESCRIPTSDIR}/${SMAGEFILE} |
109 | else |
110 | die "smagefile '${SMAGESCRIPTSDIR}/${SMAGEFILE}' not found." |
111 | fi |
112 | |
113 | # create build info dir |
114 | install -d ${BUILDSERVER_CACHE_DIR}/build/${PNAME} |
115 | # set up LINT log |
116 | logdir="${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}" |
117 | logfile="${logdir}/LINT_CHECKS" |
118 | |
119 | [ -d ${logdir} ] || install -d "${logdir}" |
120 | :> "${logfile}" |
121 | |
122 | # honor split packages |
123 | if [[ -n ${SPLIT_PACKAGES} ]] |
124 | then |
125 | split_save_variables |
126 | export SAVED_BINDIR="${BINDIR}" |
127 | for subpackage in ${SPLIT_PACKAGES} |
128 | do |
129 | # export subpackage bindir |
130 | export BINDIR="${SAVED_BINDIR}_${subpackage}" |
131 | # get the right variables for the split |
132 | export PNAME="${subpackage}" |
133 | split_info_${PNAME} |
134 | |
135 | if [[ -z ${TARGETS} ]] |
136 | then |
137 | TARGETS="${BINDIR}" |
138 | else |
139 | TARGETS+=" ${BINDIR}" |
140 | fi |
141 | # restore smage environment |
142 | split_restore_variables |
143 | done |
144 | # unset all saved smage variables |
145 | split_unset_variables |
146 | else |
147 | TARGETS="${BINDIR}" |
148 | fi |
149 | |
150 | echo "DEBUG: TARGETS='${TARGETS}'" |
151 | for dir in ${TARGETS} |
152 | do |
153 | #echo "DEBUG: running lint check for '${dir}'" |
154 | lint_checks "${dir}" | tee -a "${logfile}" |
155 | done |
156 | |
157 | #echo "DEBUG lint: read"; read |