Magellan Linux

Diff of /trunk/mage/usr/lib/mage/smage2.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1579 by niro, Wed Dec 28 10:56:10 2011 UTC revision 1580 by niro, Wed Dec 28 11:58:28 2011 UTC
# Line 139  get_db_md5_sum() Line 139  get_db_md5_sum()
139    
140  download_sources()  download_sources()
141  {  {
   
142   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
143    
144   local EOA=${#SRC_URI[*]}   local count=${#SRC_URI[*]}
145   local my_SRC_URI   local uri
146   local my_SRC_URI_DEST   local subdir
147   local my_SRC_URI_MIRROR   local outputdir
148   local my_SOURCEDIR   local db_md5_file="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
149   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local fetching
150   local FETCHING   local i
  local i mirror  
  local wget_opts  
   
  # filter wget command if busybox was found  
  wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"  
   
  # install SRCDIR/PNAME if not exist  
  [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}  
151    
152   # check if FETCHING is needed   # check if FETCHING is needed
153   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null )   if mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5
  if [[ $? = 0 ]]  
154   then   then
155   # md5's ok, no fetching needed   # md5's ok, no fetching needed
156   FETCHING=false   fetching=false
157   else   else
158   FETCHING=true   fetching=true
159   fi   fi
160    
161   for ((i=0; i < EOA; i++))   if [[ ${fetching} = true ]]
162   do   then
163   # url to file   for ((i=0; i < count; i++))
164   my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"   do
165     # url to file
166   # subdir in sources dir; the my_SRCI_URI file goes to there   uri="${SRC_URI[${i}]%%' '*}"
  my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"  
   
  # if my_src_uri_dest is not equal my_src_uri; than an other dir is used  
  if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]  
  then  
  my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}"  
  else  
  my_SOURCEDIR="${SOURCEDIR}/${PNAME}"  
  fi  
   
  # create the SOURCEDIR  
  install -d ${my_SOURCEDIR}  
   
  # if an mirrored file than replace first the mirror uri  
  if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]  
  then  
  for mirror in ${MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"  
   
  if [[ ${FETCHING} = true ]]  
  then  
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  ${wget_opts} \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]  
  then  
  for mirror in ${SOURCEFORGE_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"  
   
  if [[ ${FETCHING} = true ]]  
  then  
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  ${wget_opts} \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]  
  then  
  for mirror in ${GNU_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"  
   
  if [[ ${FETCHING} = true ]]  
  then  
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  ${wget_opts} \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]  
  then  
  for mirror in ${KDE_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"  
167    
168   if [[ ${FETCHING} = true ]]   # subdir in sources dir; the my_SRCI_URI file goes to there
169   then   subdir="${SRC_URI[${i}]##*' '}"
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  ${wget_opts} \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]  
  then  
  for mirror in ${GNOME_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"  
170    
171   if [[ ${FETCHING} = true ]]   # if $subdir is not equal with $uri then an other dir is used
172   then   if [[ ${uri} != ${subdir} ]]
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  ${wget_opts} \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  else  
  if [[ ${FETCHING} = true ]]  
173   then   then
174   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"   outputdir="${SOURCEDIR}/${PNAME}/${subdir}"
175   wget \   else
176   ${wget_opts} \   outputdir="${SOURCEDIR}/${PNAME}"
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \  
  "${my_SRC_URI}"  
177   fi   fi
  fi  
178    
179   # unset them to be shure   echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}"
180   unset my_SRC_URI   mdownload --uri "${uri}" --dir "${outputdir}" || die "Could not download '${uri}'"
  unset my_SRC_URI_DEST  
  unset my_SRC_URI_MIRROR  
  unset my_SOURCEDIR  
  done  
181    
182   # recheck md5 sums   # unset them to be sure
183   echo   unset uri
184   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   unset subdir
185   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed"   unset outputdir
186   echo   done
187    
188     # recheck md5 sums after download
189     echo
190     echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
191     mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed"
192     echo
193     else
194     echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}"
195     fi
196    
197   # not needed anymore   # not needed anymore
198   unset SRC_URI   unset SRC_URI
# Line 578  mstripstatic() Line 455  mstripstatic()
455   find ${stripdir} ! -type d | xargs file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null   find ${stripdir} ! -type d | xargs file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null
456  }  }
457    
458    mstriplibtoolarchive()
459    {
460     local stripdir="$@"
461    
462     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
463     find ${stripdir} ! -type d -name \*.la | xargs file | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null
464    }
465    
466    mpurgetargets()
467    {
468     local stripdir="$@"
469     local target
470    
471     [[ -z ${stripdir} ]] && stripdir=${BINDIR}
472     # nothing to do in this case
473     [[ -z ${PURGE_TARGETS[*]} ]] && return
474    
475     for target in ${PURGE_TARGETS[*]}
476     do
477     # check if target is a regex pattern without any slashes
478     if [[ ${target} = ${target//\/} ]]
479     then
480     find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null
481     else
482     rm -f -- ${target} 2> /dev/null
483     fi
484     done
485    }
486    
487  mcompressdocs()  mcompressdocs()
488  {  {
489   local bindir="$@"   local bindir="$@"
# Line 1569  else Line 1475  else
1475   mcompressdocs ${BINDIR}   mcompressdocs ${BINDIR}
1476  fi  fi
1477    
1478    if [[ ${SMAGE_STRIP_LIBTOOL} = true ]]
1479    then
1480     if [[ -n ${SPLIT_PACKAGES} ]]
1481     then
1482     for subpackage in ${SPLIT_PACKAGES}
1483     do
1484     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}"
1485     mstriplibtoolarchive ${BINDIR}_${subpackage}
1486     done
1487     else
1488     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}"
1489     mstriplibtoolarchive ${BINDIR}
1490     fi
1491    fi
1492    
1493    if [[ ${SMAGE_PURGE} = true ]]
1494    then
1495     if [[ -n ${SPLIT_PACKAGES} ]]
1496     then
1497     for subpackage in ${SPLIT_PACKAGES}
1498     do
1499     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}"
1500     mpurgetargets ${BINDIR}_${subpackage}
1501     done
1502     else
1503     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}"
1504     mpurgetargets ${BINDIR}
1505     fi
1506    fi
1507    
1508  # stripping all bins and libs  # stripping all bins and libs
1509  case ${NOSTRIP} in  case ${NOSTRIP} in

Legend:
Removed from v.1579  
changed lines
  Added in v.1580