From 28e81cab37c3f604ea961cf1ad88e5541aaa83e5 Mon Sep 17 00:00:00 2001 From: Andrew Jeddeloh Date: Tue, 14 Nov 2017 10:26:17 -0800 Subject: [PATCH] *: add script to check for duplicate pkgs Add a script to check for packages defined in both coreos-overlay and portage-stable. --- find_overlay_dups | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 find_overlay_dups diff --git a/find_overlay_dups b/find_overlay_dups new file mode 100755 index 0000000000..c76a104201 --- /dev/null +++ b/find_overlay_dups @@ -0,0 +1,35 @@ +#!/bin/bash + +# Prints packages which are in both portage-stable and coreos-overlay + +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) +. "${SCRIPT_ROOT}/common.sh" || exit 1 + +DEFINE_string overlay_path "${SRC_ROOT}/third_party/coreos-overlay" \ + "Directory containing the overlay" +DEFINE_string portage_stable_path "${SRC_ROOT}/third_party/portage-stable" \ + "Path to portage-stable" + +# Parse flags +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" + +function get_tree_packages() { + # gets a list of all packages in a tree + find "$1" -maxdepth 3 -type f -name "*.ebuild" -printf "%P\n" | xargs dirname | sort | uniq +} + +portage_stable_packages=$(get_tree_packages ${FLAGS_portage_stable_path}) +overlay_packages=$(get_tree_packages ${FLAGS_overlay_path}) + +all_packages="$portage_stable_packages $overlay_packages" +dups=$(sort <<< "$all_packages" | uniq -D | uniq) + +if [[ -z "$dups" ]]; then + info "No duplicate packages, all good!" + exit 0 +fi + +warn "Found duplicate package(s):" +warn "$dups" +exit 1