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.3 2005-09-09 17:52:55 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 |
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 " uppretend - pretend dependencies for a system upgrade" |
echo " uppretend - pretend dependencies for a system upgrade" |
91 |
echo " upgrade - runs a complete system upgrade" |
echo " upgrade - runs a complete system upgrade" |
92 |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
93 |
echo " srcupgrade - runs a complete system upgrade from source" |
echo " srcupgrade - runs a complete system upgrade from source" |
94 |
echo " search - searches mage-tree for a package" |
echo " search - searches mage-tree for a package" |
95 |
echo " clean - removes *all* downloaded packages" |
echo " clean - removes *all* downloaded packages" |
96 |
echo " unpack - unpacks *all* needed package for 'foo'" |
echo " unpack - unpacks *all* needed package for 'foo'" |
97 |
echo " download - downloads *all* needed packages for 'foo'" |
echo " download - downloads *all* needed packages for 'foo'" |
98 |
echo " version - prints version info" |
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" |
129 |
if [[ ${METHOD} != upgrade ]] && \ |
if [[ ${METHOD} != upgrade ]] && \ |
130 |
[[ ${METHOD} != srcupgrade ]] && \ |
[[ ${METHOD} != srcupgrade ]] && \ |
131 |
[[ ${METHOD} != uppretend ]] && \ |
[[ ${METHOD} != uppretend ]] && \ |
132 |
[[ ${METHOD} != srcuppretend ]] |
[[ ${METHOD} != srcuppretend ]] && \ |
133 |
|
[[ ${METHOD} != update ]] && \ |
134 |
|
[[ ${METHOD} != clean ]] && \ |
135 |
|
[[ ${METHOD} != version ]] && \ |
136 |
|
[[ ${METHOD} != search ]] && \ |
137 |
|
[[ ${METHOD} != regen-mage-tree ]] |
138 |
then |
then |
139 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
140 |
fi |
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 |
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 |
325 |
--pbuild ${METHOD} |
--pbuild ${METHOD} |
326 |
;; |
;; |
327 |
|
|
328 |
upgrade|srcupgrade) |
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 |
# get all dependencies of *all* installed packages |
347 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
348 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
352 |
--pver ${METHOD} \ |
--pver ${METHOD} \ |
353 |
--pbuild ${METHOD})" |
--pbuild ${METHOD})" |
354 |
|
|
355 |
echo "DEBUG: ${ALLDEPS}" |
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) |
367 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
368 |
|
|
369 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
370 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
371 |
|
|
372 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
373 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |