Magellan Linux

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

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

revision 947 by niro, Sat Nov 21 01:44:27 2009 UTC revision 1346 by niro, Sat Jun 4 09:20:09 2011 UTC
# Line 50  export LC_ALL=C Line 50  export LC_ALL=C
50    
51  source /etc/mage.rc.global  source /etc/mage.rc.global
52  source ${MAGERC}  source ${MAGERC}
53    source ${MLIBDIR}/mage4.functions.sh
54    
55  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
56  if [[ -n ${MROOT} ]]  if [[ -n ${MROOT} ]]
# Line 59  then Line 60  then
60   export BINDIR=${MROOT}/${BINDIR}   export BINDIR=${MROOT}/${BINDIR}
61  fi  fi
62    
63    # sources the smage file and uses state from distribution file if exist
64    # may helpful for repository support later on
65    smagesource()
66    {
67     local file="$1"
68     local mystate
69     local mycodename
70    
71     source ${file}
72    
73     [[ -n ${STATE} ]] && mystate="${STATE}"
74     if [ -f ${SMAGESCRIPTSDIR}/distribution ]
75     then
76     source ${SMAGESCRIPTSDIR}/distribution
77     [[ -n ${STATE} ]] && mystate="${STATE}"
78     fi
79     # now switch state and export it
80     STATE="${mystate}"
81    }
82    
83  showversion()  showversion()
84  {  {
85   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 153  download_sources() Line 174  download_sources()
174   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
175   local FETCHING   local FETCHING
176   local i mirror   local i mirror
177     local wget_opts
178    
179     # filter wget command if busybox was found
180     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
181    
182   # install SRCDIR/PNAME if not exist   # install SRCDIR/PNAME if not exist
183   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
184    
185   # check if FETCHING is needed   # check if FETCHING is needed
186   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null )
187   if [[ $? = 0 ]]   if [[ $? = 0 ]]
188   then   then
189   # md5's ok, no fetching needed   # md5's ok, no fetching needed
# Line 198  download_sources() Line 222  download_sources()
222   then   then
223   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
224   wget \   wget \
225   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
226   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
227   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
228   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 222  download_sources() Line 243  download_sources()
243   then   then
244   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
245   wget \   wget \
246   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
247   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
248   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
249   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 246  download_sources() Line 264  download_sources()
264   then   then
265   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
266   wget \   wget \
267   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
268   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
269   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
270   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 270  download_sources() Line 285  download_sources()
285   then   then
286   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
287   wget \   wget \
288   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
289   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
290   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
291   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 294  download_sources() Line 306  download_sources()
306   then   then
307   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
308   wget \   wget \
309   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
310   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
311   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
312   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 313  download_sources() Line 322  download_sources()
322   then   then
323   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
324   wget \   wget \
325   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
326   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
327   "${my_SRC_URI}"   "${my_SRC_URI}"
328   fi   fi
# Line 332  download_sources() Line 338  download_sources()
338   # recheck md5 sums   # recheck md5 sums
339   echo   echo
340   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
341   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed"
342   echo   echo
343    
344   # not needed anymore   # not needed anymore
# Line 520  mlibtoolize() Line 526  mlibtoolize()
526   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
527  }  }
528    
529    mautoreconf()
530    {
531     local opts="$@"
532     [[ -z ${opts} ]] && opts="--verbose --install --force"
533    
534     autoreconf ${opts} || die "running: mautoreconf ${opts}"
535    }
536    
537  minstalldocs()  minstalldocs()
538  {  {
539   local docfiles   local docfiles
# Line 530  minstalldocs() Line 544  minstalldocs()
544   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
545   fi   fi
546    
547     local i
548   for i in ${docfiles}   for i in ${docfiles}
549   do   do
550   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
551   install -m 0644 ${SRCDIR}/${i}.gz \   then
552   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
553     install -m 0644 ${SRCDIR}/${i}.gz \
554     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
555     fi
556   done   done
557  }  }
558    
# Line 844  regen_mage_tree() Line 862  regen_mage_tree()
862   export PNAME="${i}"   export PNAME="${i}"
863   split_info_${i}   split_info_${i}
864   build_mage_script --split-pkg-base "${split_pkg_base}"   build_mage_script --split-pkg-base "${split_pkg_base}"
865     # restore smage environment
866     split_restore_variables
867   done   done
868   echo   echo
869   # restore smage environment   # unset all saved smage variables
870   split_restore_variables   split_unset_variables
871    
872   else   else
873   echo   echo
# Line 1000  split_restore_variables() Line 1020  split_restore_variables()
1020   eval "${saved_postremove/SAVED_/}"   eval "${saved_postremove/SAVED_/}"
1021   export -f postremove   export -f postremove
1022   fi   fi
1023    }
1024    
1025    split_unset_variables()
1026    {
1027   # unset saved vars; not needed anymore   # unset saved vars; not needed anymore
1028   unset SAVED_PNAME   unset SAVED_PNAME
1029   unset SAVED_PVER   unset SAVED_PVER
# Line 1179  fi Line 1202  fi
1202  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1203  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1204  then  then
1205   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1206   then   then
1207   SMAGENAME="$2"   SMAGENAME="$2"
1208   MD5DIR="$3"   MD5DIR="$3"
1209   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1210    
1211     smagesource ${SMAGENAME} || die "download source failed"
1212    
1213   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1214   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1235  then Line 1260  then
1260   echo   echo
1261   else   else
1262   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1263   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1264   echo   echo
1265   echo   echo
1266   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1257  then Line 1282  then
1282   # get smage   # get smage
1283   SMAGENAME="$2"   SMAGENAME="$2"
1284   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1285   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1286    
1287   download_sources   download_sources
1288   exit 0   exit 0
# Line 1269  then Line 1294  then
1294   # set correct SMAGENAME   # set correct SMAGENAME
1295   SMAGENAME="$2"   SMAGENAME="$2"
1296   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1297   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1298    
1299   regen_mage_tree   regen_mage_tree
1300    
# Line 1292  then Line 1317  then
1317   elif [[ -n ${SPLIT_PACKAGES} ]]   elif [[ -n ${SPLIT_PACKAGES} ]]
1318   then   then
1319   split_save_variables   split_save_variables
1320   for subpackage in ${SPLIT_PACKAGE}   for subpackage in ${SPLIT_PACKAGES}
1321   do   do
1322   # get the right variables for the split   # get the right variables for the split
1323   export PNAME="${subpackage}"   export PNAME="${subpackage}"
# Line 1304  then Line 1329  then
1329   --pver "${PVER}" \   --pver "${PVER}" \
1330   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1331   --parch "${ARCH}"   --parch "${ARCH}"
1332     # restore smage environment
1333     split_restore_variables
1334   done   done
1335   split_restore_variables   # unset all saved smage variables
1336     split_unset_variables
1337    
1338   else   else
1339   # build md5sum for existing packages   # build md5sum for existing packages
# Line 1328  then Line 1356  then
1356    
1357   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1358    
1359   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1360    
1361   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1362   then   then
# Line 1377  fi Line 1405  fi
1405  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1406  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1407    
1408  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1409  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1410  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1411  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
# Line 1496  then Line 1524  then
1524   done   done
1525   # restore bindir & pname   # restore bindir & pname
1526   split_restore_variables   split_restore_variables
1527     # unset all saved smage variables
1528     split_unset_variables
1529  else  else
1530   src_install | ${SMAGE_LOG_CMD}   src_install | ${SMAGE_LOG_CMD}
1531   die_pipestatus 0 "src_install failed"   die_pipestatus 0 "src_install failed"
# Line 1505  fi Line 1535  fi
1535  # compressing doc, info & man files  # compressing doc, info & man files
1536  if [[ -n ${SPLIT_PACKAGES} ]]  if [[ -n ${SPLIT_PACKAGES} ]]
1537  then  then
1538   for subpackage in ${SPLIT_PACKAGE}   for subpackage in ${SPLIT_PACKAGES}
1539   do   do
1540   mcompressdocs ${BINDIR}_${subpackage}   mcompressdocs ${BINDIR}_${subpackage}
1541   done   done
# Line 1522  case ${NOSTRIP} in Line 1552  case ${NOSTRIP} in
1552   *)   *)
1553   if [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
1554   then   then
1555   for subpackage in ${SPLIT_PACKAGE}   for subpackage in ${SPLIT_PACKAGES}
1556   do   do
1557   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1558   mstripbins ${BINDIR}_${subpackage}   mstripbins ${BINDIR}_${subpackage}
1559   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"
1560   mstriplibs ${BINDIR}_${subpackage}   mstriplibs ${BINDIR}_${subpackage}
1561   done   done
1562   else   else
# Line 1607  case ${NOPKGBUILD} in Line 1637  case ${NOPKGBUILD} in
1637   --parch "${ARCH}"   --parch "${ARCH}"
1638    
1639   echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"   echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1640    
1641     # restore smage environment
1642     split_restore_variables
1643   done   done
1644   split_restore_variables   # unset all saved smage variables
1645     split_unset_variables
1646    
1647   else   else
1648   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"

Legend:
Removed from v.947  
changed lines
  Added in v.1346