From bd7adb6c4f4de944663d966bd9ecc68427fd6448 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Tue, 10 Jun 2014 18:44:47 -0700 Subject: [PATCH] feat(metadata): Add support for updating ebuild metadata cache New script update_metadata to do a global update of both repos. Add support to update_ebuilds to do incremental updates when just pulling new ebuilds into portage-stable. --- update_ebuilds | 19 +++++++++++++++++-- update_metadata | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100755 update_metadata diff --git a/update_ebuilds b/update_ebuilds index 7597134e6c..a847afde58 100755 --- a/update_ebuilds +++ b/update_ebuilds @@ -20,6 +20,8 @@ DEFINE_string rsync "rsync://rsync.gentoo.org/gentoo-portage" \ "Rsync location for gentoo-portage to use with --portage=rsync" DEFINE_boolean commit ${FLAGS_FALSE} \ "Commit all changes after updating portage-stable." +DEFINE_boolean regencache ${FLAGS_TRUE} \ + "Regenerate cache for updated ebuilds." # Parse flags @@ -36,6 +38,11 @@ if [[ -z "$*" ]]; then die "No packages provided" fi +# eclass updates impact coreos-overlay too, use update_metadata. +if [[ "$*" == *eclass* ]]; then + FLAGS_regencache=${FLAGS_FALSE} +fi + export CVSROOT="${FLAGS_cvsroot}" cd "$FLAGS_portage_stable" @@ -52,7 +59,7 @@ for pkg in "$@"; do else if [[ "$FLAGS_portage" == rsync ]]; then FLAGS_portage="${FLAGS_rsync}" - fi + fi mkdir -p "$pkg" rsync $RSYNC_OPTS -v --exclude CVS "$FLAGS_portage/$pkg/" "$pkg" fi @@ -64,7 +71,11 @@ for pkg in "$@"; do git add -A "$pkg" - # TODO(marineam): Update metadata directory? + # Sync up the ebuild metadata cache + if [[ $FLAGS_regencache -eq $FLAGS_TRUE && "$pkg" == */* ]]; then + egencache --repo=portage-stable --update "$pkg" + git add -A "metadata/md5-cache/${pkg}-*" + fi done if [[ $FLAGS_commit -eq $FLAGS_TRUE ]]; then @@ -82,3 +93,7 @@ EOF else git status fi + +if [[ "$*" == *eclass* ]]; then + info "Please run update_metadata to update cache in all overlays." +fi diff --git a/update_metadata b/update_metadata new file mode 100755 index 0000000000..f17dd9c42d --- /dev/null +++ b/update_metadata @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2014 The CoreOS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) +. "${SCRIPT_ROOT}/common.sh" || exit 1 + +DEFINE_boolean commit ${FLAGS_FALSE} \ + "Commit all changes after updating." + +# Parse flags +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" +switch_to_strict_mode + +if [[ $# -eq 0 ]]; then + eval set -- portage-stable coreos +fi + +update_overlay() { + local repo_name="$1" + local repo_path=$(portageq get_repo_path / "${repo_name}") + local job_opts=$(portageq envvar MAKEOPTS) + + info "Updating metadata in ${repo_name}..." + egencache ${job_opts} --repo="${repo_name}" --update + + pushd "${repo_path}" >/dev/null + git add -A metadata/md5-cache + if [[ ${FLAGS_commit} -eq ${FLAGS_TRUE} ]]; then + git commit -m "chore(metadata): Regenerate cache" metadata/md5-cache + else + git status metadata/md5-cache + fi + popd >/dev/null +} + +for repo in "$@"; do + if ! portageq get_repo_path / "$repo" >/dev/null; then + die_notrace "Unknown repo name '$repo'" + fi + update_overlay "$repo" +done + +command_completed