1 |
#!/bin/sh |
#!/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.1 2005-09-09 16:35:41 niro Exp $ |
# $Id$ |
4 |
|
|
5 |
# default die function |
# default die function |
6 |
die() |
die() |
7 |
{ |
{ |
8 |
|
xtitleclean |
9 |
|
mqueryfeature "debug" && echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
10 |
echo -e ${COLRED}"$@"${COLDEFAULT} |
echo -e ${COLRED}"$@"${COLDEFAULT} |
11 |
exit 1 |
exit 1 |
12 |
} |
} |
13 |
|
|
14 |
# include all needed files |
# include all needed files |
15 |
# [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ |
[ -f /etc/mage.rc.global ] && \ |
16 |
# source ${MLIBDIR}/conf/mage.rc.global || \ |
source /etc/mage.rc.global || \ |
17 |
# die "${MLIBDIR}/conf/mage.rc.global missing" |
die "/etc/mage.rc.global missing" |
18 |
# |
|
19 |
# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
[ -f ${MAGERC} ] && source ${MAGERC} || \ |
20 |
# die "Your /etc/mage.rc is missing. Aborting." |
die "Your ${MAGERC} is missing. Aborting." |
21 |
# |
|
22 |
# [ -f ${MLIBDIR}/mage.functions.sh ] && \ |
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
23 |
# source ${MLIBDIR}/mage.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
24 |
# 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 |
|
|
|
|
|
## only for tests -> normally in /etc/rc.d/init.d/functions |
|
|
COLRED="\033[1;6m\033[31m" |
|
|
COLGREEN="\033[1;6m\033[32m" |
|
|
COLBLUE="\033[1;6m\033[34m" |
|
|
COLDEFAULT="\033[0m" |
|
|
|
|
|
if [[ ${NOCOLORS} = true ]] |
|
|
then |
|
|
COLRED="" |
|
|
COLGREEN="" |
|
|
COLYELLOW="" |
|
|
COLBLUE="" |
|
|
COLMAGENTA="" |
|
|
COLWHITE="" |
|
|
COLDEFAULT="" |
|
|
fi |
|
25 |
|
|
26 |
# export default path |
# export default path |
27 |
export PATH="${PATH}:${MLIBDIR}" |
export PATH="${PATH}:${MLIBDIR}" |
32 |
# sanity checks |
# sanity checks |
33 |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
34 |
|
|
35 |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && |
36 |
|
[[ $1 != update ]] && |
37 |
|
[[ $1 != update-rsync ]] && |
38 |
|
[[ $1 != update-tarball ]] |
39 |
then |
then |
40 |
echo |
echo |
41 |
echo "Please choose an profile from the mage tree." |
echo "Please choose an profile from the mage tree." |
44 |
fi |
fi |
45 |
|
|
46 |
# default messages |
# default messages |
47 |
showversion() { |
showversion() |
48 |
|
{ |
49 |
local MAGEVERSION="$(< ${MLIBDIR}/version)" |
local MAGEVERSION="$(< ${MLIBDIR}/version)" |
50 |
|
|
51 |
echo -en "Magellan Package Manager v${MAGEVERSION} " |
echo -en "Magellan Package Manager v${MAGEVERSION} " |
52 |
echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
53 |
} |
} |
54 |
|
|
55 |
print_usage(){ |
print_usage() |
56 |
showversion |
{ |
57 |
echo |
#showversion |
58 |
|
#echo |
59 |
echo "Usage: $(basename $0) [option] pkgname ..." |
echo "Usage: $(basename $0) [option] pkgname ..." |
60 |
echo "Options:" |
echo "Options:" |
61 |
echo " pretend - pretends dependencies of a package" |
echo " pretend - pretends dependencies of a package" |
62 |
echo " srcpretend - pretends dependencies of a package (build from source)" |
echo " srcpretend - pretends dependencies of a package (build from source)" |
63 |
echo " install - installs a package" |
echo " install - installs a package" |
64 |
echo " srcinstall - installs a package from source" |
echo " srcinstall - installs a package from source" |
65 |
echo " uninstall - removes a package" |
echo " uninstall - removes a package" |
66 |
echo " update - updates mage-tree" |
echo " update - updates the mage-tree via default sync method" |
67 |
echo " search - searches mage-tree for a package" |
echo " update-rsync - updates the mage-tree via rsync" |
68 |
echo " clean - removes *all* downloaded packages" |
echo " update-tarball - updates the mage-tree via a tarball" |
69 |
# echo " unpack - unpacks a package" |
echo " uppretend - pretend dependencies for a system upgrade" |
70 |
echo " download - downloads a package" |
echo " upgrade - runs a complete system upgrade" |
71 |
echo " version - prints version info" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
72 |
|
echo " srcupgrade - runs a complete system upgrade from source" |
73 |
|
echo " pretend-build-prerequisites - prints build prerequisites" |
74 |
|
echo " install-build-prerequisites - install build prerequisites" |
75 |
|
echo " run-preinstall - runs preinstall part of an installed package" |
76 |
|
echo " run-postinstall - runs postinstall part of an installed package" |
77 |
|
echo " search - searches mage-tree for a package" |
78 |
|
echo " clean - removes *all* downloaded packages" |
79 |
|
echo " unpack - unpacks *all* needed package for 'foo'" |
80 |
|
echo " download - downloads *all* needed packages for 'foo'" |
81 |
|
echo " print-features - prints all enabled mage-features" |
82 |
|
echo " version - prints version info" |
83 |
|
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
84 |
echo |
echo |
85 |
echo "Other options:" |
echo "Other options:" |
86 |
# echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
# echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
87 |
# echo "Builds a Package with its dependencies, but won't install anything." |
# echo "Builds a Package with its dependencies, but won't install anything." |
88 |
# echo |
# echo |
89 |
echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE" |
echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE" |
90 |
echo "Overrides stable packages; you can install packages that are marked unstable." |
echo "Overrides stable packages; you can install packages that are marked unstable." |
91 |
echo |
echo |
92 |
echo "USE_TESTING=true $(basename $0) [src]install PACKAGE" |
echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE" |
93 |
echo "Overrides stable packages; you can install packages that are marked testing." |
echo "Overrides stable packages; you can install packages that are marked testing." |
94 |
echo |
echo |
95 |
echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" |
echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" |
101 |
showversion |
showversion |
102 |
echo |
echo |
103 |
|
|
|
# before anything run mage_setup |
|
|
mage_setup || die "error in mage_setup()" |
|
|
|
|
104 |
# install method |
# install method |
105 |
METHOD="$1" |
METHOD="$1" |
106 |
|
|
107 |
# initial unversionized packagename, gets overridden later |
# initial unversionized packagename, gets overridden later on |
108 |
MAGENAME="$2" |
MAGENAME="$2" |
109 |
|
|
110 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
if [[ ${METHOD} != upgrade ]] && |
111 |
|
[[ ${METHOD} != srcupgrade ]] && |
112 |
|
[[ ${METHOD} != uppretend ]] && |
113 |
|
[[ ${METHOD} != srcuppretend ]] && |
114 |
|
[[ ${METHOD} != update ]] && |
115 |
|
[[ ${METHOD} != update-rsync ]] && |
116 |
|
[[ ${METHOD} != update-tarball ]] && |
117 |
|
[[ ${METHOD} != clean ]] && |
118 |
|
[[ ${METHOD} != version ]] && |
119 |
|
[[ ${METHOD} != search ]] && |
120 |
|
[[ ${METHOD} != regen-mage-tree ]] && |
121 |
|
[[ ${METHOD} != print-features ]] |
122 |
|
then |
123 |
|
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
124 |
|
fi |
125 |
|
|
126 |
|
# set PKGDIR and BUILDDIR to MROOT |
127 |
|
if [[ -n ${MROOT} ]] |
128 |
|
then |
129 |
|
PKGDIR=${MROOT}/${PKGDIR} |
130 |
|
BUILDDIR=${MROOT}/${BUILDDIR} |
131 |
|
fi |
132 |
|
|
133 |
|
# before anything run mage_setup |
134 |
|
mage_setup || die "error in mage_setup()" |
135 |
|
|
136 |
|
# load supported mage features |
137 |
|
load_mage_features |
138 |
|
|
139 |
|
# query debug mode |
140 |
|
if mqueryfeature "debug" |
141 |
|
then |
142 |
|
depwalker_debug="--debug" |
143 |
|
else |
144 |
|
depwalker_debug="" |
145 |
|
fi |
146 |
|
|
147 |
case ${METHOD} in |
case ${METHOD} in |
148 |
download) |
download) |
149 |
|
have_root_privileges || die "You must be root to run this operation." |
150 |
|
|
151 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
152 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
153 |
|
|
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 |
|
# package is masked |
161 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
162 |
|
|
163 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
164 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
172 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
173 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
174 |
--pver ${PVER} \ |
--pver ${PVER} \ |
175 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
176 |
|
${depwalker_debug})" |
177 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
178 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
179 |
;; |
;; |
180 |
|
|
181 |
srcdownload) |
srcdownload) |
182 |
|
have_root_privileges || die "You must be root to run this operation." |
183 |
|
|
184 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
185 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
186 |
|
|
188 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
189 |
|
|
190 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
191 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
192 |
|
|
193 |
|
# package is masked |
194 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
195 |
|
|
196 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
197 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
205 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
206 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
207 |
--pver ${PVER} \ |
--pver ${PVER} \ |
208 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
209 |
|
${depwalker_debug})" |
210 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
211 |
;; |
;; |
212 |
|
|
213 |
pretend|srcpretend) |
pretend|srcpretend|pretend-build-prerequisites) |
214 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
215 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
216 |
|
|
218 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
219 |
|
|
220 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
221 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
222 |
|
|
223 |
|
# package is masked |
224 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
225 |
|
|
226 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
227 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
243 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
244 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
245 |
--pver ${PVER} \ |
--pver ${PVER} \ |
246 |
--pbuild ${PBUILD} |
--pbuild ${PBUILD} \ |
247 |
|
${depwalker_debug} |
248 |
;; |
;; |
249 |
|
|
250 |
install) |
install|install-build-prerequisites) |
251 |
|
have_root_privileges || die "You must be root to run this operation." |
252 |
|
|
253 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
254 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
255 |
|
|
257 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
258 |
|
|
259 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
260 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
261 |
|
|
262 |
|
# package is masked |
263 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
264 |
|
|
265 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
266 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
271 |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
272 |
then |
then |
273 |
echo -en "Package " |
echo -en "Package " |
274 |
echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
275 |
echo -e " already installed." |
echo -e " already installed." |
276 |
exit 3 |
exit 3 |
277 |
fi |
fi |
282 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
283 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
284 |
--pver ${PVER} \ |
--pver ${PVER} \ |
285 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
286 |
|
${depwalker_debug})" |
287 |
|
|
288 |
# first fetch all packages |
# first fetch all packages |
289 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
290 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
|
291 |
install_packages ${ALLDEPS} || die "installing packages" |
install_packages ${ALLDEPS} || die "installing packages" |
292 |
;; |
;; |
293 |
|
|
294 |
srcinstall) |
srcinstall) |
295 |
|
have_root_privileges || die "You must be root to run this operation." |
296 |
|
|
297 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
298 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
299 |
|
|
301 |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
302 |
|
|
303 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
304 |
source $(get_highest_magefile ${PCAT} ${MAGENAME}) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
305 |
|
|
306 |
|
# package is masked |
307 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
308 |
|
|
309 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
310 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
315 |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
316 |
then |
then |
317 |
echo -en "Package " |
echo -en "Package " |
318 |
echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
319 |
echo -e " already installed." |
echo -e " already installed." |
320 |
exit 3 |
exit 3 |
321 |
fi |
fi |
326 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
327 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
328 |
--pver ${PVER} \ |
--pver ${PVER} \ |
329 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
330 |
|
${depwalker_debug})" |
331 |
|
|
332 |
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
333 |
;; |
;; |
334 |
|
|
335 |
uninstall) |
uninstall) |
336 |
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
have_root_privileges || die "You must be root to run this operation." |
337 |
if [ -z "${ALLDEPS}" ] |
|
338 |
then |
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
339 |
die "No package installed named '${MAGENAME}'." |
if [ -z "${ALLDEPS}" ] |
340 |
fi |
then |
341 |
uninstall_packages ${ALLDEPS} |
die "No package installed named '${MAGENAME}'." |
342 |
|
fi |
343 |
|
uninstall_packages ${ALLDEPS} |
344 |
|
;; |
345 |
|
|
346 |
|
run-preinstall|run-postinstall) |
347 |
|
have_root_privileges || die "You must be root to run this operation." |
348 |
|
|
349 |
|
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
350 |
|
if [ -z "${ALLDEPS}" ] |
351 |
|
then |
352 |
|
die "No package installed named '${MAGENAME}'." |
353 |
|
fi |
354 |
|
rerun_pkgfunctions --method "${METHOD//run-}" ${ALLDEPS} |
355 |
|
;; |
356 |
|
|
357 |
|
uppretend|srcuppretend) |
358 |
|
${MLIBDIR}/depwalker.sh \ |
359 |
|
--method ${METHOD} \ |
360 |
|
--pcat ${METHOD} \ |
361 |
|
--pname ${METHOD} \ |
362 |
|
--pver ${METHOD} \ |
363 |
|
--pbuild ${METHOD} \ |
364 |
|
${depwalker_debug} |
365 |
|
;; |
366 |
|
|
367 |
|
upgrade) |
368 |
|
have_root_privileges || die "You must be root to run this operation." |
369 |
|
|
370 |
|
# get all dependencies of *all* installed packages |
371 |
|
# fake pcat,pname,pver,pbuild ... |
372 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
373 |
|
--method ${METHOD} \ |
374 |
|
--pcat ${METHOD} \ |
375 |
|
--pname ${METHOD} \ |
376 |
|
--pver ${METHOD} \ |
377 |
|
--pbuild ${METHOD} \ |
378 |
|
${depwalker_debug})" |
379 |
|
|
380 |
|
# first fetch all packages |
381 |
|
fetch_packages ${ALLDEPS} || die "fetching packages" |
382 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
383 |
|
install_packages ${ALLDEPS} || die "installing packages" |
384 |
|
;; |
385 |
|
|
386 |
|
srcupgrade) |
387 |
|
have_root_privileges || die "You must be root to run this operation." |
388 |
|
|
389 |
|
# get all dependencies of *all* installed packages |
390 |
|
# fake pcat,pname,pver,pbuild ... |
391 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
392 |
|
--method ${METHOD} \ |
393 |
|
--pcat ${METHOD} \ |
394 |
|
--pname ${METHOD} \ |
395 |
|
--pver ${METHOD} \ |
396 |
|
--pbuild ${METHOD} \ |
397 |
|
${depwalker_debug})" |
398 |
|
|
399 |
|
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
400 |
;; |
;; |
401 |
|
|
402 |
search) |
search) |
403 |
${MLIBDIR}/pkgsearch.sh ${MAGENAME} |
pkgsearch "${MAGENAME}" |
404 |
;; |
;; |
405 |
|
|
406 |
# unpack) |
unpack) |
407 |
# build_unpackpkg |
have_root_privileges || die "You must be root to run this operation." |
408 |
# ;; |
|
409 |
|
# first of all get the right pkg which going to be installed |
410 |
|
PCAT="$(pname2pcat ${MAGENAME})" |
411 |
|
|
412 |
|
# package does not exists |
413 |
|
[ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
414 |
|
|
415 |
|
# source the highest magefile of this pkg |
416 |
|
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
417 |
|
|
418 |
|
# package is masked |
419 |
|
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
420 |
|
|
421 |
|
# convert PKGNAME to PNAME/PVER/PBUILD |
422 |
|
# we're working *only* with these three vars from here on |
423 |
|
PNAME="$(pkgname2pname ${PKGNAME})" |
424 |
|
PVER="$(pkgname2pver ${PKGNAME})" |
425 |
|
PBUILD="$(pkgname2pbuild ${PKGNAME})" |
426 |
|
|
427 |
|
# get all dependencies of this package |
428 |
|
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
429 |
|
--method install \ |
430 |
|
--pcat ${PCAT} \ |
431 |
|
--pname ${PNAME} \ |
432 |
|
--pver ${PVER} \ |
433 |
|
--pbuild ${PBUILD} \ |
434 |
|
${depwalker_debug})" |
435 |
|
|
436 |
|
fetch_packages ${ALLDEPS} || die "fetching packages" |
437 |
|
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
438 |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
439 |
|
;; |
440 |
|
|
441 |
update) |
update) |
442 |
|
have_root_privileges || die "You must be root to run this operation." |
443 |
|
# default to tarball |
444 |
|
[[ -z ${MAGE_UPDATE_METHOD} ]] && MAGE_UPDATE_METHOD="tarball" |
445 |
|
case ${MAGE_UPDATE_METHOD} in |
446 |
|
rsync) syncmage ;; |
447 |
|
tarball) syncmage_tarball ;; |
448 |
|
*) die "Unknown MAGE_UPDATE_METHOD defined." ;; |
449 |
|
esac |
450 |
|
;; |
451 |
|
|
452 |
|
update-rsync) |
453 |
|
have_root_privileges || die "You must be root to run this operation." |
454 |
syncmage |
syncmage |
455 |
;; |
;; |
456 |
|
|
457 |
|
update-tarball) |
458 |
|
have_root_privileges || die "You must be root to run this operation." |
459 |
|
syncmage_tarball |
460 |
|
;; |
461 |
|
|
462 |
clean) |
clean) |
463 |
|
have_root_privileges || die "You must be root to run this operation." |
464 |
cleanpkg |
cleanpkg |
465 |
;; |
;; |
466 |
|
|
467 |
version) |
version) |
468 |
showversion |
# showversion |
469 |
|
exit 0 |
470 |
;; |
;; |
471 |
|
|
472 |
regen-mage-tree) |
regen-mage-tree) |
473 |
|
have_root_privileges || die "You must be root to run this operation." |
474 |
|
|
475 |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
476 |
then |
then |
477 |
echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." |
echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." |
483 |
done |
done |
484 |
;; |
;; |
485 |
|
|
486 |
|
print-features) |
487 |
|
mprintfeatures |
488 |
|
;; |
489 |
|
|
490 |
*) |
*) |
491 |
print_usage |
print_usage |
492 |
;; |
;; |