Magellan Linux

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

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

revision 40 by niro, Thu Jan 6 23:28:28 2005 UTC revision 90 by niro, Tue Jun 28 20:39:35 2005 UTC
# Line 4  Line 4 
4  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
5    
6  # SMAGE2  # SMAGE2
7  # version: 0.3.6-r10  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.13 2005-06-28 20:39:35 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 ##
14  SMAGEVERSION=0.3.6-r10  SMAGEVERSION=0.3.6-r17
15  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
16  SMAGENAME="$1"  SMAGENAME="$1"
17  SMAGESUFFIX="smage2"  SMAGESUFFIX="smage2"
# Line 84  syncsmage2() { Line 84  syncsmage2() {
84   xtitleclean   xtitleclean
85  }  }
86    
87    # $1 filename
88    get_db_md5_sum() {
89     local DB_FILE
90     local MD5_FILE
91     local i
92    
93     DB_ENTRY="$(basename $1)"
94     MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})"
95    
96     i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)"
97    
98     echo "${i}"
99    }
100    
101    download_sources() {
102    
103     [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
104    
105     local EOA=${#SRC_URI[*]}
106     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"
111     local FETCHING
112     local i mirror
113    
114    
115     #install SRCDIR/PNAME if not exist
116     [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
117    
118     # check if FETCHING is needed
119     ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
120     if [[ $? == 0 ]]
121     then
122     # md5's ok, not fetching needed
123     FETCHING=false
124     else
125     FETCHING=true
126     fi
127    
128     for ((i=0; i < EOA; i++))
129     do
130     # 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
145     if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]
146     then
147     for mirror in ${MIRRORS}
148     do
149     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"
150    
151     #echo "DEBUG: ${MY_SRC_URI}"
152     if [[ ${FETCHING} == true ]]
153     then
154     echo "==> fetching ${my_SRC_URI_MIRROR}"
155     wget \
156     --passive-ftp \
157     --tries 3 \
158     --continue \
159     --progress bar \
160     --directory-prefix="${my_SOURCEDIR}" \
161     "${my_SRC_URI_MIRROR}"
162     if [ "$?" == "0" ]
163     then
164     break
165     else
166     continue
167     fi
168     fi
169     done
170     else
171     #echo "DEBUG: ${SRC_URI[${i}]}"
172     if [[ ${FETCHING} == true ]]
173     then
174     echo "==> fetching ${my_SRC_URI}"
175     wget \
176     --passive-ftp \
177     --tries 3 \
178     --continue \
179     --progress bar \
180     --directory-prefix="${my_SOURCEDIR}" \
181     "${my_SRC_URI}"
182    # only needed to run through a list of mirrors
183    # if [ "$?" == "0" ]
184    # then
185    # break
186    # else
187    # continue
188    # fi
189     fi
190     fi
191    
192     # unset them to be shure
193     unset my_SRC_URI
194     unset my_SRC_URI_DEST
195     unset my_SRC_URI_MIRROR
196     unset my_SOURCEDIR
197     done
198    
199     # recheck md5 sums
200     echo
201     echo ">== Checking MD5 sums:"
202     ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"
203     echo
204    
205     # not needed anymore
206     unset SRC_URI
207    }
208    
209  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
210  src_prepare() {  src_prepare() {
211   echo "no src_prepare defined"   echo "no src_prepare defined"
# Line 218  minstalldocs() { Line 340  minstalldocs() {
340   done   done
341  }  }
342    
343    mstriplibs() {
344     local stripdir="$@"
345    
346     [ -z "${stripdir}" ] && stripdir=${BINDIR}
347     find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
348    }
349    
350    mstripbins() {
351     local stripdir="$@"
352    
353     [ -z "${stripdir}" ] && stripdir=${BINDIR}
354     find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
355    }
356    
357  setup_distcc_environment(){  setup_distcc_environment(){
358   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
359   then   then
# Line 258  setup_ccache_environment(){ Line 394  setup_ccache_environment(){
394   fi   fi
395  }  }
396    
397    # print out our version
398    showversion
399    echo
400    
401  if [ -z "$1" ]  if [ -z "$1" ]
402  then  then
  showversion  
  echo  
403   echo "No .smage2 file given. Exiting."   echo "No .smage2 file given. Exiting."
404   echo   echo
405   exit 1   exit 1
# Line 270  fi Line 408  fi
408  #updating smage2-scripts  #updating smage2-scripts
409  if [ "$1" == "update" ]  if [ "$1" == "update" ]
410  then  then
411     if [ ! -d ${SOURCEDIR} ]
412     then
413     install -d ${SOURCEDIR}
414     fi
415     syncsmage2
416     exit 0
417    fi
418    
419    #creates md5sums for smages to given dir
420    if [ "$1" == "calcmd5" ]
421    then
422     if [ $# -ge 3 ]
423     then
424     SMAGENAME="$2"
425     MD5DIR="$3"
426     source ${SMAGENAME} || die "download source failed"
427    
428     # overridable sourcedir; must be declared after source of the smage2
429     CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
430    
431     [ -z "${SRC_URI}" ] && die "Nothing declared to calculate."
432    
433     # end of array
434     EOA=${#SRC_URI[*]}
435    
436     [ ! -d ${MD5DIR} ] && install -d ${MD5DIR}
437    
438     # clear md5sum file
439     MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
440     echo -n > ${MY_MD5_FILE}
441    
442     for ((i=0; i < EOA; i++))
443     do
444     # url to file
445     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
446    
447     # subdir in sources dir; the my_SRCI_URI file goes to there
448     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
449    
450     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
451     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
452     then
453     MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})"
454     else
455     MY_SRC_FILE="$(basename ${SRC_URI[${i}]})"
456     fi
457    
458     if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ]
459     then
460     echo "calculating $(basename ${MY_SRC_FILE}) ..."
461     ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE}
462     else
463     echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}."
464     fi
465    
466     # unset them to be shure
467     unset my_SRC_URI
468     unset my_SRC_URI_DEST
469     unset my_SRC_URI_MIRROR
470     unset my_SOURCEDIR
471     done
472    
473     echo
474     echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
475     echo
476     else
477     echo "Usage: Calculating MD5 Sums:"
478     echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"
479     echo
480     echo
481     echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
482     echo
483     exit 1
484     fi
485    
486     exit 0
487    fi
488    
489    #download sources
490    if [ "$1" == "download" -a -n "$2" ]
491    then
492   showversion   showversion
493   if [ ! -d ${SMAGESCRIPTSDIR} ]   if [ ! -d ${SMAGESCRIPTSDIR} ]
494   then   then
495   install -d ${SMAGESCRIPTSDIR}   install -d ${SMAGESCRIPTSDIR}
496   fi   fi
497   syncsmage2  
498     # get smage
499     SMAGENAME="$2"
500     MD5DIR="$(dirname ${SMAGENAME})/md5"
501     source ${SMAGENAME} || die "download source failed"
502    
503     download_sources
504   exit 0   exit 0
505  fi  fi
506    
   
