Annotation of /trunk/mage/usr/lib/mage/mage4.sh
Parent Directory | Revision Log
Revision 226 -
(hide annotations)
(download)
(as text)
Fri Sep 9 16:35:46 2005 UTC (19 years ago) by niro
File MIME type: application/x-sh
File size: 8687 byte(s)
Fri Sep 9 16:35:46 2005 UTC (19 years ago) by niro
File MIME type: application/x-sh
File size: 8687 byte(s)
complete rewrite
1 | niro | 226 | #!/bin/sh |
2 | # Magellan Linux Installer (mage.sh) | ||
3 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.1 2005-09-09 16:35:41 niro Exp $ | ||
4 | |||
5 | # default die function | ||
6 | die() | ||
7 | { | ||
8 | echo -e ${COLRED}"$@"${COLDEFAULT} | ||
9 | exit 1 | ||
10 | } | ||
11 | |||
12 | # include all needed files | ||
13 | # [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ | ||
14 | # source ${MLIBDIR}/conf/mage.rc.global || \ | ||
15 | # die "${MLIBDIR}/conf/mage.rc.global missing" | ||
16 | # | ||
17 | # [ -f /etc/mage.rc ] && source /etc/mage.rc || \ | ||
18 | # die "Your /etc/mage.rc is missing. Aborting." | ||
19 | # | ||
20 | # [ -f ${MLIBDIR}/mage.functions.sh ] && \ | ||
21 | # source ${MLIBDIR}/mage.functions.sh || \ | ||
22 | # die "mage functions missing" | ||
23 | |||
24 | # for tests only | ||
25 | source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global | ||
26 | source /etc/mage.rc | ||
27 | source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh | ||
28 | MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage | ||
29 | |||
30 | ## only for tests -> normally in /etc/rc.d/init.d/functions | ||
31 | COLRED="\033[1;6m\033[31m" | ||
32 | COLGREEN="\033[1;6m\033[32m" | ||
33 | COLBLUE="\033[1;6m\033[34m" | ||
34 | COLDEFAULT="\033[0m" | ||
35 | |||
36 | if [[ ${NOCOLORS} = true ]] | ||
37 | then | ||
38 | COLRED="" | ||
39 | COLGREEN="" | ||
40 | COLYELLOW="" | ||
41 | COLBLUE="" | ||
42 | COLMAGENTA="" | ||
43 | COLWHITE="" | ||
44 | COLDEFAULT="" | ||
45 | fi | ||
46 | |||
47 | # export default path | ||
48 | export PATH="${PATH}:${MLIBDIR}" | ||
49 | |||
50 | # export the default C locale | ||
51 | export LC_ALL=C | ||
52 | |||
53 | # sanity checks | ||
54 | [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} | ||
55 | |||
56 | if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] | ||
57 | then | ||
58 | echo | ||
59 | echo "Please choose an profile from the mage tree." | ||
60 | echo "ln -snf ${MAGEDIR}/profiles/profilename /etc/mage-profile" | ||
61 | exit 1 | ||
62 | fi | ||
63 | |||
64 | # default messages | ||
65 | showversion() { | ||
66 | local MAGEVERSION="$(< ${MLIBDIR}/version)" | ||
67 | |||
68 | echo -en "Magellan Package Manager v${MAGEVERSION} " | ||
69 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" | ||
70 | } | ||
71 | |||
72 | print_usage(){ | ||
73 | showversion | ||
74 | echo | ||
75 | echo "Usage: $(basename $0) [option] pkgname ..." | ||
76 | echo "Options:" | ||
77 | echo " pretend - pretends dependencies of a package" | ||
78 | echo " srcpretend - pretends dependencies of a package (build from source)" | ||
79 | echo " install - installs a package" | ||
80 | echo " srcinstall - installs a package from source" | ||
81 | echo " uninstall - removes a package" | ||
82 | echo " update - updates mage-tree" | ||
83 | echo " search - searches mage-tree for a package" | ||
84 | echo " clean - removes *all* downloaded packages" | ||
85 | # echo " unpack - unpacks a package" | ||
86 | echo " download - downloads a package" | ||
87 | echo " version - prints version info" | ||
88 | echo | ||
89 | echo "Other options:" | ||
90 | # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" | ||
91 | # echo "Builds a Package with its dependencies, but won't install anything." | ||
92 | # echo | ||
93 | echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE" | ||
94 | echo "Overrides stable packages; you can install packages that are marked unstable." | ||
95 | echo | ||
96 | echo "USE_TESTING=true $(basename $0) [src]install PACKAGE" | ||
97 | echo "Overrides stable packages; you can install packages that are marked testing." | ||
98 | echo | ||
99 | echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" | ||
100 | echo "Disables all colors in the messages." | ||
101 | echo | ||
102 | } | ||
103 | |||
104 | |||
105 | showversion | ||
106 | echo | ||
107 | |||
108 | # before anything run mage_setup | ||
109 | mage_setup || die "error in mage_setup()" | ||
110 | |||
111 | # install method | ||
112 | METHOD="$1" | ||
113 | |||
114 | # initial unversionized packagename, gets overridden later | ||
115 | MAGENAME="$2" | ||
116 | |||
117 | [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 | ||
118 | |||
119 | |||
120 | case ${METHOD} in | ||
121 | download) | ||
122 | # first of all get the right pkg which going to be installed | ||
123 | PCAT="$(pname2pcat ${MAGENAME})" | ||
124 | |||
125 | # package does not exists | ||
126 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
127 | |||
128 | # source the highest magefile of this pkg | ||
129 | source $(get_highest_magefile ${PCAT} ${MAGENAME}) | ||
130 | |||
131 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
132 | # we're working *only* with these three vars from here on | ||
133 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
134 | PVER="$(pkgname2pver ${PKGNAME})" | ||
135 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
136 | |||
137 | # get all dependencies of this package | ||
138 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
139 | --method install \ | ||
140 | --pcat ${PCAT} \ | ||
141 | --pname ${PNAME} \ | ||
142 | --pver ${PVER} \ | ||
143 | --pbuild ${PBUILD})" | ||
144 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
145 | ;; | ||
146 | |||
147 | srcdownload) | ||
148 | # first of all get the right pkg which going to be installed | ||
149 | PCAT="$(pname2pcat ${MAGENAME})" | ||
150 | |||
151 | # package does not exists | ||
152 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
153 | |||
154 | # source the highest magefile of this pkg | ||
155 | source $(get_highest_magefile ${PCAT} ${MAGENAME}) | ||
156 | |||
157 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
158 | # we're working *only* with these three vars from here on | ||
159 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
160 | PVER="$(pkgname2pver ${PKGNAME})" | ||
161 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
162 | |||
163 | # get all dependencies of this package | ||
164 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
165 | --method srcinstall \ | ||
166 | --pcat ${PCAT} \ | ||
167 | --pname ${PNAME} \ | ||
168 | --pver ${PVER} \ | ||
169 | --pbuild ${PBUILD})" | ||
170 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
171 | ;; | ||
172 | |||
173 | pretend|srcpretend) | ||
174 | # first of all get the right pkg which going to be installed | ||
175 | PCAT="$(pname2pcat ${MAGENAME})" | ||
176 | |||
177 | # package does not exists | ||
178 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
179 | |||
180 | # source the highest magefile of this pkg | ||
181 | source $(get_highest_magefile ${PCAT} ${MAGENAME}) | ||
182 | |||
183 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
184 | # we're working *only* with these three vars from here on | ||
185 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
186 | PVER="$(pkgname2pver ${PKGNAME})" | ||
187 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
188 | |||
189 | # abort if already installed | ||
190 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
191 | then | ||
192 | echo -en "Package " | ||
193 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
194 | echo -e " already installed." | ||
195 | exit 3 | ||
196 | fi | ||
197 | # get all dependencies of this package | ||
198 | ${MLIBDIR}/depwalker.sh \ | ||
199 | --method ${METHOD} \ | ||
200 | --pcat ${PCAT} \ | ||
201 | --pname ${PNAME} \ | ||
202 | --pver ${PVER} \ | ||
203 | --pbuild ${PBUILD} | ||
204 | ;; | ||
205 | |||
206 | install) | ||
207 | # first of all get the right pkg which going to be installed | ||
208 | PCAT="$(pname2pcat ${MAGENAME})" | ||
209 | |||
210 | # package does not exists | ||
211 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
212 | |||
213 | # source the highest magefile of this pkg | ||
214 | source $(get_highest_magefile ${PCAT} ${MAGENAME}) | ||
215 | |||
216 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
217 | # we're working *only* with these three vars from here on | ||
218 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
219 | PVER="$(pkgname2pver ${PKGNAME})" | ||
220 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
221 | |||
222 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
223 | then | ||
224 | echo -en "Package " | ||
225 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
226 | echo -e " already installed." | ||
227 | exit 3 | ||
228 | fi | ||
229 | |||
230 | # get all dependencies of this package | ||
231 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
232 | --method ${METHOD} \ | ||
233 | --pcat ${PCAT} \ | ||
234 | --pname ${PNAME} \ | ||
235 | --pver ${PVER} \ | ||
236 | --pbuild ${PBUILD})" | ||
237 | |||
238 | # first fetch all packages | ||
239 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
240 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
241 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
242 | install_packages ${ALLDEPS} || die "installing packages" | ||
243 | ;; | ||
244 | |||
245 | srcinstall) | ||
246 | # first of all get the right pkg which going to be installed | ||
247 | PCAT="$(pname2pcat ${MAGENAME})" | ||
248 | |||
249 | # package does not exists | ||
250 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
251 | |||
252 | # source the highest magefile of this pkg | ||
253 | source $(get_highest_magefile ${PCAT} ${MAGENAME}) | ||
254 | |||
255 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
256 | # we're working *only* with these three vars from here on | ||
257 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
258 | PVER="$(pkgname2pver ${PKGNAME})" | ||
259 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
260 | |||
261 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
262 | then | ||
263 | echo -en "Package " | ||
264 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
265 | echo -e " already installed." | ||
266 | exit 3 | ||
267 | fi | ||
268 | |||
269 | # get all dependencies of this package | ||
270 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
271 | --method ${METHOD} \ | ||
272 | --pcat ${PCAT} \ | ||
273 | --pname ${PNAME} \ | ||
274 | --pver ${PVER} \ | ||
275 | --pbuild ${PBUILD})" | ||
276 | |||
277 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" | ||
278 | ;; | ||
279 | |||
280 | uninstall) | ||
281 | ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" | ||
282 | if [ -z "${ALLDEPS}" ] | ||
283 | then | ||
284 | die "No package installed named '${MAGENAME}'." | ||
285 | fi | ||
286 | uninstall_packages ${ALLDEPS} | ||
287 | ;; | ||
288 | |||
289 | search) | ||
290 | ${MLIBDIR}/pkgsearch.sh ${MAGENAME} | ||
291 | ;; | ||
292 | |||
293 | # unpack) | ||
294 | # build_unpackpkg | ||
295 | # ;; | ||
296 | |||
297 | update) | ||
298 | syncmage | ||
299 | ;; | ||
300 | |||
301 | clean) | ||
302 | cleanpkg | ||
303 | ;; | ||
304 | |||
305 | version) | ||
306 | showversion | ||
307 | ;; | ||
308 | |||
309 | regen-mage-tree) | ||
310 | if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] | ||
311 | then | ||
312 | echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." | ||
313 | exit 1 | ||
314 | fi | ||
315 | for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2") | ||
316 | do | ||
317 | smage2 only-regen-tree "${i}" | ||
318 | done | ||
319 | ;; | ||
320 | |||
321 | *) | ||
322 | print_usage | ||
323 | ;; | ||
324 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |