Contents of /trunk/mage-buildserver/helper/buildserver-build-uninstall-prerequisites.sh
Parent Directory | Revision Log
Revision 2764 -
(show annotations)
(download)
(as text)
Thu Aug 28 08:18:01 2014 UTC (10 years ago) by niro
File MIME type: application/x-sh
File size: 3843 byte(s)
Thu Aug 28 08:18:01 2014 UTC (10 years ago) by niro
File MIME type: application/x-sh
File size: 3843 byte(s)
-be more silent
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 | load_mage_features |
66 | mage_setup |
67 | |
68 | if [[ -z ${SMAGEFILE} ]] |
69 | then |
70 | die "no smage file given. call '$(basename $0) with/relative/path/from/buildroot/svn/smage/to/smagefile'" |
71 | fi |
72 | |
73 | if [ -f ${SMAGESCRIPTSDIR}/${SMAGEFILE} ] |
74 | then |
75 | # be silent |
76 | FVERBOSE=off \ |
77 | SILENT=1 \ |
78 | smagesource ${SMAGESCRIPTSDIR}/${SMAGEFILE} |
79 | else |
80 | die "smagefile '${SMAGESCRIPTSDIR}/${SMAGEFILE}' not found." |
81 | fi |
82 | |
83 | # create build info dir |
84 | install -d ${BUILDSERVER_CACHE_DIR}/build |
85 | |
86 | if [ ! -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALL_DEPS ] |
87 | then |
88 | die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALL_DEPS missing. run 'buildserver-build-depends first" |
89 | fi |
90 | |
91 | if [ ! -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS ] |
92 | then |
93 | die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS missing. run 'buildserver-build-depends first" |
94 | fi |
95 | |
96 | INSTALL_DEPS="$(< ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALL_DEPS)" |
97 | SRC_INSTALL_DEPS="$(< ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS)" |
98 | |
99 | if [[ -z ${SRC_INSTALL_DEPS} ]] |
100 | then |
101 | die "buildserver-build-uninstall-prerequisites: SRC_INSTALL_DEPS are empty, aborting." |
102 | fi |
103 | |
104 | #reverse dep order |
105 | unset REV_INSTALL_DEPS |
106 | for dep in ${INSTALL_DEPS} |
107 | do |
108 | if [[ -z ${REV_INSTALL_DEPS} ]] |
109 | then |
110 | REV_INSTALL_DEPS="${dep}" |
111 | else |
112 | REV_INSTALL_DEPS="${dep} ${REV_INSTALL_DEPS}" |
113 | fi |
114 | done |
115 | |
116 | # remove all previously installed packages |
117 | echo |
118 | echo "Cleaning buildroot - removing previously installed packages in reversed order:" |
119 | echo "---- dependencies ----" |
120 | echo "SRC_INSTALL_DEPS:" |
121 | for i in ${SRC_INSTALL_DEPS} |
122 | do |
123 | echo " * ${i}" |
124 | done |
125 | echo "INSTALL_DEPS:" |
126 | for i in ${REV_INSTALL_DEPS} |
127 | do |
128 | echo " * ${i}" |
129 | done |
130 | echo "----------------------" |
131 | |
132 | for pkg in ${SRC_INSTALL_DEPS} ${REV_INSTALL_DEPS} |
133 | do |
134 | uninstall_list="" |
135 | pname="$(magename2pname ${pkg})" |
136 | pcat="$(magename2pcat ${pkg})" |
137 | pver="$(magename2pver ${pkg})" |
138 | pbuild="$(magename2pbuild ${pkg})" |
139 | if [ -f ${BUILDSERVER_CACHE_DIR}/protected/${pname} ] |
140 | then |
141 | echo "'${pcat}/${pname}-${pver}-${pbuild}' is protected - ignoring" |
142 | else |
143 | if is_installed ${pcat}/${pname}-${pver}-${pbuild} |
144 | then |
145 | if [[ -z ${uninstall_list} ]] |
146 | then |
147 | uninstall_list="${pcat}/${pname}-${pver}-${pbuild}" |
148 | else |
149 | uninstall_list="${uninstall_list} ${pcat}/${pname}-${pver}-${pbuild}" |
150 | fi |
151 | else |
152 | echo "'${pcat}/${pname}-${pver}-${pbuild}' not installed - ignoring" |
153 | fi |
154 | |
155 | if [[ -n ${uninstall_list} ]] |
156 | then |
157 | uninstall_packages "${uninstall_list}" || die "cleaning buildroot: ${pkg}" |
158 | else |
159 | echo "uninstall_list is empty for pkg '${pcat}/${pname}-${pver}-${pbuild}' - doing nothing" |
160 | fi |
161 | fi |
162 | done |
163 | |
164 | # mark prerequisites as uninstalled |
165 | touch ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/UNSTALLED_PREREQUISITES |
Properties
Name | Value |
---|---|
svn:executable | * |