1 |
#!/bin/sh |
#!/bin/sh |
2 |
# Magellan Linux Installer (mage.sh) |
# 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 $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.9 2005-12-01 12:40:21 niro Exp $ |
4 |
|
|
5 |
# default die function |
# default die function |
6 |
die() |
die() |
10 |
} |
} |
11 |
|
|
12 |
# include all needed files |
# include all needed files |
13 |
# [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ |
[ -f /etc/mage.rc.global ] && \ |
14 |
# source ${MLIBDIR}/conf/mage.rc.global || \ |
source /etc/mage.rc.global || \ |
15 |
# die "${MLIBDIR}/conf/mage.rc.global missing" |
die "/etc/mage.rc.global missing" |
16 |
# |
|
17 |
# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
[ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
18 |
# die "Your /etc/mage.rc is missing. Aborting." |
die "Your /etc/mage.rc is missing. Aborting." |
19 |
# |
|
20 |
# [ -f ${MLIBDIR}/mage.functions.sh ] && \ |
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
21 |
# source ${MLIBDIR}/mage.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
22 |
# die "mage functions missing" |
die "mage functions missing" |
23 |
|
|
24 |
# for tests only |
# for tests only |
25 |
source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global |
#source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global |
26 |
source /etc/mage.rc |
#source /etc/mage.rc |
27 |
source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh |
#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 |
#MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage |
29 |
|
|
30 |
## only for tests -> normally in /etc/rc.d/init.d/functions |
## only for tests -> normally in /etc/rc.d/init.d/functions |
31 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
32 |
COLGREEN="\033[1;6m\033[32m" |
COLGREEN="\033[1;6m\033[32m" |
33 |
|
COLYELLOW="\033[1;6m\033[33m" |
34 |
COLBLUE="\033[1;6m\033[34m" |
COLBLUE="\033[1;6m\033[34m" |
35 |
|
COLMAGENTA="\033[1;6m\033[35m" |
36 |
|
COLWHITE="\033[1;6m\033[37m" |
37 |
|
COLGRAY="\033[0;6m\033[37m" |
38 |
|
COLBOLD="\033[1m" |
39 |
COLDEFAULT="\033[0m" |
COLDEFAULT="\033[0m" |
40 |
|
|
41 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
46 |
COLBLUE="" |
COLBLUE="" |
47 |
COLMAGENTA="" |
COLMAGENTA="" |
48 |
COLWHITE="" |
COLWHITE="" |
49 |
|
COLGRAY="" |
50 |
|
COLBOLD="" |
51 |
COLDEFAULT="" |
COLDEFAULT="" |
52 |
fi |
fi |
53 |
|
|
81 |
echo |
echo |
82 |
echo "Usage: $(basename $0) [option] pkgname ..." |
echo "Usage: $(basename $0) [option] pkgname ..." |
83 |
echo "Options:" |
echo "Options:" |
84 |
echo " pretend - pretends dependencies of a package" |
echo " pretend - pretends dependencies of a package" |
85 |
echo " srcpretend - pretends dependencies of a package (build from source)" |
echo " srcpretend - pretends dependencies of a package (build from source)" |
86 |
echo " install - installs a package" |
echo " install - installs a package" |
87 |
echo " srcinstall - installs a package from source" |
echo " srcinstall - installs a package from source" |
88 |
echo " uninstall - removes a package" |
echo " uninstall - removes a package" |
89 |
echo " update - updates mage-tree" |
echo " update - updates mage-tree" |
90 |
echo " search - searches mage-tree for a package" |
echo " uppretend - pretend dependencies for a system upgrade" |
91 |
echo " clean - removes *all* downloaded packages" |
echo " upgrade - runs a complete system upgrade" |
92 |
# echo " unpack - unpacks a package" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
93 |
echo " download - downloads a package" |
echo " srcupgrade - runs a complete system upgrade from source" |
94 |
echo " version - prints version info" |
echo " search - searches mage-tree for a package" |
95 |
|
echo " clean - removes *all* downloaded packages" |
96 |
|
echo " unpack - unpacks *all* needed package for 'foo'" |
97 |
|
echo " download - downloads *all* needed packages for 'foo'" |
98 |
|
echo " version - prints version info" |
99 |
|
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
100 |
echo |
echo |
101 |
echo "Other options:" |
echo "Other options:" |
102 |
# echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
# echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
126 |
# initial unversionized packagename, gets overridden later |
# initial unversionized packagename, gets overridden later |
127 |
MAGENAME="$2" |
MAGENAME="$2" |
128 |
|
|
129 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
if [[ ${METHOD} != upgrade ]] && \ |
130 |
|
[[ ${METHOD} != srcupgrade ]] && \ |
131 |
|
[[ ${METHOD} != uppretend ]] && \ |
132 |
|
[[ ${METHOD} != srcuppretend ]] && \ |
133 |
|
[[ ${METHOD} != update ]] && \ |
134 |
|
[[ ${METHOD} != clean ]] && \ |
135 |
|
[[ ${METHOD} != version ]] && \ |
136 |
|
[[ ${METHOD} != search ]] && \ |
137 |
|
[[ ${METHOD} != regen-mage-tree ]] |
138 |
|
then |
139 |
|
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
140 |
|
fi |
141 |
|
|
142 |
|
# set PKGDIR and BUILDDIR to MROOT |
143 |
|
if [[ -n ${MROOT} ]] |
144 |
|
then |
145 |
|
PKGDIR=${MROOT}/${PKGDIR} |
146 |
|
BUILDDIR=${MROOT}/${BUILDDIR} |
147 |
|
fi |
148 |
|
|
149 |
case ${METHOD} in |
case ${METHOD} in |
150 |
download) |
download) |
155 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
156 |
|
|
157 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
158 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
159 |
|
|
160 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
161 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
171 |
--pver ${PVER} \ |
--pver ${PVER} \ |
172 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD})" |
173 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
174 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
175 |
;; |
;; |
176 |
|
|
177 |
srcdownload) |
srcdownload) |
182 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
183 |
|
|
184 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
185 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
186 |
|
|
187 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
188 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
208 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
209 |
|
|
210 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
211 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
212 |
|
|
213 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
214 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
241 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
242 |
|
|
243 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
244 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
245 |
|
|
246 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
247 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
252 |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
253 |
then |
then |
254 |
echo -en "Package " |
echo -en "Package " |
255 |
echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
256 |
echo -e " already installed." |
echo -e " already installed." |
257 |
exit 3 |
exit 3 |
258 |
fi |
fi |
280 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
281 |
|
|
282 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
283 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
284 |
|
|
285 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
286 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
291 |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
292 |
then |
then |
293 |
echo -en "Package " |
echo -en "Package " |
294 |
echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
295 |
echo -e " already installed." |
echo -e " already installed." |
296 |
exit 3 |
exit 3 |
297 |
fi |
fi |
316 |
uninstall_packages ${ALLDEPS} |
uninstall_packages ${ALLDEPS} |
317 |
;; |
;; |
318 |
|
|
319 |
|
uppretend|srcuppretend) |
320 |
|
${MLIBDIR}/depwalker.sh \ |
321 |
|
--method ${METHOD} \ |
322 |
|
--pcat ${METHOD} \ |
323 |
|
--pname ${METHOD} \ |
324 |
|
--pver ${METHOD} \ |
325 |
|
--pbuild ${METHOD} |
326 |
|
;; |
327 |
|
|
328 |
|
upgrade) |
329 |
|
# get all dependencies of *all* installed packages |
330 |
|
# fake pcat,pname,pver,pbuild ... |
331 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
332 |
|
--method ${METHOD} \ |
333 |
|
--pcat ${METHOD} \ |
334 |
|
--pname ${METHOD} \ |
335 |
|
--pver ${METHOD} \ |
336 |
|
--pbuild ${METHOD})" |
337 |
|
|
338 |
|
# first fetch all packages |
339 |
|
fetch_packages ${ALLDEPS} || die "fetching packages" |
340 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
341 |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
342 |
|
install_packages ${ALLDEPS} || die "installing packages" |
343 |
|
;; |
344 |
|
|
345 |
|
srcupgrade) |
346 |
|
# get all dependencies of *all* installed packages |
347 |
|
# fake pcat,pname,pver,pbuild ... |
348 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
349 |
|
--method ${METHOD} \ |
350 |
|
--pcat ${METHOD} \ |
351 |
|
--pname ${METHOD} \ |
352 |
|
--pver ${METHOD} \ |
353 |
|
--pbuild ${METHOD})" |
354 |
|
|
355 |
|
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
356 |
|
;; |
357 |
|
|
358 |
search) |
search) |
359 |
${MLIBDIR}/pkgsearch.sh ${MAGENAME} |
pkgsearch "${MAGENAME}" |
360 |
;; |
;; |
361 |
|
|
362 |
# unpack) |
unpack) |
363 |
# build_unpackpkg |
# first of all get the right pkg which going to be installed |
364 |
# ;; |
PCAT="$(pname2pcat ${MAGENAME})" |
365 |
|
|
366 |
|
# package does not exists |
367 |
|
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
368 |
|
|
369 |
|
# source the highest magefile of this pkg |
370 |
|
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
371 |
|
|
372 |
|
# convert PKGNAME to PNAME/PVER/PBUILD |
373 |
|
# we're working *only* with these three vars from here on |
374 |
|
PNAME="$(pkgname2pname ${PKGNAME})" |
375 |
|
PVER="$(pkgname2pver ${PKGNAME})" |
376 |
|
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
377 |
|
|
378 |
|
# get all dependencies of this package |
379 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
380 |
|
--method install \ |
381 |
|
--pcat ${PCAT} \ |
382 |
|
--pname ${PNAME} \ |
383 |
|
--pver ${PVER} \ |
384 |
|
--pbuild ${PBUILD})" |
385 |
|
fetch_packages ${ALLDEPS} || die "fetching packages" |
386 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
387 |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
388 |
|
;; |
389 |
|
|
390 |
update) |
update) |
391 |
syncmage |
syncmage |