507  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]
508  then  then
509   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
# Line 329  fi Line 553  fi
553    
554  source ${SMAGENAME} || die "source failed"  source ${SMAGENAME} || die "source failed"
555  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"
556    MD5DIR="$(dirname ${SMAGENAME})/md5"
557    
558  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
559    echo "Compiling ${PKGNAME}"
560    
561    #download sources
562    download_sources
563    
564  #fixes some issues with these functions  #fixes some issues with these functions
565  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
566  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
# Line 422  then Line 652  then
652   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info
653  fi  fi
654    
655    # stripping all bins and libs
656    case ${NOSTRIP} in
657     true|TRUE|yes|y)
658     echo -e "NOSTRIP=true detected; Package will not be stripped ..."
659     ;;
660     *)
661     echo -e "Stripping binaries ..."
662     mstripbins ${BINDIR}
663     echo -e "Stripping libraries ..."
664     mstriplibs ${BINDIR}
665     ;;
666    esac
667    
668  #the new buildpkg command  #the new buildpkg command
669  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
670   true|TRUE|yes|y)   true|TRUE|yes|y)
# Line 435  esac Line 678  esac
678    
679  #for sure  #for sure
680  unset NOPKGBUILD  unset NOPKGBUILD
681    unset NOSTRIP
682    
683  xtitleclean  xtitleclean
684  #echo -e "\nPackage ${PKGNAME} successfully builded.\n"  #echo -e "\nPackage ${PKGNAME} successfully builded.\n"

Legend:
Removed from v.40  
changed lines
  Added in v.90