Add support for the md5-cache metadata format. (Bug 422675)
authorPaul Varner <fuzzyray@gentoo.org>
Wed, 20 Jun 2012 17:11:44 +0000 (12:11 -0500)
committerPaul Varner <fuzzyray@gentoo.org>
Wed, 20 Jun 2012 17:11:44 +0000 (12:11 -0500)
The gentoo tree is moving to the md5-cache format instead of pms. This
add support for reading the md5-cache metadata format.

bin/euse

index 85ff9242321b8236c391a2257c3d930efd90994b..3b7556f5011632ecbe6f6734cc2079471f6fc2c3 100755 (executable)
--- a/bin/euse
+++ b/bin/euse
@@ -385,6 +385,7 @@ get_useflaglist() {
 #
 get_useflaglist_ebuild() {
        local known=$(echo "${ACTIVE_FLAGS[5]}" | egrep "^${1}")
+       local cacheformat
        if [[ -n $known ]]; then
                # No need to recache
                return
@@ -400,23 +401,34 @@ get_useflaglist_ebuild() {
                fi
                # Open the ebuild file and retrieve defined USE flags
                [[ ! -d "$portdir/${1}" ]] && continue
-               if [[ ! -d "$portdir/metadata/cache" ]]; then
+               cacheformat="unknown"
+               [[ -d "$portdir/metadata/cache" ]] && cacheformat="cache" # format is pms
+               [[ -d "$portdir/metadata/md5-cache" ]] && cacheformat="md5-cache" # format is md5-cache
+               if [[ "$cacheformat" == "unknown" ]]; then
                        echo "!!! Metadata cache not found. You need to run " >&2
                        echo "!!! 'egencache --repo=$overlay --update'" >&2
                        echo "!!! to generate metadata for your overlays" >&2
                        return 1
                fi
-               append=$(set +f; ls $portdir/metadata/cache/${1}-* \
+               append=$(set +f; ls ${portdir}/metadata/${cacheformat}/${1}-* \
                        | egrep "${1}-[0-9.]+" \
-                       | sed -e "s:$portdir/metadata/cache/${1}-::g" \
+                       | sed -e "s:${portdir}/metadata/${cacheformat}/${1}-::g" \
                        | while read -d $'\n' version; do
                                IFS=$'\n'
-                               if [[ ! -e "$portdir/metadata/cache/${1}-$version" ]]; then
+                               if [[ ! -e "${portdir}/metadata/${cacheformat}/${1}-$version" ]]; then
                                        # Repo does not have this particular package
                                        continue
                                fi
-                               iuse=$(head -11 "$portdir/metadata/cache/${1}-$version"|tail -1)
-                               slot=$(head -3 "$portdir/metadata/cache/${1}-$version"|tail -1)
+                               if [[ "${cacheformat}" == "cache" ]]; then
+                                       iuse=$(head -n 11 "${portdir}/metadata/${cacheformat}/${1}-$version"|tail -n 1)
+                                       slot=$(head -n 3 "${portdir}/metadata/${cacheformat}/${1}-$version"|tail -n 1)
+                               elif [[ "${cacheformat}" == "md5-cache" ]]; then
+                                       iuse=$(grep "^IUSE=" "${portdir}/metadata/${cacheformat}/${1}-$version" | sed 's/^IUSE=//')
+                                       slot=$(grep "^SLOT=" "${portdir}/metadata/${cacheformat}/${1}-$version" | sed 's/^SLOT=//')
+                               else
+                                       # This is a bug, we should have already returned
+                                       return 1
+                               fi
                                echo "${1};${version};${slot};${iuse};${overlay}"
                        done
                )