#!/usr/bin/env bash # Copyright 2006-2014 Gentoo Foundation; Distributed under the GPL v2 # -- 2014-08-04 # do numeric comparison on calculated rev-diff, as [[ 0 < -9 ]] is true # -- 2010-10-16 # treat ChangeLogs special, such that newer repoman that update the # ChangeLog can just do so -- we try to 'prepend only' avoiding # conflicts # -- 2010-01-14 # allow eclasses to be found in MTREEDIR if not in PTREEDIR # -- 2009-08-11 # allow to use web-based viewcvs instead of anonymous CVS access # -- 2008-06-17 # switch to fully sourcing ebuilds (and their eclasses) in fetch_files # such that we catch more cases in which patches can be referenced # -- 2007-11-27 # ignore live CVS ebuilds (version 9999) # -- 2007-11-11 # add some dummy implementations of often used functions to silence bash # some more # -- 2007-11-09 # also take notion of local variables for expansion in fetch_files # -- 2007-10-08 # added support for _p in versions after _rc, _pre, etc. # sourcing the versionator eclass when being used now for better # expansion of variables in fetch_files # -- 2007-09-24 # added support for all P* variables in fetch_files expansion, avoided # getting bash errors due to unterminated quotes # -- 2007-09-12 # performance improvements by avoiding comparing ebuilds to non-ebuilds # when looking for updates, and by avoiding fork/execs for cut and echo # in the version comparator function # -- 2007-03-20 # also update alpha, beta, pre, p, etc. instead of only revisions. # Basically everything which is on top of the 'base' version number # should be upgraded always. # -- 2007-02-08 # when adding a new version, also try and copy all extra files from # FILESDIR. Also when invoked from an empty directory properly deal # with "missing" files, so new files are copied. # -- 2006-12-24 # support for inter-revisions (-r01.1), which are also ignored when # comparing to the main tree # -- 2006-11-03 # let eapify figure out what should be done to a file. This requires # the extension of the file to be retained in the temp location, but # afterwards it works nicely for eclasses and ebuilds, as well as # ChangeLogs. # -- 2006-09-22 # eupdate: a not yet fully complete bucket of voodoo to sync a the # prefix tree with the mainline tree. Strategies followed are largerly # based on cvs revision numbers and diffs between those revisions. For # the real internals, please look at the comments below in the code. In # general, this script checks if an ebuild contains the most recent # changes to it, and if there is a newer ebuild available. In both # cases (cross) diffing techniques are used to maintain the manually # made changes. # # This script doesn't run out of the box, you have to feed it some paths # so it can do it's magic stuff. Also, you have to be a gentoo # developer with cvs access. (Or when anoncvs is available, every user # can do it.) For your convenience it is intended that you rename this # file to something without the .in and change the paths below. # Main Tree Directory, an rsynced portage tree is fine [[ -z $MTREEDIR ]] && MTREEDIR='/path/to/rsync-gentoo-x86' # Prefix offset [[ -z $EPREFIX ]] && EPREFIX=$(portageq envvar EPREFIX) # Prefix Tree Directory [[ -z $PTREEDIR ]] && PTREEDIR="`cd ${EPREFIX}/usr/portage && pwd -P`" # How to reach the CVS server for retrieving revision diffs, devs can # use their ssh access for the most up-to-date tree. You can use the # anonymous CVS (:pserver:anonymous@anoncvs.gentoo.org:/var/cvsroot) or # HTTP-based webcvs (http://sources.gentoo.org/viewcvs.py). We default # to the first since it should be less stressful for the server. [[ -z $CVSROOT ]] && CVSROOT=':pserver:anonymous@anoncvs.gentoo.org:/var/cvsroot' # Don't touch this. You really don't want to. CVSMODULE='gentoo-x86' # Voodoo to figure out what package you're currently messing with EPACKAGE="`pwd -P`"; EPACKAGE=${EPACKAGE#*${PTREEDIR}/} [[ -e "${EPREFIX}"/etc/init.d/functions.sh ]] \ && source "${EPREFIX}"/etc/init.d/functions.sh \ || echo "!!! cannot find functions.sh !!!" [[ -z $DO_INDENT ]] || RC_INDENTATION=$DO_INDENT # file used for subshell communication (in /tmp, so swap on Solaris) gf=/tmp/eupdate.subshell.$$ # returns the CVS revision number from the $Header get_cvsversion() { if [[ -z $1 ]] ; then echo 0 return fi ver=`egrep '(^|[^\\])\\\$(Header|Id):' "$1" | egrep -m1 -o "v [0-9.]+" | head -n1` if [[ $ver == "" ]] ; then echo 0 return fi echo ${ver#v } } # Comparator for ebuild version strings. Returns 0 if both arguments # are equal, a number less then 0 if the first argument is smaller than # the second, and a number greater then 0 otherwise. Arguments may be # up to full paths to the bare version string only. # It is possible to deduce what the largest difference between the two # given versions is, by considering the following on the absolute return # value: 10000 < x < 0 -> main version, where 1 is a difference in # the major, 10 a difference in the minor, etc. 100000 < x < 10000 -> # suffix, 1000000 < x < 100000 -> revision. cmp_ebuild_ver() { # get the bare version, if not already local l=$(get_ebuildversion $1) local r=$(get_ebuildversion $2) if [[ -z $l ]] && [[ -z $r ]]; then echo 0 return elif [[ ! -z $l ]] && [[ -z $r ]] ; then echo 1 return fi local lver=${l%%-*} local lrev=${l#${lver}} ; lrev=${lrev#-} local t=$lver lver=${lver%%_*} local lsuf=${t#${lver}} ; lsuf=${lsuf#_} local rver=${r%%-*} local rrev=${r#${rver}} ; rrev=${rrev#-} t=$rver rver=${rver%%_*} local rsuf=${t#${rver}} ; rsuf=${rsuf#_} local cnt=1 # start "eating" the version from the left, comparing the numbers, # following an exit-early approach while [[ $lver != "" ]] || [[ $rver != "" ]] ; do # get the "head" component local la=${lver%%.*} local ra=${rver%%.*} # unfortunately also characters next to numbers can appear in # the version number, 4a is considered to be smaller than 33 local lan=${la%%[a-zA-Z]*} local ran=${ra%%[a-zA-Z]*} # deal with 1.0301 < 1.30 while [[ ${lan} == 0* && ${ran} == 0* ]] ; do lan=${lan#0} ran=${ran#0} done if [[ ${lan} == 0* ]] ; then [[ -z ${ran} ]] && echo ${cnt} || echo -${cnt} return elif [[ ${ran} == 0* ]] ; then [[ -z ${lan} ]] && echo -${cnt} || echo ${cnt} return fi t=$((lan - ran)) if (( ${t} != 0 )) ; then (( $t > 9 )) && t=9 (( $t < -9 )) && t=-9 echo $((t * cnt)) return else # perform string equality... should work if [[ ${la} < ${ra} ]] ; then echo $((-1 * cnt)) return elif [[ ${la} > ${ra} ]] ; then echo $cnt return fi fi # remove the part we processed (and was equal) lver=${lver#${la}} rver=${rver#${ra}} # strip leading dot (if any) lver=${lver#.} rver=${rver#.} (( $cnt < 1000 )) && cnt=$((cnt * 10)) done # the main version components are equal, dive into the suffices # we need to treat _p special, as it can occur with the other suffices # suffix precedence rules: # alpha # beta # pre # rc # (none) # p cnt=10000 local lan=0 case $lsuf in alpha*) lan=-1 lsuf=${lsuf#alpha} ;; beta*) lan=-2 lsuf=${lsuf#beta} ;; pre*) lan=-3 lsuf=${lsuf#pre} ;; rc*) lan=-4 lsuf=${lsuf#rc} ;; p*) lan=-6 lsuf=${lsuf#p} ;; *) lan=-5 ;; esac local ran=0 case $rsuf in alpha*) ran=-1 rsuf=${rsuf#alpha} ;; beta*) ran=-2 rsuf=${rsuf#beta} ;; pre*) ran=-3 rsuf=${rsuf#pre} ;; rc*) ran=-4 rsuf=${rsuf#rc} ;; p*) ran=-6 rsuf=${rsuf#p} ;; *) ran=-5 ;; esac t=$((lan - ran)) if (( ${t} != 0 )) ; then echo $((-t * cnt)) return fi # if lsuf or rsuf starts with a 0, bash thinks it's an octal number if [[ ${lsuf} == 0* || ${rsuf} == 0* ]] ; then lsuf="1${lsuf}" rsuf="1${rsuf}" fi lsuf=${lsuf:-0} rsuf=${rsuf:-0} t=$((${lsuf%_p*} - ${rsuf%_p*})) if (( ${t} != 0 )) ; then (( $t > 9 )) && t=9 (( $t < -9 )) && t=-9 echo $((t * cnt)) return fi # we may have a _p in the suffices now, need to compare those case ${lsuf}:${rsuf} in *_p*:*_p*) t=$((${lsuf#*_p} - ${rsuf#*_p})) if (( ${t} != 0 )) ; then (( $t > 9 )) && t=9 (( $t < -9 )) && t=-9 echo $((t * cnt)) return fi ;; *_p*:*) echo $cnt return ;; *:*_p*) echo -$cnt return ;; esac # suffices were equal too, now lets see the revision cnt=100000 lrev=${lrev#r} rrev=${rrev#r} lsrev=0 rsrev=0 if [[ ${lrev:0:1} == "0" ]] ; then lsrev=${lrev/*./} lrev=${lrev:1} lrev=${lrev/.*/} fi if [[ ${rrev:0:1} == "0" ]] ; then rsrev=${rrev/*./} rrev=${rrev:1} rrev=${rrev/.*/} fi t=$((lrev - rrev)) (( $t == 0 )) && t=$((lsrev - rsrev)) (( $t > 9 )) && t=9 (( $t < -9 )) && t=-9 echo $((t * cnt)) } get_ebuildversion() { if [[ -z $1 ]] ; then return fi # strip extension t=${1%.ebuild} # abort if this is not an ebuild if [[ $t == $1 ]] ; then return fi # strip package name t=${t#*-} # sometimes there are dashes in the package name while [[ ${t:0:1} < "0" || ${t:0:1} > "9" ]] ; do [[ $t != ${t#*-} ]] \ && t=${t#*-} \ || break done echo ${t} } cross_diff() { mver=$(get_ebuildversion $1) pver=$(get_ebuildversion $2) # $1 is just somewhere, $2 must be local, mte becomes local $1 mte=${1##*/} pte=$2 # get real main tree corresponding version if [[ ${pte/-r0/-r} == $pte ]] ; then mypte=$pte else # normalise version, so we compare against the original # version from the main tree mypte=${pte%.*.ebuild}.ebuild mypte=${mypte/-r0/-r} mypte=${mypte/-r.ebuild/.ebuild} mypte=${mypte/-r0.ebuild/.ebuild} fi mtecv=$(get_cvsversion $1) ptecv=$(get_cvsversion $2) ewarn "new version in main tree: ${mver} [${pver}] ... cross diff from $ptecv to $mtecv" # checkout both original versions and make the diffs, # ignoring keywords tmp="tmp.${package##*.}" if [[ ${CVSROOT} == "http://"* ]] ; then wget -q -O /var/tmp/$mypte-$ptecv.$tmp \ "${CVSROOT}/${CVSMODULE}/${EPACKAGE}/$mypte?rev=$ptecv" wget -q -O /var/tmp/$mte-$mtecv.$tmp \ "${CVSROOT}/${CVSMODULE}/${EPACKAGE}/$mte?rev=$mtecv" else cvs -Q -d"${CVSROOT}" \ checkout -r$ptecv -p ${CVSMODULE}/${EPACKAGE}/$mypte \ > /var/tmp/$mypte-$ptecv.$tmp cvs -Q -d"${CVSROOT}" \ checkout -r$mtecv -p ${CVSMODULE}/${EPACKAGE}/$mte \ > /var/tmp/$mte-$mtecv.$tmp fi # create the new file to patch against cp $pte $mte # Sanitise the $Header line, because it may differ being in the # Attic or something. Use version of main tree, to keep updates # working. sed -i \ -e 's|^# \$Header:.*$|'"`egrep '^# \\\$Header: ' /var/tmp/$mte-$mtecv.$tmp`"'|' \ $mte /var/tmp/$mypte-$ptecv.$tmp # make KEYWORDS void in the diff sed -i \ -e 's|^KEYWORDS=.*$|'"$(egrep '^KEYWORDS=' $pte | head -n1)"'|' \ /var/tmp/$mypte-$ptecv.$tmp /var/tmp/$mte-$mtecv.$tmp # destroy changes (hopefully) with the prefixed version by eapifying eapify -e /var/tmp/$mypte-$ptecv.$tmp /var/tmp/$mte-$mtecv.$tmp > /dev/null # (attempt to) do it! diff -u /var/tmp/$mypte-$ptecv.$tmp /var/tmp/$mte-$mtecv.$tmp \ | patch --no-backup-if-mismatch $mte ret=$? rm /var/tmp/$mypte-$ptecv.$tmp /var/tmp/$mte-$mtecv.$tmp # try to get new patches and stuff fetch_files $mte return $ret } revision_diff() { local mtecv=$1 local ptecv=$2 local package=$3 local pfile=$4 # Gentoo never increments the major, and branches are not # allowed, so we can make things easy and only use the minor if [[ ${mtecv#1.} -eq ${ptecv#1.} ]] ; then return elif [[ ${mtecv#1.} -gt ${ptecv#1.} ]] ; then echo "out-of-date, applying diff -r$ptecv -r$mtecv" # checkout both original versions and make the diffs, # ignoring keywords local tmp="tmp.${package##*.}" if [[ ${CVSROOT} == "http://"* ]] ; then wget -q -O /var/tmp/$package-$ptecv.$tmp \ "${CVSROOT}/${CVSMODULE}/${EPACKAGE}/$package?rev=$ptecv" wget -q -O /var/tmp/$package-$mtecv.$tmp \ "${CVSROOT}/${CVSMODULE}/${EPACKAGE}/$package?rev=$mtecv" else cvs -Q -d"${CVSROOT}" \ checkout -r$ptecv -p ${CVSMODULE}/${EPACKAGE}/$package \ > /var/tmp/$package-$ptecv.$tmp cvs -Q -d"${CVSROOT}" \ checkout -r$mtecv -p ${CVSMODULE}/${EPACKAGE}/$package \ > /var/tmp/$package-$mtecv.$tmp fi # make KEYWORDS void in the diff [[ ${package##*.} == "ebuild" ]] && sed -i \ -e 's|^KEYWORDS=.*$|'"$(egrep '^KEYWORDS=' $pfile | head -n1)"'|' \ /var/tmp/$package-$mtecv.$tmp /var/tmp/$package-$ptecv.$tmp if [[ ${package} != "ChangeLog" ]] ; then # destroy changes (hopefully) with the prefixed version by eapifying eapify /var/tmp/$package-$ptecv.$tmp /var/tmp/$package-$mtecv.$tmp > /dev/null # if the file was checked out by ecopy from the web, correct the # header so we don't get conflicts because of that sed -i -e '/^# $Header:/s:/var/www/viewcvs.gentoo.org/raw_cvs:/var/cvsroot:' \ $pfile # show what's going to change diff -U 1 /var/tmp/$package-$ptecv.$tmp /var/tmp/$package-$mtecv.$tmp local chng=$? # (attempt to) do it! diff -u /var/tmp/$package-$ptecv.$tmp /var/tmp/$package-$mtecv.$tmp \ | patch --no-backup-if-mismatch $pfile local ret=$? # try to get new patches and stuff fetch_files $pfile else # treat ChangeLogs different, so we can have appends both in # gx86 and Prefix (repoman insists) # first zap the headers, so we don't get any changes there sed -i \ -e '1c\# ChangeLog for '"${EPACKAGE}" \ -e '2c\# Copyright 1999-'"$(date +%Y)"' Gentoo Foundation; Distributed under the GPL v2' \ /var/tmp/$package-$mtecv.$tmp { echo "@@ -1,3 +1,3 @@" head -n3 /var/tmp/$package-$ptecv.$tmp | sed -e 's/^/-/' head -n3 $pfile | sed -e 's/^/+/' } | patch -r - --no-backup-if-mismatch /var/tmp/$package-$ptecv.$tmp # then just take the first hunk, nothing more diff -U 1 /var/tmp/$package-$ptecv.$tmp /var/tmp/$package-$mtecv.$tmp | sed -e '4,$s/^@@ .*$/REMOVEMEXXXXXX/' | sed -e '/REMOVEMEXXXXXX/,$d' local chng=$? diff -U 0 /var/tmp/$package-$ptecv.$tmp /var/tmp/$package-$mtecv.$tmp | \ sed -e '4,$s/^@@ .*$/REMOVEMEXXXXXX/' | \ sed -e '/REMOVEMEXXXXXX/,$d' | \ patch --no-backup-if-mismatch $pfile local ret=$? fi [[ $ret == 0 ]] && ret=$chng rm /var/tmp/$package-$ptecv.$tmp /var/tmp/$package-$mtecv.$tmp return $ret fi } fetch_files() { local mver=$(get_ebuildversion $1) local pn=${EPACKAGE##*/} local pv=${mver%-r*} local pr=${mver#${pv}} ; pr=${pr#-} ; pr=${pr:-r0} local pf=${pn}-${mver} local p=$pn-$pv local t="" # ebuild.sh and friends provided often occurring funcs local funcs=' EXPORT_FUNCTIONS() { :; } has() { :; } hasq() { :; } use() { :; } use_enable() { :; } use_with() { :; } addwrite() { :; } addpredict() { :; } debug-print-function() { :; } debug-print() { :; } inherit() { for p in $*; do if [[ -f '"${PTREEDIR}"'/eclass/${p}.eclass ]]; then source '"${PTREEDIR}"'/eclass/${p}.eclass else source '"${MTREEDIR}"'/eclass/${p}.eclass fi done } :' # Find all "referenced" files from/to FILESDIR. We keep ${FILESDIR} # in, to just use a bash eval on what we found to get the right # path. eindent sed \ -e '/FILESDIR/!d' \ -e 's/^.*[^"]\("\?\${FILESDIR}\)/\1/' \ -e 's/#.*$//' \ -e 's/\\$//' \ $1 | \ while read l ; do t=$(eval a='$l'; for i in $a ; do echo $i ; break ; done) t=$(env -i P=$p PN=$pn PV=$pv PR=$pr PVR=$mver PF=$pf FILESDIR=files $(type -P bash) -c "${funcs}; source $1; echo $t") # we can have file{1,2} stuff in the first t here, so iterate # over the result list... for u in $t ; do if [[ ! -e $u ]] ; then ewarn "copying $u" [[ ! -d $(dirname $u) ]] && mkdir -p $(dirname $u) cp -R "${MTREEDIR}/${EPACKAGE}"/$u $u fi done done eoutdent } diff_patch() { ( diff -u $2 "${MTREEDIR}/${EPACKAGE}"/$1 ; echo $? > $gf ) | patch $2 local ret=$? [[ ${ret} == 0 ]] && ret=$(< $gf) rm $gf # try to get new patches and stuff fetch_files $2 return $ret } update_file() { # on directories, recurse if [[ -d $1 ]] ; then eindent # recurse into this directory (don't update digests) f=$(ls -p $1 | egrep -v "^digest-") [[ ! -z $f ]] && ( cd $1 && DO_INDENT=$RC_INDENTATION eupdate $f ; ret=$? ) eoutdent return $ret fi # check existence of files if [[ ! -f $2 ]] ; then echo "no such file: $2" return -1 fi if [[ ! -f "${MTREEDIR}/${EPACKAGE}"/$1 ]] ; then echo "$1 not found in the main tree" return 0 fi # see if the file has a CVS header local mtecv=$(get_cvsversion "${MTREEDIR}/${EPACKAGE}"/$1) local ptecv=$(get_cvsversion $2) if [[ $mtecv == 0 ]] && [[ $ptecv == 0 ]] ; then diff_patch $1 $2 return $? else revision_diff $mtecv $ptecv $1 $2 return $? fi } do_check_file() { local mfile=$1 local pfile=$2 local msg="" if [[ -z $3 ]] ; then [[ $pfile != $mfile ]] \ && msg="checking $mfile/$pfile" \ || msg="checking $mfile" else msg=$3 fi if [[ -d $mfile ]] ; then einfo "$msg (a directory)" update_file $pfile return $? fi ebegin $msg local err=$(update_file $mfile $pfile ; echo $? > $gf) local ret=$(< $gf) rm $gf [[ $ret < 0 ]] && eend -1 || eend 0 if [[ ! -z $err ]] ; then if [[ $mfile != $pfile ]] ; then [[ $ret < 0 ]] \ && eerror "$mfile/$pfile: $err" \ || ewarn "$mfile/$pfile: $err" else [[ $ret < 0 ]] \ && eerror "$mfile: $err" \ || ewarn "$mfile: $err" fi fi return $ret } # if the user gave some files on the command line, try to update those if [[ ${#*} > 0 ]] ; then while [[ ${#*} > 0 ]] ; do if [[ ${1/->/} != ${1} ]] ; then # if a a.1.ebuild->a.2.ebuild is given, we force a # cross-diff from a.1 to a.2 cross_diff ${MTREEDIR}/${EPACKAGE}/${1#*->} ${1%->*} elif [[ ${1#=} != ${1} ]] ; then # try to fetch files for this ebuild fetch_files ${1#=} elif [[ -f $1 ]] ; then # $1 just exists, just update do_check_file $1 $1 elif [[ ! -f ${MTREEDIR}/${EPACKAGE}/$1 ]] ; then # kind of lazy way of saying "file not found" do_check_file $1 $1 else # move over the file ewarn "copying $1" cp "${MTREEDIR}/${EPACKAGE}"/$1 . eapify $1 ecleankw $1 fetch_files $1 fi shift done # we're done exit 0 fi if [[ ! -d ${MTREEDIR}/${EPACKAGE} ]] ; then eerror "no such package in main tree: ${EPACKAGE}" exit 2 fi if [[ ${EPACKAGE} == "eclass" || ${EPACKAGE} == "licenses" || ${EPACKAGE} == "updates" || ${EPACKAGE} == "desc" ]] ; then einfo "Processing ${EPACKAGE} directory" excode=0 mt=`cd "${MTREEDIR}"/${EPACKAGE}/ && ls -p` pt=`ls -p` # nested loop join for pte in $pt ; do had_match=0 for mte in $mt ; do if [[ $pte == $mte ]] ; then do_check_file $mte $pte ret=$? if [[ $ret < 0 ]] || [[ $ret > 1 ]] ; then excode=-1 elif [[ $excode == 0 ]] ; then excode=$ret fi had_match=1; # we don't need $pte/$mte any more pt=${pt/$pte/} mt=${mt/$mte/} break; fi done [[ $had_match == 0 ]] \ && ewarn "warning: $pte no longer in the main tree" done # everything left in $mt now is what's not in $pt, let's make a # note about them and perform a copy for mte in $mt ; do ewarn "adding from main tree: $mte" cp "${MTREEDIR}"/${EPACKAGE}/$mte . done exit $excode fi einfo "Processing ${EPACKAGE}" excode=0 mt=`cd "${MTREEDIR}"/${EPACKAGE}/ && ls -p | egrep -v "^Manifest$"` pt=`ls -p | egrep -v "^Manifest$"` # do a nested loop join, we don't assume any order for pte in $pt ; do had_match=0 mypte=$pte for mte in $mt ; do # calculate the diffs between prefix and main if [[ ${pte} == *-r0* ]] ; then # normalise version, so we compare against the original # version from the main tree mypte=${pte%.*.ebuild}.ebuild mypte=${mypte/-r0/-r} mypte=${mypte/-r.ebuild/.ebuild} mypte=${mypte/-r0.ebuild/.ebuild} fi vdiff=$(cmp_ebuild_ver $mte $mypte) # if we have the same ebuild version... (or file) if [[ $vdiff == 0 ]] && [[ $mte == $mypte ]] ; then had_match=1 # ... look inside the files to see if the file was updated or not do_check_file $mte $pte ret=$? if [[ $ret < 0 ]] || [[ $ret > 1 ]] ; then excode=-1 elif [[ $excode == 0 ]] ; then excode=$ret fi # we found this version, so needless to look for it any more mt=${mt/$mte/} fi done # stale entry [[ $had_match == 0 ]] \ && ewarn "warning: $pte (${mypte}) no longer in the main tree" done # what's left in $mt is everything which is not in $pt # find the latest revisions/alpha/beta/pre and see if there is a more # recent revision in the main tree last_pte="" for pte in $pt ; do # skip over non-ebuilds if [[ ${pte} != *.ebuild ]] ; then pt=${pt/${pte}/} continue fi for xpte in $pt ; do # check against the rest [[ $(cmp_ebuild_ver $pte $xpte) -ge 10000 ]] \ && pt=${pt/$xpte/} done [[ $(cmp_ebuild_ver $pte $last_pte) > 0 ]] \ && last_pte=$pte done # for all ebuilds (the latest revisions/alpha/beta/pre) we check if # there is a more recent revision in the main tree for pte in $pt ; do last_rev="" for mte in $mt ; do # kill live CVS ebuilds v=$(get_ebuildversion ${mte}) if [[ ${v} == 9999 || ${v} == 99999999 ]] ; then mt=${mt/$mte/} continue fi if [[ $(cmp_ebuild_ver $mte $pte) -ge 10000 ]] ; then [[ $(cmp_ebuild_ver $mte $last_rev) > 0 ]] \ && last_rev=$mte # we will deal with the (newer) revision later, so let's # avoid the final update check below finding this revision mt=${mt/$mte/} fi done if [[ $last_rev != "" ]] ; then cross_diff ${MTREEDIR}/${EPACKAGE}/$last_rev $pte ret=$? if [[ $ret < 0 ]] || [[ $ret > 1 ]] ; then excode=-1 elif [[ $excode -ge 0 ]] ; then excode=1 # not 0, as we changed something (added a file) fi fi done # if there is anything left in mt that is bigger than last_pte we want # the biggest of that last_mte="" for mte in $mt ; do # skip over non-ebuilds [[ ${mte} != *.ebuild ]] && continue [[ $(cmp_ebuild_ver $mte $last_pte) > 0 ]] && \ [[ $(cmp_ebuild_ver $mte $last_mte) > 0 ]] \ && last_mte=$mte done if [[ $last_mte != "" ]] ; then if [[ $last_pte != "" ]] ; then # we have to apply an update from $last_pte to $last_mte cross_diff ${MTREEDIR}/${EPACKAGE}/$last_mte $last_pte ret=$? if [[ $ret < 0 ]] || [[ $ret > 1 ]] ; then excode=-1 elif [[ $excode -ge 0 ]] ; then excode=1 # not 0, as we changed something (added a file) fi else # this is from an empty directory, get the last one and relevant # files if [[ -f ${MTREEDIR}/${EPACKAGE}/metadata.xml ]] ; then ewarn "copying metadata.xml" cp "${MTREEDIR}/${EPACKAGE}"/metadata.xml . fi if [[ -f ${MTREEDIR}/${EPACKAGE}/ChangeLog ]] ; then ewarn "copying ChangeLog" cp "${MTREEDIR}/${EPACKAGE}"/ChangeLog . fi if [[ -f ${MTREEDIR}/${EPACKAGE}/Manifest ]] ; then ewarn "copying Manifest" cp "${MTREEDIR}/${EPACKAGE}"/Manifest . fi ewarn "copying $last_mte" cp "${MTREEDIR}/${EPACKAGE}"/$last_mte . eapify $last_mte ecleankw $last_mte fetch_files $last_mte fi fi exit $excode