--- trunk/mage/usr/lib/mage/mage4.functions.sh 2008/02/26 19:49:20 676 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2011/12/27 10:00:34 1548 @@ -1,6 +1,29 @@ #!/bin/bash # Magellan Linux Installer Functions (mage.functions.sh) -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.36 2008-02-26 19:49:20 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ + +COLRED="\033[1;6m\033[31m" +COLGREEN="\033[1;6m\033[32m" +COLYELLOW="\033[1;6m\033[33m" +COLBLUE="\033[1;6m\033[34m" +COLMAGENTA="\033[1;6m\033[35m" +COLWHITE="\033[1;6m\033[37m" +COLGRAY="\033[0;6m\033[37m" +COLBOLD="\033[1m" +COLDEFAULT="\033[0m" + +if [[ ${NOCOLORS} = true ]] +then + COLRED="" + COLGREEN="" + COLYELLOW="" + COLBLUE="" + COLMAGENTA="" + COLWHITE="" + COLGRAY="" + COLBOLD="" + COLDEFAULT="" +fi mage_setup() { @@ -23,6 +46,7 @@ local pkgtype local count_current local count_total + local tar_opts # get count of total packages declare -i count_current=0 @@ -54,8 +78,16 @@ continue fi + # busybox? + if need_busybox_support tar + then + tar_opts="xjf" + else + tar_opts="xjmf" + fi + echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " - tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" + tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" done # add a crlf for a better view @@ -132,7 +164,6 @@ [ -z "${pathto}" ] && continue [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" - # monitors /etc/env.d -> env-rebuild [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true @@ -198,10 +229,11 @@ is_config_protected "${pathto}" retval="$?" - # 0 - not protected # - # 1 - error # - # 2 - protected # - # 3 - protected but masked # + # 0 - not protected # + # 1 - error # + # 2 - protected # + # 3 - protected but masked # + # 4 - protected but ignored # case ${retval} in # file is not protected - (over)write it @@ -218,7 +250,7 @@ "${user}" \ "${group}" \ "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ - "${MROOT}${pathto}")" \ + "${MROOT}${pathto}")" \ "${md5sum}" ;; @@ -245,13 +277,33 @@ "${user}" \ "${group}" \ "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ - "${dest_protected}")" \ + "${dest_protected}")" \ "${md5sum}" # update global MAGE_PROTECT_COUNTER (( MAGE_PROTECT_COUNTER++ )) export MAGE_PROTECT_COUNTER ;; + + # file is protected but ignored, delete the update/do nothing + 4) + if [[ ${VERBOSE} = on ]] + then + echo -en "${COLRED}" + echo -n "! ignr " + echo -en "${COLDEFAULT}" + echo " === FILE: ${MROOT}${pathto}" + fi + # simply do nothing here - only fix mtime + fix_descriptor ${pkgname}/.files \ + "${pathto}" \ + "${posix}" \ + "${user}" \ + "${group}" \ + "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ + "${MROOT}${pathto}")" \ + "${md5sum}" + ;; esac done < ${BUILDDIR}/${pkgname}/.files @@ -298,19 +350,19 @@ ln -snf "${link}" "${MROOT}${pathto}" - # fix mtime and db - fix_descriptor ${pkgname}/.symlinks \ - "${pathto}" \ - "${posix}" \ - "${link}" \ - "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ - "${MROOT}${pathto}")" +# # fix mtime and db +# fix_descriptor ${pkgname}/.symlinks \ +# "${pathto}" \ +# "${posix}" \ +# "${link}" \ +# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ +# "${MROOT}${pathto}")" done < ${BUILDDIR}/${pkgname}/.symlinks - # now copy the fixed file over the old one - [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ - cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} +# # now copy the fixed file over the old one +# [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ +# cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} # very important: unsetting the '§' fieldseperator IFS=$'\n' @@ -326,6 +378,8 @@ local pkgname="$1" local pathto local posix + local user + local group local IFS # sanity checks; abort if not given @@ -339,12 +393,17 @@ # sets fieldseperator to "§" instead of " " IFS=§ - while read pathto posix + while read pathto posix major minor user group do [ -z "${pathto}" ] && continue [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" - mkfifo -m "${posix}" "${MROOT}$pathto" + mknod -m "${posix}" "${MROOT}${pathto}" + # make it optional atm !! + if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] + then + chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" + fi done < ${BUILDDIR}/${pkgname}/.pipes # very important: unsetting the '§' fieldseperator @@ -363,6 +422,8 @@ local posix local major local minor + local user + local group local IFS # sanity checks; abort if not given @@ -376,23 +437,68 @@ # sets fieldseperator to "§" instead of " " IFS=§ - while read pathto posix major minor + while read pathto posix major minor user group do [ -z "${pathto}" ] && continue [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" - mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} + mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" + + # make it optional atm !! + if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] + then + chown "${user}:${group}" "${MROOT}${pathto}" + fi done < ${BUILDDIR}/${pkgname}/.char # very important: unsetting the '§' fieldseperator IFS=$'\n' } +################################################### +# function install_fifos # +# install_fifos $PKGNAME # +################################################### +install_fifos() +{ + local pkgname="$1" + local pathto + local posix + local user + local group + local IFS + + # sanity checks; abort if not given + [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." + + # check needed global vars + [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." + + # make it optional atm !! + #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" + [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return + + # sets fieldseperator to "§" instead of " " + IFS=§ + + while read pathto posix user group + do + [ -z "${pathto}" ] && continue + [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" + + mkfifo -m "${posix}" "${MROOT}${pathto}" + chown "${user}:${group}" "${MROOT}${pathto}" + done < ${BUILDDIR}/${pkgname}/.fifo + + # very important: unsetting the '§' fieldseperator + IFS=$'\n' +} + ################################################### # function build_doinstall # # build_doinstall $PKGNAME # -# NOTE: this is an wrapper do install packages # +# NOTE: this is an wrapper to install packages # ################################################### build_doinstall() { @@ -400,7 +506,7 @@ # sanity checks; abort if not given [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." - + # this is only a wrapper # NOTE: @@ -415,6 +521,7 @@ install_symlinks ${pkgname} || die "install symlinks ${pkgname}" install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" + install_fifos ${pkgname} || die "install fifos ${pkgname}" } @@ -476,7 +583,7 @@ # create fake file descriptors # used by virtual and source packages - for i in .dirs .symlinks .files .pipes .char + for i in .dirs .symlinks .files .pipes .char .fifo do touch ${dbrecorddir}/${i} done @@ -494,10 +601,13 @@ # normal packages needs these files local i - for i in .char .dirs .files .pipes .symlinks + for i in .char .dirs .files .pipes .symlinks .fifo do - install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ - ${dbrecorddir}/${i} + # make .fifo optional atm + if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] + then + install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} + fi done ;; esac @@ -772,10 +882,10 @@ done # sanity checks; abort if not given - [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." - [ -z "${pname}" ] && die "remove_symlinks() \$pname not given." - [ -z "${pver}" ] && die "remove_symlinks() \$pver not given." - [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." + [ -z "${pcat}" ] && die "remove_files() \$pcat not given." + [ -z "${pname}" ] && die "remove_files() \$pname not given." + [ -z "${pver}" ] && die "remove_files() \$pver not given." + [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." pfull="${pcat}/${pname}-${pver}-${pbuild}" # check needed global vars @@ -809,10 +919,11 @@ is_config_protected "${pathto}" retval="$?" - # 0 - not protected # - # 1 - error # - # 2 - protected # - # 3 - protected but masked # + # 0 - not protected # + # 1 - error # + # 2 - protected # + # 3 - protected but masked # + # 4 - protected but ignored # case ${retval} in # file is not protected - delete it @@ -831,6 +942,18 @@ echo " === FILE: ${MROOT}${pathto}" fi ;; + + # file is protected but ignored, delete the update/do nothing + 4) + if [[ ${VERBOSE} = on ]] + then + echo -en "${COLRED}" + echo -n "! ignr " + echo -en "${COLDEFAULT}" + echo " === FILE: ${MROOT}${pathto}" + fi + # simply do nothing here + ;; esac ;; 1) @@ -853,6 +976,8 @@ { local pathto local posix + local user + local group local IFS local pcat local pname @@ -876,10 +1001,10 @@ done # sanity checks; abort if not given - [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." - [ -z "${pname}" ] && die "remove_symlinks() \$pname not given." - [ -z "${pver}" ] && die "remove_symlinks() \$pver not given." - [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." + [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." + [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." + [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." + [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." pfull="${pcat}/${pname}-${pver}-${pbuild}" # check needed global vars @@ -890,7 +1015,7 @@ # sets fieldseperator to "§" instead of " " IFS=§ - while read pathto posix + while read pathto posix user group do [ -z "${pathto}" ] && continue @@ -911,6 +1036,8 @@ { local pathto local posix + local user + local group local IFS local pcat local pname @@ -934,10 +1061,10 @@ done # sanity checks; abort if not given - [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." - [ -z "${pname}" ] && die "remove_symlinks() \$pname not given." - [ -z "${pver}" ] && die "remove_symlinks() \$pver not given." - [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." + [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." + [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." + [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." + [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." pfull="${pcat}/${pname}-${pver}-${pbuild}" # check needed global vars @@ -948,7 +1075,7 @@ # sets fieldseperator to "§" instead of " " IFS=§ - while read pathto posix + while read pathto posix user group do [ -z "${pathto}" ] && continue @@ -962,6 +1089,68 @@ ################################################### +# function remove_fifos # +# remove_fifos $PKGNAME # +################################################### +remove_fifos() +{ + local pathto + local posix + local user + local group + local IFS + local pcat + local pname + local pver + local pbuild + local i + local pfull + + IFS=$'\n' + + # very basic getops + for i in $* + do + case $1 in + --pcat|-c) shift; pcat="$1" ;; + --pname|-n) shift; pname="$1" ;; + --pver|-v) shift; pver="$1" ;; + --pbuild|-b) shift; pbuild="$1" ;; + esac + shift + done + + # sanity checks; abort if not given + [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." + [ -z "${pname}" ] && die "remove_fifos() \$pname not given." + [ -z "${pver}" ] && die "remove_fifos() \$pver not given." + [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." + pfull="${pcat}/${pname}-${pver}-${pbuild}" + + # check needed global vars + [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." + + # make it optional atm !! + #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" + [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return + + # sets fieldseperator to "§" instead of " " + IFS=§ + + while read pathto posix user group + do + [ -z "${pathto}" ] && continue + + [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" + rm "${MROOT}${pathto}" + done < ${MROOT}${INSTALLDB}/${pfull}/.fifo + + # very important: unsetting the '§' fieldseperator + IFS=$'\n' +} + + +################################################### # function remove_direcories # # remove_direcories $PKGNAME # ################################################### @@ -992,10 +1181,10 @@ done # sanity checks; abort if not given - [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." - [ -z "${pname}" ] && die "remove_symlinks() \$pname not given." - [ -z "${pver}" ] && die "remove_symlinks() \$pver not given." - [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." + [ -z "${pcat}" ] && die "remove_directories() \$pcat not given." + [ -z "${pname}" ] && die "remove_directories() \$pname not given." + [ -z "${pver}" ] && die "remove_directories() \$pver not given." + [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." pfull="${pcat}/${pname}-${pver}-${pbuild}" # check needed global vars @@ -1049,7 +1238,7 @@ ################################################### # function build_douninstall # # build_douninstall $PKGNAME # -# NOTE: this is an wrapper do remove packages # +# NOTE: this is an wrapper to remove packages # ################################################### build_douninstall() { @@ -1083,7 +1272,7 @@ # !! we use § as field seperator !! # doing so prevent us to get errors by filenames with spaces - for i in symlinks files blockdevices characterdevices directories + for i in symlinks files blockdevices characterdevices directories fifos do remove_${i} \ --pcat "${pcat}" \ @@ -1105,9 +1294,13 @@ local opt local count_current local count_total + local wget_opts [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." + # filter wget command if busybox was found + wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" + # get count of total packages declare -i count_current=0 declare -i count_total=0 @@ -1153,10 +1346,7 @@ echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " [[ ${VERBOSE} = off ]] && opt="--quiet" wget \ - --passive-ftp \ - --tries 3 \ - --continue \ - --progress bar \ + ${wget_opts} \ --directory-prefix=${PKGDIR} \ ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} if [[ $? = 0 ]] @@ -1197,12 +1387,103 @@ done # clean up backup files (foo~) - find ${MAGEDIR} -name *~ -exec rm '{}' ';' + find ${MAGEDIR} -name \*~ -exec rm '{}' ';' - # check if an newer mage version is available + # check if a newer mage version is available is_newer_mage_version_available } +syncmage_tarball() +{ + local latest_tarball + local latest_md5 + local temp="$(mktemp -d)" + local mirr mymirr + local opt + local tar_opts + local wget_opts + + # try to get the md5 marked as latest on the server + latest_md5="mage-latest.md5" + + # try to get the tarball marked as latest on the server + latest_tarball="mage-latest.tar.bz2" + + # filter wget command if busybox was found + wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" + + for mirr in ${MIRRORS} + do + # path without distribution + mymirr="${mirr%/*}" + + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo "fetching latest md5 from ${mymirr} ..." + [[ ${VERBOSE} = off ]] && opt="--quiet" + wget \ + ${wget_opts} \ + --directory-prefix=${temp} \ + ${opt} ${mymirr}/rsync/tarballs/${latest_md5} + + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo "fetching latest tarball from ${mymirr} ..." + wget \ + ${wget_opts} \ + --directory-prefix=${temp} \ + ${opt} ${mymirr}/rsync/tarballs/${latest_tarball} + if [[ $? = 0 ]] + then + break + else + continue + fi + done + + if [[ -f ${temp}/${latest_tarball} ]] + then + # check md5 + if [[ ! -f ${temp}/${latest_md5} ]] + then + die "md5 is missing ... aborting" + else + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo -n "checking md5sum... " + ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" + fi + + if [[ -d ${MAGEDIR} ]] + then + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo "cleaning old mage-tree ${MAGEDIR}..." + rm -rf ${MAGEDIR} + fi + + if need_busybox_support tar + then + tar_opts="xjf" + else + tar_opts="xjmf" + fi + + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo "updating mage-tree from tarball ..." + # unpack in dirname of MAGEDIR, as the tarball has already the mage + tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" + + if [[ -d ${temp} ]] + then + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo "cleaning temp-files ..." + rm -rf ${temp} + fi + + # check if a newer mage version is available + is_newer_mage_version_available + else + die "Could not fetch the latest tarball ... aborting" + fi +} + cleanpkg() { if [ -d "${PKGDIR}" ] @@ -1233,7 +1514,7 @@ } -# cuts full pathnames or versioniezed names down to basename +# cuts full pathnames or versionized names down to basename choppkgname() { #we want this only if full name was used @@ -1316,7 +1597,7 @@ local magefile # do not list the content of a directory, only the name (-d) - for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) + for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) do [[ -z ${magefile} ]] && continue # we exclude subdirs (for stuff like a md5sum dir) @@ -1329,28 +1610,6 @@ fi done -# do not so anything -# # stop here if HIGHEST_MAGEFILE is zero -# # this package must be unstable or old -# if [ -z "${HIGHEST_MAGEFILE}" ] -# then -# echo -# echo -n "All packages named " -# echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} -# echo -n " are marked " -# echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} -# echo "." -# echo "You need to declare USE_UNSTABLE=true to install this." -# echo -# echo "Example:" -# echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" -# echo -# echo "Be warned that these packages are not stable and may cause serious problems." -# echo "You should know what you are doing, so don't complain about any damage." -# echo -# return 1 -# fi - echo "${HIGHEST_MAGEFILE}" return 0 } @@ -1365,6 +1624,7 @@ # 1 - error # # 2 - protected # # 3 - protected but masked # +# 4 - protected but ignored # # # ################################################### is_config_protected() @@ -1373,6 +1633,8 @@ local TEST local PROTECTED local IFS + local i + local x EXPFILE="${MROOT}$1" @@ -1382,17 +1644,17 @@ # to be safe; it may be '§' IFS=' ' - # check ob in config protect + # check if config protected for i in ${CONFIG_PROTECT} do - # ersetzen von $i nur wenn am anfang der variable + # only replace $i in the beginning of the variable TEST="${EXPFILE/#${MROOT}${i}/Protected}" if [[ ${TEST} != ${EXPFILE} ]] then - # setzen das es protected ist + # file is config proteced PROTECTED=TRUE - # check ob nicht doch maskiert + # check if not masked for x in ${CONFIG_PROTECT_MASK} do TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" @@ -1401,6 +1663,16 @@ PROTECTED=MASKED fi done + + # check if not ignored + for x in ${CONFIG_PROTECT_IGNORE} + do + TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" + if [[ ${TEST} != ${EXPFILE} ]] + then + PROTECTED=IGNORED + fi + done fi done @@ -1415,6 +1687,10 @@ #echo "I'm protected, but masked - delete me" return 3 ;; + IGNORED) + #echo "I'm protected, but ignored - keep me, del update" + return 4 + ;; *) #echo "delete me" return 0 @@ -1626,7 +1902,8 @@ #deletes pakages from virtual database #$1 virtualname; $2 pkgname -virtuals_del() { +virtuals_del() +{ local virtualname="$1" local pkgname="$2" @@ -2060,6 +2337,8 @@ local SDEPEND local PROVIDE local PKGTYPE + local MAGE_TARGETS + local SPLIT_PACKAGE_BASE local preinstall local postinstall local preremove @@ -2106,6 +2385,7 @@ local count_current local magefile local src_install + local i # very basic getops for i in $* @@ -2179,12 +2459,45 @@ echo B:${pbuild} fi - if [[ -z ${MAGE_TARGETS} ]] + if [[ -n ${MAGE_TARGETS} ]] then - smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 + # basic svn compat + if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] + then + for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 + do + smage2file="${i}" + done + else + smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 + fi + + elif [[ -n ${SPLIT_PACKAGE_BASE} ]] + then + # basic svn compat + if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] + then + for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 + do + smage2file="${i}" + done + else + smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 + fi + else - smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 + # basic svn compat + if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] + then + for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 + do + smage2file="${i}" + done + else + smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 + fi fi + if [ -f "${smage2file}" ] then echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " @@ -2315,7 +2628,7 @@ then echo -ne "${COLBLUE} *** ${COLDEFAULT}" echo -ne "checking md5sum (${count_current}/${count_total}): " - ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" + ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" else echo -ne "${COLBLUE} --- ${COLDEFAULT}" echo -e "!! no md5sum file found for ${pkgfile} :(" @@ -2528,7 +2841,8 @@ unset -f postremove } -show_etc_update_mesg() { +show_etc_update_mesg() +{ [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 echo @@ -2713,7 +3027,13 @@ [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing - local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" + # support both types for the moment + if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] + then + local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" + else + local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" + fi # return 0 if the list not exist; nothin is masked [[ ! -f ${EXCLUDED} ]] && return 0 @@ -2756,3 +3076,69 @@ return 0 } +# need_busybox_support ${cmd} +# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) +need_busybox_support() +{ + local cmd + cmd="$1" + + if [[ -x /bin/busybox ]] + then + if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] + then + # needs busybox support + return 0 + fi + fi + + # no busybox + return 1 +} + +# busybox_filter_wget_options ${wget_opts} +busybox_filter_wget_options() +{ + local opts="$@" + local i + local fixed_opts + + if need_busybox_support wget + then + for i in ${opts} + do + # show only the allowed ones + case ${i} in + -c|--continue) fixed_opts+=" -c" ;; + -s|--spider) fixed_opts+=" -s" ;; + -q|--quiet) fixed_opts+=" -q" ;; + -O|--output-document) shift; fixed_opts+=" -O $1" ;; + --header) shift; fixed_opts+=" --header $1" ;; + -Y|--proxy) shift; fixed_opts+=" -Y $1" ;; + -P) shift; fixed_opts+=" -P $1" ;; + --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; + -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; + # simply drop all other opts + *) continue ;; + esac + done + + echo "${fixed_opts}" + else + echo "${opts}" + fi +} + +have_root_privileges() +{ + local retval + + if [[ $(id -u) = 0 ]] + then + retval=0 + else + retval=1 + fi + + return ${retval} +}