Magellan Linux

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

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

revision 256 by niro, Mon Oct 3 21:02:31 2005 UTC revision 306 by niro, Mon Dec 26 23:16:38 2005 UTC
# Line 4  Line 4 
4  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
5    
6  # SMAGE2  # SMAGE2
7  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.39 2005-10-03 21:02:31 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.40 2005-12-26 23:16:38 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
# Line 25  export LC_ALL=C Line 25  export LC_ALL=C
25    
26  source /etc/mage.rc  source /etc/mage.rc
27    
28  showversion() {  showversion()
29    {
30   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
31   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"
32  }  }
33    
34  die() {  die()
35    {
36   xtitleclean   xtitleclean
37   echo "SMAGE failed: $@"   echo "SMAGE failed: $@"
38   exit 1   exit 1
39  }  }
40    
41  xtitle() {  xtitle()
42   if [ ${TERM} == "xterm" ]  {
43     if [[ ${TERM} = xterm ]]
44   then   then
45   echo -ne "\033]0;[sMage: $@]\007"   echo -ne "\033]0;[sMage: $@]\007"
46   fi   fi
47   return 0   return 0
48  }  }
49    
50  xtitleclean() {  xtitleclean()
51   if [ ${TERM} == "xterm" ]  {
52     if [[ ${TERM} = xterm ]]
53   then   then
54   echo -ne "\033]0;\007"   echo -ne "\033]0;\007"
55   fi   fi
56   return 0   return 0
57  }  }
58    
59  syncsmage2() {  syncsmage2()
60    {
61   xtitle "Updating smage2-script tree ..."   xtitle "Updating smage2-script tree ..."
62   local i   local i
63   for i in ${SMAGE2RSYNC}   for i in ${SMAGE2RSYNC}
# Line 71  syncsmage2() { Line 76  syncsmage2() {
76   --delete \   --delete \
77   --delete-after \   --delete-after \
78   ${i} ${SMAGESCRIPTSDIR}   ${i} ${SMAGESCRIPTSDIR}
79    
80   if [ "$?" == "0" ]   if [[ $? = 0 ]]
81   then   then
82   break   break
83   else   else
84   continue   continue
85   fi   fi
86    
87   done   done
88    
89   #clean up backup files (foo~)   # clean up backup files (foo~)
90   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
91    
92   xtitleclean   xtitleclean
93  }  }
94    
95  # $1 filename  # $1 filename
96  get_db_md5_sum() {  get_db_md5_sum()
97    {
98   local DB_FILE   local DB_FILE
99   local MD5_FILE   local MD5_FILE
100   local i   local i
# Line 101  get_db_md5_sum() { Line 107  get_db_md5_sum() {
107   echo "${i}"   echo "${i}"
108  }  }
109    
110  download_sources() {  download_sources()
111    {
112    
113   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
114    
# Line 113  download_sources() { Line 120  download_sources() {
120   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
121   local FETCHING   local FETCHING
122   local i mirror   local i mirror
   
123    
124   #install SRCDIR/PNAME if not exist  
125     # install SRCDIR/PNAME if not exist
126   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
127    
128   # check if FETCHING is needed   # check if FETCHING is needed
129   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
130   if [[ $? == 0 ]]   if [[ $? = 0 ]]
131   then   then
132   # md5's ok, not fetching needed   # md5's ok, not fetching needed
133   FETCHING=false   FETCHING=false
134   else   else
135   FETCHING=true   FETCHING=true
136   fi   fi
137    
138   for ((i=0; i < EOA; i++))   for ((i=0; i < EOA; i++))
139   do   do
140   # url to file   # url to file
# Line 152  download_sources() { Line 159  download_sources() {
159   my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"   my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"
160    
161   #echo "DEBUG: ${MY_SRC_URI}"   #echo "DEBUG: ${MY_SRC_URI}"
162   if [[ ${FETCHING} == true ]]   if [[ ${FETCHING} = true ]]
163   then   then
164   echo "==> fetching ${my_SRC_URI_MIRROR}"   echo "==> fetching ${my_SRC_URI_MIRROR}"
165   wget \   wget \
# Line 162  download_sources() { Line 169  download_sources() {
169   --progress bar \   --progress bar \
170   --directory-prefix="${my_SOURCEDIR}" \   --directory-prefix="${my_SOURCEDIR}" \
171   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
172   if [ "$?" == "0" ]   if [[ $? = 0 ]]
173   then   then
174   break   break
175   else   else
# Line 172  download_sources() { Line 179  download_sources() {
179   done   done
180   else   else
181   #echo "DEBUG: ${SRC_URI[${i}]}"   #echo "DEBUG: ${SRC_URI[${i}]}"
182   if [[ ${FETCHING} == true ]]   if [[ ${FETCHING} = true ]]
183   then   then
184   echo "==> fetching ${my_SRC_URI}"   echo "==> fetching ${my_SRC_URI}"
185   wget \   wget \
# Line 191  download_sources() { Line 198  download_sources() {
198  # fi  # fi
199   fi   fi
200   fi   fi
201    
202   # unset them to be shure   # unset them to be shure
203   unset my_SRC_URI   unset my_SRC_URI
204   unset my_SRC_URI_DEST   unset my_SRC_URI_DEST
# Line 210  download_sources() { Line 217  download_sources() {
217  }  }
218    
219  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
220  src_prepare() {  src_prepare()
221    {
222   echo "no src_prepare defined"   echo "no src_prepare defined"
223   sleep 2   sleep 2
224   return 0   return 0
225  }  }
226    
227  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
228  src_compile() {  src_compile()
229    {
230   echo "no src_compile defined"   echo "no src_compile defined"
231   sleep 2   sleep 2
232   return 0   return 0
233  }  }
234    
235  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
236  src_install() {  src_install()
237    {
238   echo "no src_install defined"   echo "no src_install defined"
239   sleep 2   sleep 2
240   return 0   return 0
241  }  }
242    
243  mconfigure() {  mconfigure()
244    {
245   if [ -x ./configure ]   if [ -x ./configure ]
246   then   then
247   ./configure \   ./configure \
248   --prefix=/usr \   --prefix=/usr \
249   --host=${CHOST} \   --host=${CHOST} \
250   --mandir=/usr/share/man \   --mandir=/usr/share/man \
251   --infodir=/usr/share/info \   --infodir=/usr/share/info \
252   --datadir=/usr/share \   --datadir=/usr/share \
253   --sysconfdir=/etc \   --sysconfdir=/etc \
254   --localstatedir=/var/lib \   --localstatedir=/var/lib \
255   "$@" || die "mconfigure failed"   "$@" || die "mconfigure failed"
256   else   else
257   echo "configure is not an executable ..."   echo "configure is not an executable ..."
258   exit 1   exit 1
259   fi   fi
260  }  }
261    
262  minstall() {  minstall()
263   if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then  {
264     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
265     then
266   make prefix=${BINDIR}/usr \   make prefix=${BINDIR}/usr \
267   datadir=${BINDIR}/usr/share \   datadir=${BINDIR}/usr/share \
268   infodir=${BINDIR}/usr/share/info \   infodir=${BINDIR}/usr/share/info \
# Line 262  minstall() { Line 275  minstall() {
275          fi          fi
276  }  }
277    
278  mmake() {  mmake()
279    {
280   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
281  }  }
282    
283  munpack() {  munpack()
284    {
285   local SRCFILE   local SRCFILE
286   local IFTAR   local IFTAR
287   local DEST   local DEST
288    
289   SRCFILE=$1   SRCFILE=$1
290    
291   if [ -z "$2" ]   if [ -z "$2" ]
292   then   then
293   DEST=${BUILDDIR}   DEST=${BUILDDIR}
294   else   else
295   DEST=$2   DEST=$2
296   fi   fi
297    
298   case "${SRCFILE##*.}" in   case "${SRCFILE##*.}" in
299   bz2)   bz2)
300   IFTAR="$(basename $SRCFILE .bz2)"   IFTAR="$(basename $SRCFILE .bz2)"
301   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
302   if [ "${IFTAR}" == "tar" ]   if [[ ${IFTAR} = tar ]]
303   then   then
304   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
305   fi   fi
# Line 292  munpack() { Line 307  munpack() {
307   gz)   gz)
308   IFTAR="$(basename $SRCFILE .gz)"   IFTAR="$(basename $SRCFILE .gz)"
309   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
310   if [ "${IFTAR}" == "tar" ]   if [[ ${IFTAR} = tar ]]
311   then   then
312   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
313   fi   fi
# Line 309  munpack() { Line 324  munpack() {
324   esac   esac
325  }  }
326    
327  mpatch() {  mpatch()
328    {
329   local PATCHOPTS   local PATCHOPTS
330   local PATCHFILE   local PATCHFILE
331    
# Line 320  mpatch() { Line 336  mpatch() {
336  }  }
337    
338    
339  minstalldocs() {  minstalldocs()
340    {
341   local docfiles   local docfiles
   
342   docfiles="$@"   docfiles="$@"
343    
344   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
345   then   then
346   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
347   fi   fi
348    
349   for i in ${docfiles}   for i in ${docfiles}
350   do   do
351   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
# Line 338  minstalldocs() { Line 354  minstalldocs() {
354   done   done
355  }  }
356    
357  mstriplibs() {  mstriplibs()
358    {
359   local stripdir="$@"   local stripdir="$@"
360    
361   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
362   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
363  }  }
364    
365  mstripbins() {  mstripbins()
366    {
367   local stripdir="$@"   local stripdir="$@"
368    
369   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
370   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
371  }  }
372    
373  sminclude() {  sminclude()
374    {
375   local i   local i
376    
377   if [[ -n "$@" ]]   if [[ -n "$@" ]]
# Line 366  sminclude() { Line 385  sminclude() {
385   fi   fi
386  }  }
387    
388  setup_distcc_environment(){  setup_distcc_environment()
389    {
390   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
391   then   then
392   echo "Using DistCC for compilation ..."   echo "Using DistCC for compilation ..."
393   export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH"   export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
394    
395   #export distcc as compiler   # export distcc as compiler
396  # export CC="distcc"  # export CC="distcc"
397  # export CXX=distcc  # export CXX=distcc
398    
399   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
400    
401     # ccache + distcc together
402   #ccache + distcc together   if [[ ${SMAGE_USE_CCACHE} = true ]]
  if [ "${SMAGE_USE_CCACHE}" == "true" ]  
403   then   then
404   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
405   then   then
# Line 391  setup_distcc_environment(){ Line 410  setup_distcc_environment(){
410   fi   fi
411   fi   fi
412    
413   #creating distcc tempdir   # creating distcc tempdir
414   install -o distcc -g daemon -d ${DISTCC_DIR}   install -o distcc -g daemon -d ${DISTCC_DIR}
415   chmod 1777 ${DISTCC_DIR}   chmod 1777 ${DISTCC_DIR}
416   fi   fi
417  }  }
418    
419  setup_ccache_environment(){  setup_ccache_environment()
420    {
421   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
422   then   then
423   echo "Using CCache for compilation ..."   echo "Using CCache for compilation ..."
# Line 409  setup_ccache_environment(){ Line 429  setup_ccache_environment(){
429    
430  # fixes given dependencies to match a MAGE_TARGET  # fixes given dependencies to match a MAGE_TARGET
431  # fix_mage_deps -target s/depend # <-- note -target !  # fix_mage_deps -target s/depend # <-- note -target !
432  fix_mage_deps() {  fix_mage_deps()
433    {
434   local target="$1"   local target="$1"
435   local depend="$2"   local depend="$2"
436   local NDEPEND   local NDEPEND
# Line 512  build_mage_script() Line 533  build_mage_script()
533   > ${dest}   > ${dest}
534    
535   # header   # header
536   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.39 2005-10-03 21:02:31 niro Exp $' >> ${dest}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.40 2005-12-26 23:16:38 niro Exp $' >> ${dest}
537   echo  >> ${dest}   echo  >> ${dest}
538    
539   # pgkname and state   # pgkname and state
# Line 746  then Line 767  then
767  fi  fi
768    
769  # updating smage2-scripts  # updating smage2-scripts
770  if [ "$1" == "update" ]  if [[ $1 = update ]]
771  then  then
772   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
773   then   then
# Line 757  then Line 778  then
778  fi  fi
779    
780  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
781  if [ "$1" == "calcmd5" ]  if [[ $1 = calcmd5 ]]
782  then  then
783   if [ $# -ge 3 ]   if [ $# -ge 3 ]
784   then   then
# Line 809  then Line 830  then
830   unset my_SRC_URI_MIRROR   unset my_SRC_URI_MIRROR
831   unset my_SOURCEDIR   unset my_SOURCEDIR
832   done   done
833    
834   echo   echo
835   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
836   echo   echo
# Line 822  then Line 843  then
843   echo   echo
844   exit 1   exit 1
845   fi   fi
846    
847   exit 0   exit 0
848  fi  fi
849    
# Line 865  then Line 886  then
886   exit 0   exit 0
887  fi  fi
888    
889  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
890  then  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
891   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
892  fi  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly."
893    [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."
894  if [ -z "`basename ${SMAGENAME}|grep .${SMAGESUFFIX}`" ]  [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."
895  then  [ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc"
896   die "File '`basename ${SMAGENAME}`' is not a sMage v${SMAGEVERSION} file. Aborting."  [ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc"
897  fi  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc"
898    [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc"
 if [ -z "${SOURCEDIR}" ]  
 then  
  die "\$SOURCEDIR not found. Please setup your mage.rc correctly."  
 fi  
   
 if [ -z "${SMAGESCRIPTSDIR}" ]  
 then  
  die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."  
 fi  
   
 if [ -z "${SMAGE2RSYNC}" ]  
 then  
  echo "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."  
  exit 1  
 fi  
   
 if [ -z "${BINDIR}" ]  
 then  
  die "no BINDIR variable found in /etc/mage.rc"  
 fi  
   
 if [ -z "${CHOST}" ]  
 then  
  die "no CHOST variable found in /etc/mage.rc"  
 fi  
   
 if [ -z "${CFLAGS}" ]  
 then  
  die "no CFLAGS variable found in /etc/mage.rc"  
 fi  
   
 if [ -z "${CXXFLAGS}" ]  
 then  
  die "no CXXFLAGS variable found in /etc/mage.rc"  
 fi  
   
899    
900  source ${SMAGENAME} || die "source failed"  source ${SMAGENAME} || die "source failed"
901  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
# Line 940  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 925  export MAKEOPTS="${MAKEOPTS}" || die "MA
925    
926  # setup distcc  # setup distcc
927  # distcc mus be setup *before* ccache, as ccache need to be before distcc in path  # distcc mus be setup *before* ccache, as ccache need to be before distcc in path
928  if [ "${SMAGE_USE_DISTCC}" == "true" ]  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment
 then  
  setup_distcc_environment  
 fi  
929    
930  # setup ccache  # setup ccache
931  if [ "${SMAGE_USE_CCACHE}" == "true" ]  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
 then  
  setup_ccache_environment  
 fi  
   
932    
933  # small sleep to show our settings  # small sleep to show our settings
934  sleep 1  sleep 1
# Line 1035  case ${NOPKGBUILD} in Line 1013  case ${NOPKGBUILD} in
1013   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
1014   ;;   ;;
1015   *)   *)
1016   # build serveral targets   # build several targets
1017   if [ -n "${MAGE_TARGETS}" ]   if [ -n "${MAGE_TARGETS}" ]
1018   then   then
1019   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}

Legend:
Removed from v.256  
changed lines
  Added in v.306