From dcee90ac8a940932c0152861467e56743d774529 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 28 Sep 2024 09:27:19 +0200 Subject: added options and verbose to check --- bin/check | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'bin/check') diff --git a/bin/check b/bin/check index 3acb635..46e9212 100755 --- a/bin/check +++ b/bin/check @@ -3,6 +3,40 @@ BASE="${0%/*}/.." . "${BASE}/conf/default.conf" +VERBOSE=0 +OPTIONS=`getopt -n check -o hv -l help,verbose -- "$@"` +if test $? != 0; then + echo "ERROR: internal error which using getopt.." >&2; + exit 1 +fi +eval set -- "$OPTIONS" +while true; do + case "$1" in + -h|--help) + echo "check [options]" + echo "" + echo "-v --verbose be verbose" + exit 0 + ;; + + -v|--verbose) + VERBOSE=1 + shift + ;; + + --) + shift + break + ;; + + *) + echo "ERROR: Internal error in getopt" >&2 + exit 1 + esac +done + +shift `expr $OPTIND - 1` + if test ! -d "${state_dir}"; then echo "no upstream git state repo of packages.. exiting.." exit 1 @@ -19,9 +53,12 @@ nof_aur_packages=`wc -l ${aur_state_dir}/packages | cut -f 1 -d ' '` nof_checked_out_packages=`find "${packages_dir}" -type f -name PKGBUILD | wc -l` -echo "${nof_packages} packages in state repo" -echo "${nof_checked_out_packages} packages are checked out" -echo "${nof_aur_packages} packages in AUR" +if test "${VERBOSE}" = 1; then + echo "${nof_packages} packages in state repo" + echo "${nof_checked_out_packages} packages are checked out" + echo "${nof_aur_packages} packages in AUR" + sleep 10 +fi > "${data_dir}/stats" echo "packages_state\t${nof_packages}" >> "${data_dir}/stats" @@ -33,6 +70,9 @@ for duplicate in `find "${state_dir}"/{core,extra}-{any,x86_64} -type f | \ rev | cut -f 1 -d / | rev | sort | uniq -D | uniq`; do for packages in `ls ${state_dir}/{core,extra}-{any,x86_64}/$duplicate 2>/dev/null`; do for instance in `echo $packages | rev | cut -f 1,2 -d / | rev`; do + if test "${VERBOSE}" = 1; then + echo "Found duplicate state git entry for '${instance}'" + fi echo -n "${instance}\t" >> "${data_dir}/duplicates" cat "${state_dir}/$instance" | tr -s ' ' '\t' >> "${data_dir}/duplicates" done @@ -56,6 +96,9 @@ for pkgfile in `find "${packages_dir}" -type f -name PKGBUILD`; do state='missing' aur_state='missing' fi + if test "${VERBOSE}" = 1; then + echo "Missing state file for '${repo_in_pkgfile}'" + fi echo "${repo_in_pkgfile}\t${state}\t${aur_state}" >> "${data_dir}/missing_state_file" fi done -- cgit v1.2.3-70-g09d2