4 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
5 |
|
|
6 |
# SMAGE2 |
# SMAGE2 |
7 |
# version: 0.3.6-r14 |
# version: 0.3.6-r15 |
8 |
|
|
9 |
#01.10.2004 |
#01.10.2004 |
10 |
# added ccache support |
# added ccache support |
11 |
# added distcc support |
# added distcc support |
12 |
|
|
13 |
## setup ## |
## setup ## |
14 |
SMAGEVERSION=0.3.6-r14 |
SMAGEVERSION=0.3.6-r15 |
15 |
PKGSUFFIX="mpk" |
PKGSUFFIX="mpk" |
16 |
SMAGENAME="$1" |
SMAGENAME="$1" |
17 |
SMAGESUFFIX="smage2" |
SMAGESUFFIX="smage2" |
103 |
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
104 |
|
|
105 |
local EOA=${#SRC_URI[*]} |
local EOA=${#SRC_URI[*]} |
106 |
local MY_SRC_URI |
local my_SRC_URI |
107 |
|
local my_SRC_URI_DEST |
108 |
|
local my_SRC_URI_MIRROR |
109 |
|
local my_SOURCEDIR |
110 |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
111 |
local FETCHING |
local FETCHING |
112 |
local i mirror |
local i mirror |
116 |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
117 |
|
|
118 |
# check if FETCHING is needed |
# check if FETCHING is needed |
119 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} > /dev/null ) |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
120 |
if [[ $? == 0 ]] |
if [[ $? == 0 ]] |
121 |
then |
then |
122 |
# md5's ok, not fetching needed |
# md5's ok, not fetching needed |
127 |
|
|
128 |
for ((i=0; i < EOA; i++)) |
for ((i=0; i < EOA; i++)) |
129 |
do |
do |
130 |
# get MD5 sum from database |
# url to file |
131 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
132 |
|
|
133 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
134 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
135 |
|
|
136 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
137 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
138 |
|
then |
139 |
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" |
140 |
|
else |
141 |
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
142 |
|
fi |
143 |
|
|
|
|
|
144 |
# if an mirrored file than replace first the mirror uri |
# if an mirrored file than replace first the mirror uri |
145 |
if [ -n "$(echo ${SRC_URI[${i}]} | grep 'mirror://')" ] |
if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
146 |
then |
then |
147 |
for mirror in ${MIRRORS} |
for mirror in ${MIRRORS} |
148 |
do |
do |
149 |
MY_SRC_URI="$(echo ${SRC_URI[${i}]} | sed "s|mirror:/|${mirror}/sources|g")" |
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
150 |
|
|
151 |
#echo "DEBUG: ${MY_SRC_URI}" |
#echo "DEBUG: ${MY_SRC_URI}" |
152 |
if [[ ${FETCHING} == true ]] |
if [[ ${FETCHING} == true ]] |
153 |
then |
then |
154 |
echo "==> fetching ${MY_SRC_URI}" |
echo "==> fetching ${my_SRC_URI_MIRROR}" |
155 |
wget \ |
wget \ |
156 |
--passive-ftp \ |
--passive-ftp \ |
157 |
--tries 3 \ |
--tries 3 \ |
158 |
--continue \ |
--continue \ |
159 |
--progress bar \ |
--progress bar \ |
160 |
--directory-prefix="${SOURCEDIR}/${PNAME}" \ |
--directory-prefix="${my_SOURCEDIR}" \ |
161 |
"${MY_SRC_URI}" |
"${my_SRC_URI_MIRROR}" |
162 |
if [ "$?" == "0" ] |
if [ "$?" == "0" ] |
163 |
then |
then |
164 |
break |
break |
171 |
#echo "DEBUG: ${SRC_URI[${i}]}" |
#echo "DEBUG: ${SRC_URI[${i}]}" |
172 |
if [[ ${FETCHING} == true ]] |
if [[ ${FETCHING} == true ]] |
173 |
then |
then |
174 |
echo "==> fetching ${SRC_URI[${i}]}" |
echo "==> fetching ${my_SRC_URI}" |
175 |
wget \ |
wget \ |
176 |
--passive-ftp \ |
--passive-ftp \ |
177 |
--tries 3 \ |
--tries 3 \ |
178 |
--continue \ |
--continue \ |
179 |
--progress bar \ |
--progress bar \ |
180 |
--directory-prefix="${SOURCEDIR}/${PNAME}" \ |
--directory-prefix="${my_SOURCEDIR}" \ |
181 |
"${MY_SRC_URI}" |
"${my_SRC_URI}" |
182 |
if [ "$?" == "0" ] |
if [ "$?" == "0" ] |
183 |
then |
then |
184 |
break |
break |
187 |
fi |
fi |
188 |
fi |
fi |
189 |
fi |
fi |
190 |
|
|
191 |
|
# unset them to be shure |
192 |
|
unset my_SRC_URI |
193 |
|
unset my_SRC_URI_DEST |
194 |
|
unset my_SRC_URI_MIRROR |
195 |
|
unset my_SOURCEDIR |
196 |
done |
done |
197 |
|
|
198 |
# recheck md5 sums |
# recheck md5 sums |
406 |
then |
then |
407 |
if [ $# -ge 3 ] |
if [ $# -ge 3 ] |
408 |
then |
then |
|
# overridable sourcedir |
|
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
|
|
|
|
409 |
SMAGENAME="$2" |
SMAGENAME="$2" |
410 |
MD5DIR="$3" |
MD5DIR="$3" |
411 |
source ${SMAGENAME} || die "download source failed" |
source ${SMAGENAME} || die "download source failed" |
412 |
|
|
413 |
|
# overridable sourcedir; must be declared after source of the smage2 |
414 |
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
415 |
|
|
416 |
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
417 |
|
|
418 |
# end of array |
# end of array |
426 |
|
|
427 |
for ((i=0; i < EOA; i++)) |
for ((i=0; i < EOA; i++)) |
428 |
do |
do |
429 |
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
# url to file |
430 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
431 |
|
|
432 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
433 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
434 |
|
|
435 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
436 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
437 |
|
then |
438 |
|
MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" |
439 |
|
else |
440 |
|
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
441 |
|
fi |
442 |
|
|
443 |
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
444 |
then |
then |
445 |
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
447 |
else |
else |
448 |
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
449 |
fi |
fi |
450 |
|
|
451 |
|
# unset them to be shure |
452 |
|
unset my_SRC_URI |
453 |
|
unset my_SRC_URI_DEST |
454 |
|
unset my_SRC_URI_MIRROR |
455 |
|
unset my_SOURCEDIR |
456 |
done |
done |
457 |
|
|
458 |
echo |
echo |