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.2 2005-09-09 17:49:43 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.15 2007-01-19 23:15:04 niro Exp $ |
4 |
|
|
5 |
# default die function |
# default die function |
6 |
die() |
die() |
7 |
{ |
{ |
8 |
|
echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
9 |
echo -e ${COLRED}"$@"${COLDEFAULT} |
echo -e ${COLRED}"$@"${COLDEFAULT} |
10 |
exit 1 |
exit 1 |
11 |
} |
} |
12 |
|
|
13 |
# include all needed files |
# include all needed files |
14 |
# [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ |
[ -f /etc/mage.rc.global ] && \ |
15 |
# source ${MLIBDIR}/conf/mage.rc.global || \ |
source /etc/mage.rc.global || \ |
16 |
# die "${MLIBDIR}/conf/mage.rc.global missing" |
die "/etc/mage.rc.global missing" |
17 |
# |
|
18 |
# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
[ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
19 |
# die "Your /etc/mage.rc is missing. Aborting." |
die "Your /etc/mage.rc is missing. Aborting." |
20 |
# |
|
21 |
# [ -f ${MLIBDIR}/mage.functions.sh ] && \ |
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
22 |
# source ${MLIBDIR}/mage.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
23 |
# die "mage functions missing" |
die "mage functions missing" |
|
|
|
|
# for tests only |
|
|
source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global |
|
|
source /etc/mage.rc |
|
|
source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh |
|
|
MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage |
|
24 |
|
|
25 |
## only for tests -> normally in /etc/rc.d/init.d/functions |
## only for tests -> normally in /etc/rc.d/init.d/functions |
26 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
27 |
COLGREEN="\033[1;6m\033[32m" |
COLGREEN="\033[1;6m\033[32m" |
28 |
|
COLYELLOW="\033[1;6m\033[33m" |
29 |
COLBLUE="\033[1;6m\033[34m" |
COLBLUE="\033[1;6m\033[34m" |
30 |
|
COLMAGENTA="\033[1;6m\033[35m" |
31 |
|
COLWHITE="\033[1;6m\033[37m" |
32 |
|
COLGRAY="\033[0;6m\033[37m" |
33 |
|
COLBOLD="\033[1m" |
34 |
COLDEFAULT="\033[0m" |
COLDEFAULT="\033[0m" |
35 |
|
|
36 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
41 |
COLBLUE="" |
COLBLUE="" |
42 |
COLMAGENTA="" |
COLMAGENTA="" |
43 |
COLWHITE="" |
COLWHITE="" |
44 |
|
COLGRAY="" |
45 |
|
COLBOLD="" |
46 |
COLDEFAULT="" |
COLDEFAULT="" |
47 |
fi |
fi |
48 |
|
|
64 |
fi |
fi |
65 |
|
|
66 |
# default messages |
# default messages |
67 |
showversion() { |
showversion() |
68 |
|
{ |
69 |
local MAGEVERSION="$(< ${MLIBDIR}/version)" |
local MAGEVERSION="$(< ${MLIBDIR}/version)" |
70 |
|
|
71 |
echo -en "Magellan Package Manager v${MAGEVERSION} " |
echo -en "Magellan Package Manager v${MAGEVERSION} " |
72 |
echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
73 |
} |
} |
74 |
|
|
75 |
print_usage(){ |
print_usage() |
76 |
showversion |
{ |
77 |
echo |
#showversion |
78 |
|
#echo |
79 |
echo "Usage: $(basename $0) [option] pkgname ..." |
echo "Usage: $(basename $0) [option] pkgname ..." |
80 |
echo "Options:" |
echo "Options:" |
81 |
echo " pretend - pretends dependencies of a package" |
echo " pretend - pretends dependencies of a package" |
82 |
echo " srcpretend - pretends dependencies of a package (build from source)" |
echo " srcpretend - pretends dependencies of a package (build from source)" |
83 |
echo " install - installs a package" |
echo " install - installs a package" |
84 |
echo " srcinstall - installs a package from source" |
echo " srcinstall - installs a package from source" |
85 |
echo " uninstall - removes a package" |
echo " uninstall - removes a package" |
86 |
echo " update - updates mage-tree" |
echo " update - updates mage-tree" |
87 |
echo " uppretend - pretend dependencies for a system upgrade" |
echo " uppretend - pretend dependencies for a system upgrade" |
88 |
echo " upgrade - runs a complete system upgrade" |
echo " upgrade - runs a complete system upgrade" |
89 |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
90 |
echo " srcupgrade - runs a complete system upgrade from source" |
echo " srcupgrade - runs a complete system upgrade from source" |
91 |
echo " search - searches mage-tree for a package" |
echo " search - searches mage-tree for a package" |
92 |
echo " clean - removes *all* downloaded packages" |
echo " clean - removes *all* downloaded packages" |
93 |
echo " unpack - unpacks *all* needed package for 'foo'" |
echo " unpack - unpacks *all* needed package for 'foo'" |
94 |
echo " download - downloads *all* needed packages for 'foo'" |
echo " download - downloads *all* needed packages for 'foo'" |
95 |
echo " version - prints version info" |
echo " version - prints version info" |
96 |
|
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
97 |
echo |
echo |
98 |
echo "Other options:" |
echo "Other options:" |
99 |
# echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
# echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
100 |
# echo "Builds a Package with its dependencies, but won't install anything." |
# echo "Builds a Package with its dependencies, but won't install anything." |
101 |
# echo |
# echo |
102 |
echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE" |
echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE" |
103 |
echo "Overrides stable packages; you can install packages that are marked unstable." |
echo "Overrides stable packages; you can install packages that are marked unstable." |
104 |
echo |
echo |
105 |
echo "USE_TESTING=true $(basename $0) [src]install PACKAGE" |
echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE" |
106 |
echo "Overrides stable packages; you can install packages that are marked testing." |
echo "Overrides stable packages; you can install packages that are marked testing." |
107 |
echo |
echo |
108 |
echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" |
echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" |
114 |
showversion |
showversion |
115 |
echo |
echo |
116 |
|
|
|
# before anything run mage_setup |
|
|
mage_setup || die "error in mage_setup()" |
|
|
|
|
117 |
# install method |
# install method |
118 |
METHOD="$1" |
METHOD="$1" |
119 |
|
|
123 |
if [[ ${METHOD} != upgrade ]] && \ |
if [[ ${METHOD} != upgrade ]] && \ |
124 |
[[ ${METHOD} != srcupgrade ]] && \ |
[[ ${METHOD} != srcupgrade ]] && \ |
125 |
[[ ${METHOD} != uppretend ]] && \ |
[[ ${METHOD} != uppretend ]] && \ |
126 |
[[ ${METHOD} != srcuppretend ]] |
[[ ${METHOD} != srcuppretend ]] && \ |
127 |
|
[[ ${METHOD} != update ]] && \ |
128 |
|
[[ ${METHOD} != clean ]] && \ |
129 |
|
[[ ${METHOD} != version ]] && \ |
130 |
|
[[ ${METHOD} != search ]] && \ |
131 |
|
[[ ${METHOD} != regen-mage-tree ]] |
132 |
then |
then |
133 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
134 |
fi |
fi |
135 |
|
|
136 |
|
# set PKGDIR and BUILDDIR to MROOT |
137 |
|
if [[ -n ${MROOT} ]] |
138 |
|
then |
139 |
|
PKGDIR=${MROOT}/${PKGDIR} |
140 |
|
BUILDDIR=${MROOT}/${BUILDDIR} |
141 |
|
fi |
142 |
|
|
143 |
|
# before anything run mage_setup |
144 |
|
mage_setup || die "error in mage_setup()" |
145 |
|
|
146 |
case ${METHOD} in |
case ${METHOD} in |
147 |
download) |
download) |
152 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
153 |
|
|
154 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
155 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
156 |
|
|
157 |
|
# package is masked |
158 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
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 |
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 |
|
# package is masked |
188 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
189 |
|
|
190 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
191 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
211 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
212 |
|
|
213 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
214 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
215 |
|
|
216 |
|
# package is masked |
217 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
218 |
|
|
219 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
220 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
247 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
248 |
|
|
249 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
250 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
251 |
|
|
252 |
|
# package is masked |
253 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
254 |
|
|
255 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
256 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
261 |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
262 |
then |
then |
263 |
echo -en "Package " |
echo -en "Package " |
264 |
echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
265 |
echo -e " already installed." |
echo -e " already installed." |
266 |
exit 3 |
exit 3 |
267 |
fi |
fi |
289 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
290 |
|
|
291 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
292 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
293 |
|
|
294 |
|
# package is masked |
295 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
296 |
|
|
297 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
298 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
303 |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
304 |
then |
then |
305 |
echo -en "Package " |
echo -en "Package " |
306 |
echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
307 |
echo -e " already installed." |
echo -e " already installed." |
308 |
exit 3 |
exit 3 |
309 |
fi |
fi |
337 |
--pbuild ${METHOD} |
--pbuild ${METHOD} |
338 |
;; |
;; |
339 |
|
|
340 |
upgrade|srcupgrade) |
upgrade) |
341 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
342 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
343 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
347 |
--pver ${METHOD} \ |
--pver ${METHOD} \ |
348 |
--pbuild ${METHOD})" |
--pbuild ${METHOD})" |
349 |
|
|
350 |
echo "DEBUG: ${ALLDEPS}" |
# first fetch all packages |
351 |
|
fetch_packages ${ALLDEPS} || die "fetching packages" |
352 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
353 |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
354 |
|
install_packages ${ALLDEPS} || die "installing packages" |
355 |
|
;; |
356 |
|
|
357 |
|
srcupgrade) |
358 |
|
# get all dependencies of *all* installed packages |
359 |
|
# fake pcat,pname,pver,pbuild ... |
360 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
361 |
|
--method ${METHOD} \ |
362 |
|
--pcat ${METHOD} \ |
363 |
|
--pname ${METHOD} \ |
364 |
|
--pver ${METHOD} \ |
365 |
|
--pbuild ${METHOD})" |
366 |
|
|
367 |
|
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
368 |
;; |
;; |
369 |
|
|
370 |
search) |
search) |
371 |
${MLIBDIR}/pkgsearch.sh ${MAGENAME} |
pkgsearch "${MAGENAME}" |
372 |
;; |
;; |
373 |
|
|
374 |
unpack) |
unpack) |
379 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
380 |
|
|
381 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
382 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
383 |
|
|
384 |
|
# package is masked |
385 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
386 |
|
|
387 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
388 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
411 |
;; |
;; |
412 |
|
|
413 |
version) |
version) |
414 |
showversion |
# showversion |
415 |
|
exit 0 |
416 |
;; |
;; |
417 |
|
|
418 |
regen-mage-tree) |
regen-mage-tree) |