scripts/src/check-duplicates
Maciej Barć 1e91579e95
src/check-duplicates: to make debian shellcheck happy
Signed-off-by: Maciej Barć <xgqt@protonmail.com>
2021-02-14 23:35:43 +01:00

78 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# This file is part of scripts.
# scripts is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# scripts is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with scripts. If not, see <https://www.gnu.org/licenses/>.
# Original author: Maciej Barć <xgqt@protonmail.com>
# Copyright (c) 2021, src_prepare group
# Licensed under the GNU GPL v3 License
# Fork of 'portdupe' from Gentoo science reporitory, original by omp:
# Copyright 2006 David Shakaryan <omp@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
# This one upgrades the license to GNU General Public License v3
# shellcheck disable=1117
trap 'exit 128' INT
export PATH
PORTDIR="$(portageq get_repo_path / gentoo)"
# If an argument is present, use it as the overlay directory.
if [ "${1}" ]
then
cd "${1}" || exit 1
fi
# Checking, displaying, etc.
for PACKAGE in */*
do
if [ -d "${PORTDIR}/${PACKAGE}" ] \
&& [[ $(basename "${PACKAGE}") != "CVS" ]] \
&& grep -q "$(dirname "${PACKAGE}")" "${PORTDIR}/profiles/categories"
then
# Reset versions from last package checked.
PORTPACK_VERS=""
OVERPACK_VERS=""
# Find just package name excluding category.
PACKAGE_BASE="$(basename "${PACKAGE}")"
# Find versions of package in portage.
for PORTPACK in $(find "${PORTDIR}/${PACKAGE}" -name "*.ebuild" | sed -e 's/.ebuild//')
do
PORTPACK_VER="$(basename "${PORTPACK}" | sed "s/${PACKAGE_BASE}-//")"
PORTPACK_VERS="${PORTPACK_VERS} ${PORTPACK_VER}"
done
# Find versions of package in overlay.
for OVERPACK in $(find "${PACKAGE}" -name "*.ebuild" | sed -e 's/.ebuild//')
do
OVERPACK_VER="$(basename "${OVERPACK}" | sed "s/${PACKAGE_BASE}-//")"
OVERPACK_VERS="${OVERPACK_VERS} ${OVERPACK_VER}"
done
# Output info with colors.
echo -e "\e[1;33m${PACKAGE}\e[0m"
echo -e " \e[1;35mPortage:\e[0m${PORTPACK_VERS}"
echo -e " \e[1;35mOverlay:\e[0m${OVERPACK_VERS}"
fi
done