Contents of /trunk/mage-buildserver/helper/buildserver-build.sh
Parent Directory | Revision Log
Revision 2747 -
(show annotations)
(download)
(as text)
Wed Aug 13 14:02:51 2014 UTC (9 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4771 byte(s)
Wed Aug 13 14:02:51 2014 UTC (9 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4771 byte(s)
-split off helper functions
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 | SILENT=1 smagesource ${SMAGESCRIPTSDIR}/${SMAGEFILE} |
76 | else |
77 | die "smagefile '${SMAGESCRIPTSDIR}/${SMAGEFILE}' not found." |
78 | fi |
79 | |
80 | # save STATE, gets deleted by regen_mage_tree |
81 | BUILDSERVER_SAVED_STATE="${STATE}" |
82 | |
83 | #regen_mage_tree # do this after dep install |
84 | TARGET_MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" |
85 | TARGET_SRC_TARBALL="/var/cache/mage/src-packages/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}" |
86 | |
87 | # create build info dir |
88 | install -d ${BUILDSERVER_CACHE_DIR}/build |
89 | |
90 | if [ ! -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS ] |
91 | then |
92 | die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS missing. run 'buildserver-build-depends first" |
93 | fi |
94 | |
95 | SRC_INSTALL_DEPS="$(< ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS)" |
96 | |
97 | if [[ -z ${SRC_INSTALL_DEPS} ]] |
98 | then |
99 | die "buildserver-build: SRC_INSTALL_DEPS are empty, aborting." |
100 | fi |
101 | |
102 | # save STATE, gets deleted by regen_mage_tree |
103 | BUILDSERVER_SAVED_STATE="${STATE}" |
104 | |
105 | #regen_mage_tree # do this after dep install |
106 | TARGET_MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" |
107 | TARGET_SRC_TARBALL="/var/cache/mage/src-packages/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}" |
108 | |
109 | if [ ! -f ${TARGET_SRC_TARBALL} ] |
110 | then |
111 | die "${TARGET_SRC_TARBALL} is missing" |
112 | fi |
113 | |
114 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
115 | then |
116 | echo -en "Package " |
117 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
118 | echo -e " already installed. try a revup." |
119 | exit 3 |
120 | fi |
121 | |
122 | if [ -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/BUILD_OK ] |
123 | then |
124 | echo -en "Package " |
125 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
126 | echo -e " already build successfully. try a revup." |
127 | exit 3 |
128 | fi |
129 | |
130 | #if [ -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/BUILD_FAILED ] |
131 | #then |
132 | # echo -en "Package " |
133 | # echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
134 | # echo -e " build has failed already. try to fix build and revup or enforce rebuild." |
135 | # exit 3 |
136 | #fi |
137 | |
138 | # create build info dir |
139 | install -d ${BUILDSERVER_CACHE_DIR}/build |
140 | |
141 | echo |
142 | echo "---- environment -----" |
143 | echo "MROOT: ${FAKE_MROOT}" |
144 | echo "PKGDIR: ${PKGDIR}" |
145 | echo "BUILDDIR: ${BUILDDIR}" |
146 | echo "BINDIR: ${BINDIR}" |
147 | echo "$(mprintfeatures)" |
148 | echo "----------------------" |
149 | echo |
150 | #echo "DEBUG: paused"; read |
151 | |
152 | if [ ! -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALLED_PREREQUISITES ] |
153 | then |
154 | die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALLED_PREREQUISITES missing. run 'buildserver-build-prerequisites first" |
155 | fi |
156 | |
157 | #### building target package from src-pkg tarball#### |
158 | if smage2 --src-tarball ${TARGET_SRC_TARBALL} |
159 | then |
160 | build_retval=0 |
161 | echo 0 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/BUILD_OK |
162 | echo "Build successfull!" |
163 | regen_mage_tree |
164 | # restore STATE |
165 | STATE="${BUILDSERVER_SAVED_STATE}" |
166 | if install_packages ${SRC_INSTALL_DEPS} || die "installing packages" |
167 | then |
168 | install_retval=0 |
169 | echo 0 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALL_OK |
170 | echo "Install successfull!" |
171 | else |
172 | install_retval=1 |
173 | echo 1 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/INSTALL_FAILED |
174 | echo "Installation *not* successfull!" |
175 | fi |
176 | else |
177 | build_retval=1 |
178 | echo 1 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}/BUILD_FAILED |
179 | echo "Build failed" |
180 | echo "DEBUG: read" |
181 | read |
182 | fi |
183 | |
184 | ## always run auto etc-update |
185 | echo "running etc-update" |
186 | echo "-5" | etc-update |
187 | |
188 | exit ${build_retval} |
Properties
Name | Value |
---|---|
svn:executable | * |