Magellan Linux

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

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

revision 43 by niro, Mon Jan 10 01:59:03 2005 UTC revision 186 by niro, Tue Aug 16 23:23:33 2005 UTC
# Line 4  Line 4 
4  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
5    
6  # SMAGE2  # SMAGE2
7  # version: 0.3.6-r11  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.21 2005-08-16 23:23:26 niro Exp $
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 ##
 SMAGEVERSION=0.3.6-r11  
14  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
15  SMAGENAME="$1"  SMAGENAME="$1"
16  SMAGESUFFIX="smage2"  SMAGESUFFIX="smage2"
# Line 19  SMAGESUFFIX="smage2" Line 18  SMAGESUFFIX="smage2"
18  #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"  #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"
19  #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"  #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"
20  MLIBDIR=/usr/lib/mage  MLIBDIR=/usr/lib/mage
21    SMAGEVERSION="$( < ${MLIBDIR}/version)"
22    
23    # export default C locale
24    export LC_ALL=C
25    
26  source /etc/mage.rc  source /etc/mage.rc
27    
# Line 84  syncsmage2() { Line 87  syncsmage2() {
87   xtitleclean   xtitleclean
88  }  }
89    
90    # $1 filename
91    get_db_md5_sum() {
92     local DB_FILE
93     local MD5_FILE
94     local i
95    
96     DB_ENTRY="$(basename $1)"
97     MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})"
98    
99     i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)"
100    
101     echo "${i}"
102    }
103    
104    download_sources() {
105    
106     [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
107    
108     local EOA=${#SRC_URI[*]}
109     local my_SRC_URI
110     local my_SRC_URI_DEST
111     local my_SRC_URI_MIRROR
112     local my_SOURCEDIR
113     local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
114     local FETCHING
115     local i mirror
116    
117    
118     #install SRCDIR/PNAME if not exist
119     [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
120    
121     # check if FETCHING is needed
122     ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
123     if [[ $? == 0 ]]
124     then
125     # md5's ok, not fetching needed
126     FETCHING=false
127     else
128     FETCHING=true
129     fi
130    
131     for ((i=0; i < EOA; i++))
132     do
133     # url to file
134     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
135    
136     # subdir in sources dir; the my_SRCI_URI file goes to there
137     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
138    
139     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
140     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
141     then
142     my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}"
143     else
144     my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
145     fi
146    
147     # if an mirrored file than replace first the mirror uri
148     if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]
149     then
150     for mirror in ${MIRRORS}
151     do
152     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"
153    
154     #echo "DEBUG: ${MY_SRC_URI}"
155     if [[ ${FETCHING} == true ]]
156     then
157     echo "==> fetching ${my_SRC_URI_MIRROR}"
158     wget \
159     --passive-ftp \
160     --tries 3 \
161     --continue \
162     --progress bar \
163     --directory-prefix="${my_SOURCEDIR}" \
164     "${my_SRC_URI_MIRROR}"
165     if [ "$?" == "0" ]
166     then
167     break
168     else
169     continue
170     fi
171     fi
172     done
173     else
174     #echo "DEBUG: ${SRC_URI[${i}]}"
175     if [[ ${FETCHING} == true ]]
176     then
177     echo "==> fetching ${my_SRC_URI}"
178     wget \
179     --passive-ftp \
180     --tries 3 \
181     --continue \
182     --progress bar \
183     --directory-prefix="${my_SOURCEDIR}" \
184     "${my_SRC_URI}"
185    # only needed to run through a list of mirrors
186    # if [ "$?" == "0" ]
187    # then
188    # break
189    # else
190    # continue
191    # fi
192     fi
193     fi
194    
195     # unset them to be shure
196     unset my_SRC_URI
197     unset my_SRC_URI_DEST
198     unset my_SRC_URI_MIRROR
199     unset my_SOURCEDIR
200     done
201    
202     # recheck md5 sums
203     echo
204     echo ">== Checking MD5 sums:"
205     ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"
206     echo
207    
208     # not needed anymore
209     unset SRC_URI
210    }
211    
212  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
213  src_prepare() {  src_prepare() {
214   echo "no src_prepare defined"   echo "no src_prepare defined"
# Line 218  minstalldocs() { Line 343  minstalldocs() {
343   done   done
344  }  }
345    
346    mstriplibs() {
347     local stripdir="$@"
348    
349     [ -z "${stripdir}" ] && stripdir=${BINDIR}
350     find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
351    }
352    
353    mstripbins() {
354     local stripdir="$@"
355    
356     [ -z "${stripdir}" ] && stripdir=${BINDIR}
357     find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
358    }
359    
360    sminclude() {
361     local i
362    
363     if [[ -n "$@" ]]
364     then
365     for i in $@
366     do
367     echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
368     source ${SMAGESCRIPTSDIR}/include/${i}.sminc
369     done
370     echo
371     fi
372    }
373    
374  setup_distcc_environment(){  setup_distcc_environment(){
375   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
376   then   then
# Line 258  setup_ccache_environment(){ Line 411  setup_ccache_environment(){
411   fi   fi
412  }  }
413    
414    # print out our version
415    showversion
416    echo
417    
418  if [ -z "$1" ]  if [ -z "$1" ]
419  then  then
  showversion  
  echo  
420   echo "No .smage2 file given. Exiting."   echo "No .smage2 file given. Exiting."
421   echo   echo
422   exit 1   exit 1
# Line 270  fi Line 425  fi
425  #updating smage2-scripts  #updating smage2-scripts
426  if [ "$1" == "update" ]  if [ "$1" == "update" ]
427  then  then
428   showversion   if [ ! -d ${SOURCEDIR} ]
  if [ ! -d ${SMAGESCRIPTSDIR} ]  
429   then   then
430   install -d ${SMAGESCRIPTSDIR}   install -d ${SOURCEDIR}
431   fi   fi
432   syncsmage2   syncsmage2
433   exit 0   exit 0
434  fi  fi
435    
436    #creates md5sums for smages to given dir
437    if [ "$1" == "calcmd5" ]
438    then
439     if [ $# -ge 3 ]
440     then
441     SMAGENAME="$2"
442     MD5DIR="$3"
443     source ${SMAGENAME} || die "download source failed"
444    
445     # overridable sourcedir; must be declared after source of the smage2
446     CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
447    
448     [ -z "${SRC_URI}" ] && die "Nothing declared to calculate."
449    
450     # end of array
451     EOA=${#SRC_URI[*]}
452    
453     [ ! -d ${MD5DIR} ] && install -d ${MD5DIR}
454    
455     # clear md5sum file
456     MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
457     echo -n > ${MY_MD5_FILE}
458    
459     for ((i=0; i < EOA; i++))
460     do
461     # url to file
462     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
463    
464     # subdir in sources dir; the my_SRCI_URI file goes to there
465     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
466    
467     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
468     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
469     then
470     MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})"
471     else
472     MY_SRC_FILE="$(basename ${SRC_URI[${i}]})"
473     fi
474    
475     if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ]
476     then
477     echo "calculating $(basename ${MY_SRC_FILE}) ..."
478     ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE}
479     else
480     echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}."
481     fi
482    
483     # unset them to be shure
484     unset my_SRC_URI
485     unset my_SRC_URI_DEST
486     unset my_SRC_URI_MIRROR
487     unset my_SOURCEDIR
488     done
489    
490     echo
491     echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
492     echo
493     else
494     echo "Usage: Calculating MD5 Sums:"
495     echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"
496     echo
497     echo
498     echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
499     echo
500     exit 1
501     fi
502    
503     exit 0
504    fi
505    
506    #download sources
507    if [ "$1" == "download" -a -n "$2" ]
508    then
509     if [ ! -d ${SMAGESCRIPTSDIR} ]
510     then
511     install -d ${SMAGESCRIPTSDIR}
512     fi
513    
514     # get smage
515     SMAGENAME="$2"
516     MD5DIR="$(dirname ${SMAGENAME})/md5"
517     source ${SMAGENAME} || die "download source failed"
518    
519     download_sources
520     exit 0
521    fi
522    
523  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]
524  then  then
# Line 329  fi Line 569  fi
569    
570  source ${SMAGENAME} || die "source failed"  source ${SMAGENAME} || die "source failed"
571  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"
572    MD5DIR="$(dirname ${SMAGENAME})/md5"
573    
574  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
575    echo "Compiling ${PKGNAME}"
576    
577    #download sources
578    download_sources
579    
580  #fixes some issues with these functions  #fixes some issues with these functions
581  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
582  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
# Line 422  then Line 668  then
668   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info
669  fi  fi
670    
671    # stripping all bins and libs
672    case ${NOSTRIP} in
673     true|TRUE|yes|y)
674     echo -e "NOSTRIP=true detected; Package will not be stripped ..."
675     ;;
676     *)
677     echo -e "Stripping binaries ..."
678     mstripbins ${BINDIR}
679     echo -e "Stripping libraries ..."
680     mstriplibs ${BINDIR}
681     ;;
682    esac
683    
684  #the new buildpkg command  #the new buildpkg command
685  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
686   true|TRUE|yes|y)   true|TRUE|yes|y)
# Line 435  esac Line 694  esac
694    
695  #for sure  #for sure
696  unset NOPKGBUILD  unset NOPKGBUILD
697    unset NOSTRIP
698    
699  xtitleclean  xtitleclean
700  #echo -e "\nPackage ${PKGNAME} successfully builded.\n"  #echo -e "\nPackage ${PKGNAME} successfully builded.\n"

Legend:
Removed from v.43  
changed lines
  Added in v.186