2 |
# Magellan Linux Installer Functions (mage.functions.sh) |
# Magellan Linux Installer Functions (mage.functions.sh) |
3 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ |
4 |
|
|
5 |
|
COLRED="\033[1;6m\033[31m" |
6 |
|
COLGREEN="\033[1;6m\033[32m" |
7 |
|
COLYELLOW="\033[1;6m\033[33m" |
8 |
|
COLBLUE="\033[1;6m\033[34m" |
9 |
|
COLMAGENTA="\033[1;6m\033[35m" |
10 |
|
COLWHITE="\033[1;6m\033[37m" |
11 |
|
COLGRAY="\033[0;6m\033[37m" |
12 |
|
COLBOLD="\033[1m" |
13 |
|
COLDEFAULT="\033[0m" |
14 |
|
|
15 |
|
if [[ ${NOCOLORS} = true ]] |
16 |
|
then |
17 |
|
COLRED="" |
18 |
|
COLGREEN="" |
19 |
|
COLYELLOW="" |
20 |
|
COLBLUE="" |
21 |
|
COLMAGENTA="" |
22 |
|
COLWHITE="" |
23 |
|
COLGRAY="" |
24 |
|
COLBOLD="" |
25 |
|
COLDEFAULT="" |
26 |
|
fi |
27 |
|
|
28 |
mage_setup() |
mage_setup() |
29 |
{ |
{ |
30 |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
38 |
return 0 |
return 0 |
39 |
} |
} |
40 |
|
|
41 |
|
mchecksum() |
42 |
|
{ |
43 |
|
local i |
44 |
|
local rundir |
45 |
|
local file |
46 |
|
local method |
47 |
|
local cmd |
48 |
|
local retval |
49 |
|
local sum |
50 |
|
local dest |
51 |
|
|
52 |
|
# very basic getops |
53 |
|
for i in $* |
54 |
|
do |
55 |
|
case $1 in |
56 |
|
--rundir|-r) shift; rundir="$1" ;; |
57 |
|
--file|-f) shift; file="$1" ;; |
58 |
|
--method|-m) shift; method="$1" ;; |
59 |
|
esac |
60 |
|
shift |
61 |
|
done |
62 |
|
|
63 |
|
# sanity checks |
64 |
|
[[ -z ${rundir} ]] && die "mchecksum(): rundir missing" |
65 |
|
[[ -z ${file} ]] && die "mchecksum(): file missing" |
66 |
|
[[ -z ${method} ]] && die "mchecksum(): method missing" |
67 |
|
|
68 |
|
case ${method} in |
69 |
|
md5) cmd="md5sum" ;; |
70 |
|
sha256) cmd="sha256sum" ;; |
71 |
|
*) die "mchecksum(): unknown method '${method}'" ;; |
72 |
|
esac |
73 |
|
|
74 |
|
if [[ -d ${rundir} ]] |
75 |
|
then |
76 |
|
pushd ${rundir} &> /dev/null |
77 |
|
|
78 |
|
# all file must be non-zero |
79 |
|
retval=0 |
80 |
|
while read sum dest |
81 |
|
do |
82 |
|
if [ ! -s ${dest} ] |
83 |
|
then |
84 |
|
echo "${dest}: file is empty ;(" |
85 |
|
retval=127 |
86 |
|
fi |
87 |
|
done < ${file} |
88 |
|
if [[ ${retval} != 127 ]] |
89 |
|
then |
90 |
|
# be verbose here |
91 |
|
${cmd} -c ${file} #&> /dev/null |
92 |
|
retval="$?" |
93 |
|
fi |
94 |
|
|
95 |
|
popd &> /dev/null |
96 |
|
else |
97 |
|
retval=1 |
98 |
|
fi |
99 |
|
|
100 |
|
return "${retval}" |
101 |
|
} |
102 |
|
|
103 |
|
mcheckemptydir() |
104 |
|
{ |
105 |
|
local dir="$1" |
106 |
|
local retval=1 |
107 |
|
|
108 |
|
if [[ ! -d ${dir} ]] |
109 |
|
then |
110 |
|
echo "mcheckemptydir(): '${dir}' is not a directory!" |
111 |
|
retval=3 |
112 |
|
else |
113 |
|
shopt -s nullglob dotglob |
114 |
|
files=( ${dir}/* ) |
115 |
|
(( ${#files[*]} )) || retval=0 |
116 |
|
shopt -u nullglob dotglob |
117 |
|
fi |
118 |
|
|
119 |
|
return ${retval} |
120 |
|
} |
121 |
|
|
122 |
|
unpack_package() |
123 |
|
{ |
124 |
|
local magefile="$1" |
125 |
|
local pkg |
126 |
|
local pkgtype |
127 |
|
local tar_opts |
128 |
|
|
129 |
|
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
130 |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
131 |
|
|
132 |
|
xtitle "[ Unpacking ${pkg} ]" |
133 |
|
|
134 |
|
# abort on virtual pkg |
135 |
|
if [[ ${pkgtype} = virtual ]] |
136 |
|
then |
137 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
138 |
|
echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... " |
139 |
|
continue |
140 |
|
fi |
141 |
|
|
142 |
|
# abort on sources pkg |
143 |
|
if [[ ${pkgtype} = sources ]] |
144 |
|
then |
145 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
146 |
|
echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... " |
147 |
|
continue |
148 |
|
fi |
149 |
|
|
150 |
|
# busybox? |
151 |
|
if need_busybox_support tar |
152 |
|
then |
153 |
|
tar_opts="xjf" |
154 |
|
else |
155 |
|
tar_opts="xjmf" |
156 |
|
fi |
157 |
|
|
158 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... " |
159 |
|
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
160 |
|
} |
161 |
|
|
162 |
unpack_packages() |
unpack_packages() |
163 |
{ |
{ |
164 |
local list="$@" |
local list="$@" |
165 |
local magefile |
local magefile |
|
local pkg |
|
|
local pkgtype |
|
166 |
local count_current |
local count_current |
167 |
local count_total |
local count_total |
168 |
|
local tar_opts |
169 |
|
|
170 |
# get count of total packages |
# get count of total packages |
171 |
declare -i count_current=0 |
declare -i count_current=0 |
175 |
|
|
176 |
for magefile in ${list} |
for magefile in ${list} |
177 |
do |
do |
178 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
unpack_package "${magefile}" |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
|
|
|
|
179 |
(( count_current++ )) |
(( count_current++ )) |
|
xtitle "[ (${count_current}/${count_total}) Unpacking ${pkg} ]" |
|
|
|
|
|
# abort on virtual pkg |
|
|
if [[ ${pkgtype} = virtual ]] |
|
|
then |
|
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
|
|
echo " !unpack virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
|
|
continue |
|
|
fi |
|
|
|
|
|
# abort on sources pkg |
|
|
if [[ ${pkgtype} = sources ]] |
|
|
then |
|
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
|
|
echo " !unpack sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
|
|
continue |
|
|
fi |
|
|
|
|
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
|
|
tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
|
180 |
done |
done |
181 |
|
|
182 |
# add a crlf for a better view |
# add a crlf for a better view |
196 |
mtime=$(stat -c %Y "${reference}") |
mtime=$(stat -c %Y "${reference}") |
197 |
touch \ |
touch \ |
198 |
--no-create \ |
--no-create \ |
199 |
|
--no-dereference \ |
200 |
--time=mtime \ |
--time=mtime \ |
201 |
--reference "${reference}" \ |
--reference="${reference}" \ |
202 |
"${pathto}" |
"${pathto}" |
203 |
|
|
204 |
echo "${mtime}" |
echo "${mtime}" |
252 |
while read pathto posix user group |
while read pathto posix user group |
253 |
do |
do |
254 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
255 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
|
|
|
256 |
|
|
257 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
258 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
328 |
case ${retval} in |
case ${retval} in |
329 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
330 |
0|3) |
0|3) |
331 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
332 |
install -m "${posix}" -o "${user}" -g "${group}" \ |
install -m "${posix}" -o "${user}" -g "${group}" \ |
333 |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
334 |
"${MROOT}${pathto}" |
"${MROOT}${pathto}" |
340 |
"${user}" \ |
"${user}" \ |
341 |
"${group}" \ |
"${group}" \ |
342 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
343 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
344 |
"${md5sum}" |
"${md5sum}" |
345 |
;; |
;; |
346 |
|
|
347 |
# file is protected, write backup file |
# file is protected, write backup file |
348 |
2) |
2) |
349 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
350 |
then |
then |
351 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
352 |
echo -n "! prot " |
echo -n "! prot " |
367 |
"${user}" \ |
"${user}" \ |
368 |
"${group}" \ |
"${group}" \ |
369 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
370 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
371 |
"${md5sum}" |
"${md5sum}" |
372 |
|
|
373 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
377 |
|
|
378 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
379 |
4) |
4) |
380 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
381 |
then |
then |
382 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
383 |
echo -n "! ignr " |
echo -n "! ignr " |
384 |
echo -en "${COLDEFAULT}" |
echo -en "${COLDEFAULT}" |
385 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
386 |
fi |
fi |
387 |
# simply do nothing here |
# simply do nothing here - only fix mtime |
388 |
|
fix_descriptor ${pkgname}/.files \ |
389 |
|
"${pathto}" \ |
390 |
|
"${posix}" \ |
391 |
|
"${user}" \ |
392 |
|
"${group}" \ |
393 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
394 |
|
"${MROOT}${pathto}")" \ |
395 |
|
"${md5sum}" |
396 |
;; |
;; |
397 |
esac |
esac |
398 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
436 |
while read pathto posix link mtime |
while read pathto posix link mtime |
437 |
do |
do |
438 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
439 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
440 |
|
|
441 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
442 |
|
|
443 |
# # fix mtime and db |
# fix mtime and db |
444 |
# fix_descriptor ${pkgname}/.symlinks \ |
fix_descriptor ${pkgname}/.symlinks \ |
445 |
# "${pathto}" \ |
"${pathto}" \ |
446 |
# "${posix}" \ |
"${posix}" \ |
447 |
# "${link}" \ |
"${link}" \ |
448 |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
449 |
# "${MROOT}${pathto}")" |
"${MROOT}${pathto}")" |
450 |
|
|
451 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
452 |
|
|
483 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
484 |
IFS=§ |
IFS=§ |
485 |
|
|
486 |
while read pathto posix user group |
while read pathto posix major minor user group |
487 |
do |
do |
488 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
489 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
490 |
|
|
491 |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
mknod -m "${posix}" "${MROOT}${pathto}" |
492 |
# make it optional atm !! |
# make it optional atm !! |
493 |
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
494 |
then |
then |
495 |
chown "${user}:${group}" "${MROOT}${pathto}" |
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
496 |
fi |
fi |
497 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
498 |
|
|
530 |
while read pathto posix major minor user group |
while read pathto posix major minor user group |
531 |
do |
do |
532 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
533 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
534 |
|
|
535 |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
536 |
|
|
537 |
# make it optional atm !! |
# make it optional atm !! |
538 |
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
574 |
while read pathto posix user group |
while read pathto posix user group |
575 |
do |
do |
576 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
577 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
578 |
|
|
579 |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
580 |
chown "${user}:${group}" "${MROOT}${pathto}" |
chown "${user}:${group}" "${MROOT}${pathto}" |
596 |
|
|
597 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
598 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
599 |
|
|
600 |
# this is only a wrapper |
# this is only a wrapper |
601 |
|
|
602 |
# NOTE: |
# NOTE: |
833 |
|
|
834 |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
835 |
|
|
836 |
# if $pathto is a symlink than compare linked binary |
# no extra handlink for symlinks anymore as fix_mtime |
837 |
if [ -L "${MROOT}${pathto}" ] |
# uses --no-dereference, compare directly |
838 |
then |
x=$(stat -c %Y "${MROOT}${pathto}") |
|
# readlink -f resolves full path of linked file |
|
|
x="$(readlink -f "${MROOT}${pathto}")" |
|
|
|
|
|
# abort if target does not exists |
|
|
# we keep safe here, theoretically the link can removed |
|
|
[ ! -e "${x}" ] && return 1 |
|
|
|
|
|
x=$(stat -c %Y "${x}") |
|
|
else |
|
|
x=$(stat -c %Y "${MROOT}${pathto}") |
|
|
fi |
|
839 |
|
|
840 |
[[ ${mtime} = ${x} ]] && return 0 |
[[ ${mtime} = ${x} ]] && return 0 |
841 |
|
|
897 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
898 |
if [ ! -L "${MROOT}${pathto}" ] |
if [ ! -L "${MROOT}${pathto}" ] |
899 |
then |
then |
900 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
901 |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
902 |
continue |
continue |
903 |
fi |
fi |
909 |
# 1=keep me # |
# 1=keep me # |
910 |
case ${retval} in |
case ${retval} in |
911 |
0) |
0) |
912 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
913 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
914 |
;; |
;; |
915 |
|
|
916 |
1) |
1) |
917 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
918 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
919 |
;; |
;; |
920 |
esac |
esac |
981 |
|
|
982 |
if [ ! -e "${MROOT}${pathto}" ] |
if [ ! -e "${MROOT}${pathto}" ] |
983 |
then |
then |
984 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
985 |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
986 |
continue |
continue |
987 |
fi |
fi |
1007 |
case ${retval} in |
case ${retval} in |
1008 |
# file is not protected - delete it |
# file is not protected - delete it |
1009 |
0|3) |
0|3) |
1010 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
1011 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1012 |
;; |
;; |
1013 |
|
|
1014 |
# file is protected, do not delete |
# file is protected, do not delete |
1015 |
2) |
2) |
1016 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1017 |
then |
then |
1018 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1019 |
echo -n "! prot " |
echo -n "! prot " |
1024 |
|
|
1025 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
1026 |
4) |
4) |
1027 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1028 |
then |
then |
1029 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1030 |
echo -n "! ignr " |
echo -n "! ignr " |
1036 |
esac |
esac |
1037 |
;; |
;; |
1038 |
1) |
1) |
1039 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1040 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1041 |
;; |
;; |
1042 |
esac |
esac |
1098 |
do |
do |
1099 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1100 |
|
|
1101 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
1102 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1103 |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
1104 |
|
|
1158 |
do |
do |
1159 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1160 |
|
|
1161 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
1162 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1163 |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
1164 |
|
|
1220 |
do |
do |
1221 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1222 |
|
|
1223 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1224 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1225 |
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1226 |
|
|
1281 |
|
|
1282 |
if [ ! -d "${MROOT}${pathto}" ] |
if [ ! -d "${MROOT}${pathto}" ] |
1283 |
then |
then |
1284 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1285 |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1286 |
continue |
continue |
1287 |
fi |
fi |
1289 |
# exclude .keep directories |
# exclude .keep directories |
1290 |
if [ -f "${MROOT}${pathto}/.keep" ] |
if [ -f "${MROOT}${pathto}/.keep" ] |
1291 |
then |
then |
1292 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1293 |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1294 |
continue |
continue |
1295 |
fi |
fi |
1302 |
|
|
1303 |
if rmdir "${MROOT}${pathto}" &> /dev/null |
if rmdir "${MROOT}${pathto}" &> /dev/null |
1304 |
then |
then |
1305 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
1306 |
else |
else |
1307 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1308 |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1309 |
fi |
fi |
1310 |
done |
done |
1362 |
done |
done |
1363 |
} |
} |
1364 |
|
|
1365 |
|
# convertmirrors [uri] |
1366 |
|
convertmirrors() |
1367 |
|
{ |
1368 |
|
local uri="$1" |
1369 |
|
local scheme |
1370 |
|
local mirror |
1371 |
|
local mirrors |
1372 |
|
local addon |
1373 |
|
local real_uri |
1374 |
|
local output |
1375 |
|
|
1376 |
|
# needs |
1377 |
|
[[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!" |
1378 |
|
[[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!" |
1379 |
|
[[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!" |
1380 |
|
[[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!" |
1381 |
|
[[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!" |
1382 |
|
|
1383 |
|
# check known uri schemes |
1384 |
|
case ${uri} in |
1385 |
|
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
1386 |
|
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1387 |
|
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1388 |
|
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1389 |
|
sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;; |
1390 |
|
gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;; |
1391 |
|
kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;; |
1392 |
|
*) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;; |
1393 |
|
esac |
1394 |
|
|
1395 |
|
if [[ ! -z ${mirrors} ]] |
1396 |
|
then |
1397 |
|
for mirror in ${mirrors} |
1398 |
|
do |
1399 |
|
# add a whitespace to the output |
1400 |
|
[[ -z ${output} ]] || output+=" " |
1401 |
|
output+="${mirror}${addon}/${uri/${scheme}/}" |
1402 |
|
done |
1403 |
|
else |
1404 |
|
output="${uri}" |
1405 |
|
fi |
1406 |
|
|
1407 |
|
echo "${output}" |
1408 |
|
} |
1409 |
|
|
1410 |
|
mdownload() |
1411 |
|
{ |
1412 |
|
local i |
1413 |
|
local uri |
1414 |
|
local real_uris |
1415 |
|
local mirror |
1416 |
|
local outputfile |
1417 |
|
local outputdir |
1418 |
|
local retval |
1419 |
|
local wget_opts |
1420 |
|
|
1421 |
|
# very basic getops |
1422 |
|
for i in $* |
1423 |
|
do |
1424 |
|
case $1 in |
1425 |
|
--uri|-u) shift; uri="$1" ;; |
1426 |
|
--dir|-d) shift; outputdir="$1" ;; |
1427 |
|
esac |
1428 |
|
shift |
1429 |
|
done |
1430 |
|
|
1431 |
|
# sanity checks; abort if not given |
1432 |
|
[[ -z ${uri} ]] && die "mdownload(): no uri given!" |
1433 |
|
[[ -z ${outputdir} ]] && die "mdownload(): no dir given!" |
1434 |
|
|
1435 |
|
# convert mirrored uris to the real ones |
1436 |
|
real_uris="$(convertmirrors ${uri})" |
1437 |
|
|
1438 |
|
# verbose or not |
1439 |
|
mqueryfeature "!verbose" && wget_opts+=" --quiet" |
1440 |
|
|
1441 |
|
# filter wget options if busybox was found |
1442 |
|
wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1443 |
|
|
1444 |
|
# create outputdir |
1445 |
|
[[ ! -d ${outputdir} ]] && install -d "${outputdir}" |
1446 |
|
|
1447 |
|
for mirror in ${real_uris} |
1448 |
|
do |
1449 |
|
# get the name of the output file |
1450 |
|
outputfile="${mirror##*/}" |
1451 |
|
|
1452 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1453 |
|
retval="$?" |
1454 |
|
if [[ ${retval} = 0 ]] |
1455 |
|
then |
1456 |
|
break |
1457 |
|
else |
1458 |
|
continue |
1459 |
|
fi |
1460 |
|
done |
1461 |
|
|
1462 |
|
# return wget retval |
1463 |
|
return "${retval}" |
1464 |
|
} |
1465 |
|
|
1466 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
1467 |
fetch_packages() |
fetch_packages() |
1468 |
{ |
{ |
1469 |
|
local i |
1470 |
local list="$@" |
local list="$@" |
1471 |
local pkg |
local pkg |
1472 |
local mirr |
local mirr |
1475 |
local opt |
local opt |
1476 |
local count_current |
local count_current |
1477 |
local count_total |
local count_total |
1478 |
|
local wget_opts |
1479 |
|
|
1480 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1481 |
|
|
1482 |
|
# filter wget command if busybox was found |
1483 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1484 |
|
|
1485 |
# get count of total packages |
# get count of total packages |
1486 |
declare -i count_current=0 |
declare -i count_current=0 |
1487 |
declare -i count_total=0 |
declare -i count_total=0 |
1520 |
continue |
continue |
1521 |
fi |
fi |
1522 |
|
|
1523 |
for mirr in ${MIRRORS} |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1524 |
do |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1525 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" |
|
#echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... " |
|
|
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
|
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
|
|
wget \ |
|
|
${WGET_FETCH_OPTIONS} \ |
|
|
--directory-prefix=${PKGDIR} \ |
|
|
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
|
|
if [[ $? = 0 ]] |
|
|
then |
|
|
break |
|
|
else |
|
|
continue |
|
|
fi |
|
|
done |
|
|
|
|
1526 |
if [ ! -f ${PKGDIR}/${pkg} ] |
if [ ! -f ${PKGDIR}/${pkg} ] |
1527 |
then |
then |
1528 |
die "Could not download ${pkg}" |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
1529 |
fi |
fi |
1530 |
done |
done |
1531 |
|
|
1553 |
done |
done |
1554 |
|
|
1555 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1556 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1557 |
|
|
1558 |
# check if a newer mage version is available |
# check if a newer mage version is available |
1559 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1566 |
local temp="$(mktemp -d)" |
local temp="$(mktemp -d)" |
1567 |
local mirr mymirr |
local mirr mymirr |
1568 |
local opt |
local opt |
1569 |
|
local tar_opts |
1570 |
|
local wget_opts |
1571 |
|
|
1572 |
# try to get the md5 marked as latest on the server |
# try to get the md5 marked as latest on the server |
1573 |
latest_md5="mage-latest.md5" |
latest_md5="mage-latest.md5" |
1575 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1576 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1577 |
|
|
1578 |
|
# filter wget command if busybox was found |
1579 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1580 |
|
|
1581 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1582 |
do |
do |
1583 |
# path without distribution |
# path without distribution |
1584 |
mymirr="${mirr%/*}" |
# (only for stable|testing|unstable and not DISTROTAG) |
1585 |
|
case ${mirr##*/} in |
1586 |
|
stable|testing|unstable) mymirr="${mirr%/*}";; |
1587 |
|
*) mymirr="${mirr}";; |
1588 |
|
esac |
1589 |
|
|
1590 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1591 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1592 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
mqueryfeature "!verbose" && opt="--quiet" |
1593 |
wget \ |
wget \ |
1594 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1595 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1596 |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1597 |
|
|
1598 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1599 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest tarball from ${mymirr} ..." |
1600 |
wget \ |
wget \ |
1601 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1602 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1603 |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1604 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1618 |
else |
else |
1619 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1620 |
echo -n "checking md5sum... " |
echo -n "checking md5sum... " |
1621 |
( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1622 |
fi |
fi |
1623 |
|
|
1624 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1625 |
then |
then |
1626 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1627 |
echo "cleaning old mage-tree ${MAGEDIR}..." |
echo "cleaning old mage-tree ${MAGEDIR}..." |
1628 |
rm -rf ${MAGEDIR} |
# honor mountpoints and empty dirs |
1629 |
|
if mountpoint -q ${MAGEDIR} |
1630 |
|
then |
1631 |
|
if ! mcheckemptydir ${MAGEDIR} |
1632 |
|
then |
1633 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r |
1634 |
|
fi |
1635 |
|
else |
1636 |
|
rm -rf ${MAGEDIR} |
1637 |
|
fi |
1638 |
|
fi |
1639 |
|
|
1640 |
|
if need_busybox_support tar |
1641 |
|
then |
1642 |
|
tar_opts="xjf" |
1643 |
|
else |
1644 |
|
tar_opts="xjmf" |
1645 |
fi |
fi |
1646 |
|
|
1647 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1648 |
echo "updating mage-tree from tarball ..." |
echo "updating mage-tree from tarball ..." |
1649 |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1650 |
tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1651 |
|
|
1652 |
if [[ -d ${temp} ]] |
if [[ -d ${temp} ]] |
1653 |
then |
then |
1693 |
} |
} |
1694 |
|
|
1695 |
|
|
1696 |
# cuts full pathnames or versioniezed names down to basename |
# unused? |
1697 |
choppkgname() |
# |
1698 |
{ |
# # cuts full pathnames or versionized names down to basename |
1699 |
#we want this only if full name was used |
# choppkgname() |
1700 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
# { |
1701 |
then |
# #we want this only if full name was used |
1702 |
#cuts ARCH and PBUILD |
# if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1703 |
#ARCH comes from ${MAGERC} |
# then |
1704 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
# #cuts ARCH and PBUILD |
1705 |
|
# #ARCH comes from ${MAGERC} |
1706 |
|
# MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g") |
1707 |
|
# |
1708 |
|
# #cuts version number |
1709 |
|
# MAGENAME=$(basename ${MAGENAME%-*} .mage) |
1710 |
|
# fi |
1711 |
|
# } |
1712 |
|
|
|
#cuts version number |
|
|
MAGENAME=$(basename ${MAGENAME%-*} .mage) |
|
|
fi |
|
|
} |
|
1713 |
|
|
1714 |
# get_categorie $PNAME, returns CATEGORIE |
# get_categorie $PNAME, returns CATEGORIE |
1715 |
# $1=pname |
# $1=pname |
1779 |
local magefile |
local magefile |
1780 |
|
|
1781 |
# do not list the content of a directory, only the name (-d) |
# do not list the content of a directory, only the name (-d) |
1782 |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
1783 |
do |
do |
1784 |
[[ -z ${magefile} ]] && continue |
[[ -z ${magefile} ]] && continue |
1785 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1788 |
then |
then |
1789 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1790 |
#for debug only |
#for debug only |
1791 |
[[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2 |
1792 |
fi |
fi |
1793 |
done |
done |
1794 |
|
|
|
# do not so anything |
|
|
# # stop here if HIGHEST_MAGEFILE is zero |
|
|
# # this package must be unstable or old |
|
|
# if [ -z "${HIGHEST_MAGEFILE}" ] |
|
|
# then |
|
|
# echo |
|
|
# echo -n "All packages named " |
|
|
# echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
|
|
# echo -n " are marked " |
|
|
# echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
|
|
# echo "." |
|
|
# echo "You need to declare USE_UNSTABLE=true to install this." |
|
|
# echo |
|
|
# echo "Example:" |
|
|
# echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
|
|
# echo |
|
|
# echo "Be warned that these packages are not stable and may cause serious problems." |
|
|
# echo "You should know what you are doing, so don't complain about any damage." |
|
|
# echo |
|
|
# return 1 |
|
|
# fi |
|
|
|
|
1795 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1796 |
return 0 |
return 0 |
1797 |
} |
} |
1895 |
local filename="${file##*/}" |
local filename="${file##*/}" |
1896 |
local count |
local count |
1897 |
local output |
local output |
1898 |
|
local oldprotected |
1899 |
local i |
local i |
1900 |
|
local x |
1901 |
|
|
1902 |
declare -i count=0 |
# hack; do not honor a global set IFS like '§' |
1903 |
|
local IFS |
1904 |
|
|
1905 |
|
count=0 |
1906 |
|
|
1907 |
# check if there are already protected files |
# check if there are already protected files |
1908 |
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1909 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1910 |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1911 |
do |
do |
1912 |
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1913 |
done |
done |
1914 |
(( count ++ )) |
|
1915 |
|
# convert 0001 -> 1; 0120 -> 120 etc |
1916 |
|
# use bash internal base functions to this task |
1917 |
|
x="$((10#${count}))" |
1918 |
|
for (( i=0; i<x; i++ )) |
1919 |
|
do |
1920 |
|
if [[ ${count:${i}:1} != 0 ]] |
1921 |
|
then |
1922 |
|
count="${count:${i}}" |
1923 |
|
break |
1924 |
|
fi |
1925 |
|
done |
1926 |
|
|
1927 |
|
count="$(( ${count}+1 ))" |
1928 |
|
|
1929 |
# fill output up with zeros |
# fill output up with zeros |
1930 |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
2214 |
then |
then |
2215 |
for i in $* |
for i in $* |
2216 |
do |
do |
2217 |
[[ ${MAGEDEBUG} = on ]] && \ |
mqueryfeature "debug" && \ |
2218 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2219 |
source ${MAGEDIR}/include/${i}.minc |
source ${MAGEDIR}/include/${i}.minc |
2220 |
done |
done |
2221 |
[[ ${MAGEDEBUG} = on ]] && echo |
mqueryfeature "debug" && echo |
2222 |
fi |
fi |
2223 |
} |
} |
2224 |
|
|
2662 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${MAGE_TARGETS} ]] |
2663 |
then |
then |
2664 |
# basic svn compat |
# basic svn compat |
2665 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2666 |
then |
then |
2667 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2668 |
do |
do |
2669 |
smage2file="${i}" |
smage2file="${i}" |
2670 |
done |
done |
2675 |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2676 |
then |
then |
2677 |
# basic svn compat |
# basic svn compat |
2678 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2679 |
then |
then |
2680 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2681 |
do |
do |
2682 |
smage2file="${i}" |
smage2file="${i}" |
2683 |
done |
done |
2687 |
|
|
2688 |
else |
else |
2689 |
# basic svn compat |
# basic svn compat |
2690 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2691 |
then |
then |
2692 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2693 |
do |
do |
2694 |
smage2file="${i}" |
smage2file="${i}" |
2695 |
done |
done |
2714 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2715 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2716 |
then |
then |
2717 |
|
unpack_package "${magefile}" |
2718 |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
2719 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2720 |
fi |
fi |
2829 |
then |
then |
2830 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2831 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2832 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed" |
2833 |
else |
else |
2834 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2835 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
3069 |
local state |
local state |
3070 |
local descriptiom |
local descriptiom |
3071 |
local homepage |
local homepage |
3072 |
|
local license |
3073 |
local i |
local i |
3074 |
local all_installed |
local all_installed |
3075 |
local ipver |
local ipver |
3106 |
state="$(get_value_from_magefile STATE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
3107 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
3108 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
3109 |
|
license="$(get_value_from_magefile LICENSE ${magefile})" |
3110 |
|
|
3111 |
# all installed |
# all installed |
3112 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
3113 |
do |
do |
3114 |
ipver="$(magename2pver ${i})" |
ipver="$(magename2pver ${i})" |
3115 |
ipbuild="$(magename2pbuild ${i})" |
ipbuild="$(magename2pbuild ${i})" |
3116 |
|
|
3117 |
if [[ -z ${all_installed} ]] |
if [[ -z ${all_installed} ]] |
3118 |
then |
then |
3119 |
all_installed="${ipver}-${ipbuild}" |
all_installed="${ipver}-${ipbuild}" |
3122 |
fi |
fi |
3123 |
done |
done |
3124 |
[[ -z ${all_installed} ]] && all_installed="none" |
[[ -z ${all_installed} ]] && all_installed="none" |
3125 |
|
|
3126 |
case ${state} in |
case ${state} in |
3127 |
stable) state=${COLGREEN}"[s] ";; |
stable) state=${COLGREEN}"[s] ";; |
3128 |
testing) state=${COLYELLOW}"[t] ";; |
testing) state=${COLYELLOW}"[t] ";; |
3146 |
"") continue;; |
"") continue;; |
3147 |
esac |
esac |
3148 |
|
|
3149 |
deps="${deps} $(basename ${dep%-*})" |
if [[ -z ${deps} ]] |
3150 |
|
then |
3151 |
|
deps="$(basename ${dep%-*})" |
3152 |
|
else |
3153 |
|
deps="${deps} $(basename ${dep%-*})" |
3154 |
|
fi |
3155 |
done << EOF |
done << EOF |
3156 |
${depsfull} |
${depsfull} |
3157 |
EOF |
EOF |
3162 |
"") continue;; |
"") continue;; |
3163 |
esac |
esac |
3164 |
|
|
3165 |
sdeps="${sdeps} $(basename ${dep%-*})" |
if [[ -z ${sdeps} ]] |
3166 |
|
then |
3167 |
|
sdeps="$(basename ${dep%-*})" |
3168 |
|
else |
3169 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
3170 |
|
fi |
3171 |
done << EOF |
done << EOF |
3172 |
${sdepsfull} |
${sdepsfull} |
3173 |
EOF |
EOF |
3177 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
3178 |
echo " Description: ${description}" |
echo " Description: ${description}" |
3179 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
3180 |
echo " Depends: ${deps}" |
if [[ ! -z ${license} ]] |
3181 |
|
then |
3182 |
|
echo " License: ${license}" |
3183 |
|
fi |
3184 |
|
echo " Depends: ${deps}" |
3185 |
echo " SDepends: ${sdeps}" |
echo " SDepends: ${sdeps}" |
3186 |
echo |
echo |
3187 |
|
|
3221 |
eval "${functions}() { ${include}_${functions} ; }" |
eval "${functions}() { ${include}_${functions} ; }" |
3222 |
|
|
3223 |
# debug |
# debug |
3224 |
[[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
mqueryfeature "debug" && typeset -f "${functions}" |
3225 |
|
|
3226 |
shift |
shift |
3227 |
done |
done |
3293 |
return 0 |
return 0 |
3294 |
} |
} |
3295 |
|
|
3296 |
|
# need_busybox_support ${cmd} |
3297 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3298 |
|
need_busybox_support() |
3299 |
|
{ |
3300 |
|
local cmd |
3301 |
|
local busybox |
3302 |
|
cmd="$1" |
3303 |
|
|
3304 |
|
for busybox in {,/usr}/bin/busybox |
3305 |
|
do |
3306 |
|
if [[ -x ${busybox} ]] |
3307 |
|
then |
3308 |
|
if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]] |
3309 |
|
then |
3310 |
|
# needs busybox support |
3311 |
|
return 0 |
3312 |
|
fi |
3313 |
|
fi |
3314 |
|
done |
3315 |
|
|
3316 |
|
# no busybox |
3317 |
|
return 1 |
3318 |
|
} |
3319 |
|
|
3320 |
|
# busybox_filter_wget_options ${wget_opts} |
3321 |
|
busybox_filter_wget_options() |
3322 |
|
{ |
3323 |
|
local opts="$@" |
3324 |
|
local i |
3325 |
|
local fixed_opts |
3326 |
|
|
3327 |
|
if need_busybox_support wget |
3328 |
|
then |
3329 |
|
for i in ${opts} |
3330 |
|
do |
3331 |
|
# show only the allowed ones |
3332 |
|
case ${i} in |
3333 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3334 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3335 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3336 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3337 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3338 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3339 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3340 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3341 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3342 |
|
# simply drop all other opts |
3343 |
|
*) continue ;; |
3344 |
|
esac |
3345 |
|
done |
3346 |
|
|
3347 |
|
echo "${fixed_opts}" |
3348 |
|
else |
3349 |
|
echo "${opts}" |
3350 |
|
fi |
3351 |
|
} |
3352 |
|
|
3353 |
|
have_root_privileges() |
3354 |
|
{ |
3355 |
|
local retval |
3356 |
|
|
3357 |
|
if [[ $(id -u) = 0 ]] |
3358 |
|
then |
3359 |
|
retval=0 |
3360 |
|
else |
3361 |
|
retval=1 |
3362 |
|
fi |
3363 |
|
|
3364 |
|
return ${retval} |
3365 |
|
} |
3366 |
|
|
3367 |
|
known_mage_feature() |
3368 |
|
{ |
3369 |
|
local feature="$1" |
3370 |
|
local retval |
3371 |
|
|
3372 |
|
case "${feature}" in |
3373 |
|
autosvc|!autosvc) retval=0 ;; |
3374 |
|
buildlog|!buildlog) retval=0 ;; |
3375 |
|
ccache|!ccache) retval=0 ;; |
3376 |
|
check|!check) retval=0 ;; |
3377 |
|
compressdoc|!compressdoc) retval=0 ;; |
3378 |
|
debug|!debug) retval=0 ;; |
3379 |
|
distcc|!distcc) retval=0 ;; |
3380 |
|
icecc|!icecc) retval=0 ;; |
3381 |
|
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3382 |
|
libtool|!libtool) retval=0 ;; |
3383 |
|
linuxsymlink|!linuxsymlink) retval=0 ;; |
3384 |
|
pkgbuild|!pkgbuild) retval=0 ;; |
3385 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3386 |
|
purge|!purge) retval=0 ;; |
3387 |
|
qalint|!qalint) retval=0 ;; |
3388 |
|
regentree|!regentree) retval=0 ;; |
3389 |
|
resume|!resume) retval=0 ;; |
3390 |
|
srcpkgbuild|!srcpkgbuild) retval=0 ;; |
3391 |
|
srcpkgtarball|!srcpkgtarball) retval=0 ;; |
3392 |
|
static|!static) retval=0 ;; |
3393 |
|
stepbystep|!stepbystep) retval=0 ;; |
3394 |
|
strip|!strip) retval=0 ;; |
3395 |
|
verbose|!verbose) retval=0 ;; |
3396 |
|
*) retval=1 ;; |
3397 |
|
esac |
3398 |
|
|
3399 |
|
return "${retval}" |
3400 |
|
} |
3401 |
|
|
3402 |
|
load_mage_features() |
3403 |
|
{ |
3404 |
|
for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} |
3405 |
|
do |
3406 |
|
FVERBOSE=off msetfeature ${i} |
3407 |
|
done |
3408 |
|
} |
3409 |
|
|
3410 |
|
msetfeature() |
3411 |
|
{ |
3412 |
|
local feature |
3413 |
|
local count |
3414 |
|
local i |
3415 |
|
local found |
3416 |
|
|
3417 |
|
for feature in $@ |
3418 |
|
do |
3419 |
|
found=0 |
3420 |
|
count="${#MAGE_FEATURES_CURRENT[*]}" |
3421 |
|
|
3422 |
|
if ! known_mage_feature "${feature}" |
3423 |
|
then |
3424 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3425 |
|
return 3 |
3426 |
|
fi |
3427 |
|
|
3428 |
|
for ((i=0; i<count; i++)) |
3429 |
|
do |
3430 |
|
if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]] |
3431 |
|
then |
3432 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}" |
3433 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3434 |
|
found=1 |
3435 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]] |
3436 |
|
then |
3437 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}" |
3438 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3439 |
|
found=1 |
3440 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]] |
3441 |
|
then |
3442 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}" |
3443 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3444 |
|
found=1 |
3445 |
|
fi |
3446 |
|
done |
3447 |
|
|
3448 |
|
# if the feature was not found after proccessing the whole array |
3449 |
|
# it was not declared. in this case enable it |
3450 |
|
if [[ ${found} = 0 ]] |
3451 |
|
then |
3452 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}" |
3453 |
|
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3454 |
|
fi |
3455 |
|
|
3456 |
|
export MAGE_FEATURE_CURRENT |
3457 |
|
done |
3458 |
|
} |
3459 |
|
|
3460 |
|
mqueryfeature() |
3461 |
|
{ |
3462 |
|
local feature="$1" |
3463 |
|
local retval=1 |
3464 |
|
local i |
3465 |
|
|
3466 |
|
if known_mage_feature "${feature}" |
3467 |
|
then |
3468 |
|
for i in ${MAGE_FEATURES_CURRENT[*]} |
3469 |
|
do |
3470 |
|
if [[ ${i} = ${feature} ]] |
3471 |
|
then |
3472 |
|
retval=0 |
3473 |
|
break # found break here |
3474 |
|
fi |
3475 |
|
done |
3476 |
|
else |
3477 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3478 |
|
retval=3 |
3479 |
|
fi |
3480 |
|
|
3481 |
|
return ${retval} |
3482 |
|
} |
3483 |
|
|
3484 |
|
mprintfeatures() |
3485 |
|
{ |
3486 |
|
echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}" |
3487 |
|
echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}" |
3488 |
|
echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}" |
3489 |
|
} |