1 |
#!/bin/bash |
#!/bin/bash |
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.17 2008-06-16 09:29:57 niro Exp $ |
# $Id$ |
4 |
|
|
5 |
# default die function |
# set default variables |
6 |
die() |
: ${MAGERC="@@SYSCONFDIR@@/mage.rc"} |
7 |
{ |
: ${MLIBDIR="@@MAGELIBDIR@@"} |
8 |
xtitleclean |
|
9 |
mqueryfeature "debug" && echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
# first of all include common functions |
10 |
echo -e ${COLRED}"$@"${COLDEFAULT} |
source ${MLIBDIR}/common.functions.sh |
11 |
exit 1 |
source @@SYSCONFDIR@@/mage.rc.global |
12 |
} |
source ${MAGERC} |
13 |
|
source ${MLIBDIR}/mage4.functions.sh |
|
# include all needed files |
|
|
[ -f /etc/mage.rc.global ] && \ |
|
|
source /etc/mage.rc.global || \ |
|
|
die "/etc/mage.rc.global missing" |
|
|
|
|
|
[ -f ${MAGERC} ] && source ${MAGERC} || \ |
|
|
die "Your ${MAGERC} is missing. Aborting." |
|
|
|
|
|
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
|
|
source ${MLIBDIR}/mage4.functions.sh || \ |
|
|
die "mage functions missing" |
|
14 |
|
|
15 |
# export default path |
# export default path |
16 |
export PATH="${PATH}:${MLIBDIR}" |
export PATH="${PATH}:${MLIBDIR}" |
21 |
# sanity checks |
# sanity checks |
22 |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
23 |
|
|
24 |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]] |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && |
25 |
|
[[ $1 != update ]] && |
26 |
|
[[ $1 != update-rsync ]] && |
27 |
|
[[ $1 != update-tarball ]] |
28 |
then |
then |
29 |
echo |
echo |
30 |
echo "Please choose an profile from the mage tree." |
echo "Please choose an profile from the mage tree." |
31 |
echo "ln -snf ${MAGEDIR}/profiles/profilename /etc/mage-profile" |
echo "ln -snf ${MAGEDIR}/profiles/profilename @@SYSCONFDIR@@/mage-profile" |
32 |
exit 1 |
exit 1 |
33 |
fi |
fi |
34 |
|
|
35 |
# default messages |
# default messages |
|
showversion() |
|
|
{ |
|
|
local MAGEVERSION="$(< ${MLIBDIR}/version)" |
|
|
|
|
|
echo -en "Magellan Package Manager v${MAGEVERSION} " |
|
|
echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
|
|
} |
|
|
|
|
36 |
print_usage() |
print_usage() |
37 |
{ |
{ |
38 |
#showversion |
#showversion |
44 |
echo " install - installs a package" |
echo " install - installs a package" |
45 |
echo " srcinstall - installs a package from source" |
echo " srcinstall - installs a package from source" |
46 |
echo " uninstall - removes a package" |
echo " uninstall - removes a package" |
47 |
echo " update - updates the mage-tree via rsync" |
echo " update - updates the mage-tree via default sync method" |
48 |
|
echo " update-rsync - updates the mage-tree via rsync" |
49 |
echo " update-tarball - updates the mage-tree via a tarball" |
echo " update-tarball - updates the mage-tree via a tarball" |
50 |
echo " uppretend - pretend dependencies for a system upgrade" |
echo " uppretend - pretend dependencies for a system upgrade" |
51 |
echo " upgrade - runs a complete system upgrade" |
echo " upgrade - runs a complete system upgrade" |
52 |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
53 |
echo " srcupgrade - runs a complete system upgrade from source" |
echo " srcupgrade - runs a complete system upgrade from source" |
54 |
echo " pretend-build-prerequisites" |
echo " pretend-build-prerequisites - prints build prerequisites" |
55 |
echo " install-build-prerequisites" |
echo " install-build-prerequisites - install build prerequisites" |
56 |
|
echo " run-preinstall - runs preinstall part of an installed package" |
57 |
|
echo " run-postinstall - runs postinstall part of an installed package" |
58 |
echo " search - searches mage-tree for a package" |
echo " search - searches mage-tree for a package" |
59 |
echo " clean - removes *all* downloaded packages" |
echo " clean - removes *all* downloaded packages" |
60 |
echo " unpack - unpacks *all* needed package for 'foo'" |
echo " unpack - unpacks *all* needed package for 'foo'" |
93 |
[[ ${METHOD} != uppretend ]] && |
[[ ${METHOD} != uppretend ]] && |
94 |
[[ ${METHOD} != srcuppretend ]] && |
[[ ${METHOD} != srcuppretend ]] && |
95 |
[[ ${METHOD} != update ]] && |
[[ ${METHOD} != update ]] && |
96 |
|
[[ ${METHOD} != update-rsync ]] && |
97 |
[[ ${METHOD} != update-tarball ]] && |
[[ ${METHOD} != update-tarball ]] && |
98 |
[[ ${METHOD} != clean ]] && |
[[ ${METHOD} != clean ]] && |
99 |
[[ ${METHOD} != version ]] && |
[[ ${METHOD} != version ]] && |
127 |
|
|
128 |
case ${METHOD} in |
case ${METHOD} in |
129 |
download) |
download) |
130 |
|
have_root_privileges || die "You must be root to run this operation." |
131 |
|
|
132 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
133 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
134 |
|
|
148 |
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
149 |
|
|
150 |
# get all dependencies of this package |
# get all dependencies of this package |
151 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
152 |
--method install \ |
--method install \ |
153 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
154 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
160 |
;; |
;; |
161 |
|
|
162 |
srcdownload) |
srcdownload) |
163 |
|
have_root_privileges || die "You must be root to run this operation." |
164 |
|
|
165 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
166 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
167 |
|
|
181 |
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
182 |
|
|
183 |
# get all dependencies of this package |
# get all dependencies of this package |
184 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
185 |
--method srcinstall \ |
--method srcinstall \ |
186 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
187 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
219 |
exit 3 |
exit 3 |
220 |
fi |
fi |
221 |
# get all dependencies of this package |
# get all dependencies of this package |
222 |
${MLIBDIR}/depwalker.sh \ |
${MLIBDIR}/depwalker \ |
223 |
--method ${METHOD} \ |
--method ${METHOD} \ |
224 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
225 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
258 |
fi |
fi |
259 |
|
|
260 |
# get all dependencies of this package |
# get all dependencies of this package |
261 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
262 |
--method ${METHOD} \ |
--method ${METHOD} \ |
263 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
264 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
302 |
fi |
fi |
303 |
|
|
304 |
# get all dependencies of this package |
# get all dependencies of this package |
305 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
306 |
--method ${METHOD} \ |
--method ${METHOD} \ |
307 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
308 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
324 |
uninstall_packages ${ALLDEPS} |
uninstall_packages ${ALLDEPS} |
325 |
;; |
;; |
326 |
|
|
327 |
|
run-preinstall|run-postinstall) |
328 |
|
have_root_privileges || die "You must be root to run this operation." |
329 |
|
|
330 |
|
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
331 |
|
if [ -z "${ALLDEPS}" ] |
332 |
|
then |
333 |
|
die "No package installed named '${MAGENAME}'." |
334 |
|
fi |
335 |
|
rerun_pkgfunctions --method "${METHOD//run-}" ${ALLDEPS} |
336 |
|
;; |
337 |
|
|
338 |
uppretend|srcuppretend) |
uppretend|srcuppretend) |
339 |
${MLIBDIR}/depwalker.sh \ |
${MLIBDIR}/depwalker \ |
340 |
--method ${METHOD} \ |
--method ${METHOD} \ |
341 |
--pcat ${METHOD} \ |
--pcat ${METHOD} \ |
342 |
--pname ${METHOD} \ |
--pname ${METHOD} \ |
350 |
|
|
351 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
352 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
353 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
354 |
--method ${METHOD} \ |
--method ${METHOD} \ |
355 |
--pcat ${METHOD} \ |
--pcat ${METHOD} \ |
356 |
--pname ${METHOD} \ |
--pname ${METHOD} \ |
369 |
|
|
370 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
371 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
372 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
373 |
--method ${METHOD} \ |
--method ${METHOD} \ |
374 |
--pcat ${METHOD} \ |
--pcat ${METHOD} \ |
375 |
--pname ${METHOD} \ |
--pname ${METHOD} \ |
406 |
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
407 |
|
|
408 |
# get all dependencies of this package |
# get all dependencies of this package |
409 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker \ |
410 |
--method install \ |
--method install \ |
411 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
412 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
421 |
|
|
422 |
update) |
update) |
423 |
have_root_privileges || die "You must be root to run this operation." |
have_root_privileges || die "You must be root to run this operation." |
424 |
|
# default to tarball |
425 |
|
[[ -z ${MAGE_UPDATE_METHOD} ]] && MAGE_UPDATE_METHOD="tarball" |
426 |
|
case ${MAGE_UPDATE_METHOD} in |
427 |
|
rsync) syncmage ;; |
428 |
|
tarball) syncmage_tarball ;; |
429 |
|
*) die "Unknown MAGE_UPDATE_METHOD defined." ;; |
430 |
|
esac |
431 |
|
;; |
432 |
|
|
433 |
|
update-rsync) |
434 |
|
have_root_privileges || die "You must be root to run this operation." |
435 |
syncmage |
syncmage |
436 |
;; |
;; |
437 |
|
|