2020-09-16 22:38:22 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-12-29 21:12:47 +01:00
|
|
|
# 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
|
2021-03-29 13:02:30 +02:00
|
|
|
# the Free Software Foundation, version 3.
|
2020-12-29 21:12:47 +01:00
|
|
|
|
|
|
|
# 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: Marcin Woźniak (y0rune@aol.com)
|
|
|
|
# Copyright (c) 2020, src_prepare group
|
|
|
|
# Licensed under the GNU GPL v3 License
|
2020-09-16 22:38:22 +02:00
|
|
|
|
|
|
|
function scanning(){
|
|
|
|
EUSCAN=$(euscan --nocolor --quiet "$1")
|
|
|
|
if [ -n "$EUSCAN" ]; then
|
2021-06-04 10:19:26 +02:00
|
|
|
printf "%s\n" "=============== NOW: $(find ./* -mindepth 2 -maxdepth 2 -name ''"$1"'*.ebuild' | tail -1) =================
|
|
|
|
$(printf "%s\n" "$EUSCAN" | tail -1)"
|
2020-09-16 22:38:22 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function folder(){
|
|
|
|
cd "$1" || exit
|
|
|
|
|
|
|
|
PACKAGES=()
|
|
|
|
|
|
|
|
for FILE in */*
|
|
|
|
do
|
2021-06-04 10:19:26 +02:00
|
|
|
PACKAGE=$(printf "%s\n" "$FILE" | grep -Eo '[A-z0-9_-]+$')
|
2020-09-16 22:38:22 +02:00
|
|
|
PACKAGES+=("$PACKAGE")
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in "${PACKAGES[@]}"
|
|
|
|
do
|
|
|
|
scanning "$i" &
|
|
|
|
done
|
|
|
|
|
|
|
|
for j in $(jobs -p)
|
|
|
|
do
|
|
|
|
wait "$j"
|
|
|
|
done
|
|
|
|
|
2021-06-04 10:19:26 +02:00
|
|
|
printf "%s\n" ">>> Done scanning $1"
|
2020-09-16 22:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function nofolder(){
|
|
|
|
if [ -z "${1}" ]; then
|
2021-06-04 10:19:26 +02:00
|
|
|
printf "%s\n" \
|
|
|
|
"No overlay names given" \
|
|
|
|
"Please give at least one overlay name as a commandline argument" \
|
|
|
|
"Exiting" >> /dev/stderr
|
2020-09-16 22:38:22 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
for overlay in "${@}"
|
|
|
|
do
|
|
|
|
for ebuild in $(EIX_LIMIT=0 eix --only-names --in-overlay "${overlay}")
|
|
|
|
do
|
|
|
|
euscan --nocolor --quiet "${ebuild}" &
|
|
|
|
done
|
|
|
|
|
|
|
|
for j in $(jobs -p)
|
|
|
|
do
|
|
|
|
wait "$j"
|
|
|
|
done
|
|
|
|
|
2021-06-04 10:19:26 +02:00
|
|
|
printf "%s\n" ">>> Done scanning ${overlay}"
|
2020-09-16 22:38:22 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function help(){
|
2021-06-04 10:19:26 +02:00
|
|
|
printf "%s\n" \
|
|
|
|
"You can use:" \
|
|
|
|
"* -r or --repo <HERE-REPO-NAME>" \
|
|
|
|
"* -f or --folder <FOLDER-NAME>\n" \
|
|
|
|
"Example of usage" \
|
|
|
|
"./euscan-parallel -r src_prepare-overlay" \
|
|
|
|
"./euscan-parallel -f ~/git/src_prepare-overlay"
|
2020-09-16 22:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function main(){
|
2021-06-04 10:19:26 +02:00
|
|
|
[ "$(whereis eix | wc -w)" -le "1" ] && { printf "%s\n" "The eix is NOT installed" >> /dev/stderr; exit; }
|
|
|
|
[ "$(whereis euscan | wc -w)" -le "1" ] && { printf "%s\n" "The euscan is NOT installed" >> /dev/stderr; exit; }
|
2020-09-16 22:38:22 +02:00
|
|
|
case $1 in
|
|
|
|
-h|--help)
|
|
|
|
help
|
|
|
|
;;
|
|
|
|
-r|--repo)
|
|
|
|
nofolder "$2" | tee -a "euscan-$(date -I).log"
|
|
|
|
;;
|
|
|
|
-f|--folder)
|
|
|
|
folder "$2" | tee -a "euscan-$(date -I).log"
|
|
|
|
;;
|
|
|
|
*)
|
2021-06-04 10:19:26 +02:00
|
|
|
printf "%s\n" "No found variable" >> /dev/stderr; printf "\n"; help
|
2020-09-16 22:38:22 +02:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|