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.5 2005-09-10 13:35:31 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() |
35 |
COLMAGENTA="\033[1;6m\033[35m" |
COLMAGENTA="\033[1;6m\033[35m" |
36 |
COLWHITE="\033[1;6m\033[37m" |
COLWHITE="\033[1;6m\033[37m" |
37 |
COLGRAY="\033[0;6m\033[37m" |
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 ]] |
47 |
COLMAGENTA="" |
COLMAGENTA="" |
48 |
COLWHITE="" |
COLWHITE="" |
49 |
COLGRAY="" |
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" |
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 |
# get all dependencies of *all* installed packages |
330 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
331 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
335 |
--pver ${METHOD} \ |
--pver ${METHOD} \ |
336 |
--pbuild ${METHOD})" |
--pbuild ${METHOD})" |
337 |
|
|
338 |
echo "DEBUG: ${ALLDEPS}" |
# 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) |
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 |