Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/check
blob: c50ab19002338d6aeb143e28f4300e6533e76d37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/oksh

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
fi

if test ! -d "${packages_dir}"; then
	echo "no directory for uptream package descriptions.. exiting.."
	exit 1
fi

find "${state_dir}"/{core,extra}-{any,x86_64} -type f > /tmp/update_packages.$$
nof_packages=`cat /tmp/update_packages.$$ | wc -l`
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`

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"
echo "packages_repos\t${nof_checked_out_packages}" >> "${data_dir}/stats"

# find duplicate entries in state repo
> "${data_dir}/duplicates"
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
	done
done

# find dangling repos which are no longer reference from the state git repo
# (which should be dropped to the AUR)

> "${data_dir}/missing_state_file"
for pkgfile in `find "${packages_dir}" -type f -name PKGBUILD`; do
	repo_in_pkgfile=`echo $pkgfile | rev | cut -f 2-3 -d / | rev`
	pkgname_in_pkgfile=`echo $pkgfile | rev | cut -f 2 -d / | rev`
	state_file="${state_dir}/${repo_in_pkgfile}"
	if test ! -f "${state_file}"; then
		grep "^${pkgname_in_pkgfile}$" "${aur_state_dir}/packages" 2>&1 >/dev/null
		if test $? = 0; then
			state='missing'
			aur_state="<a href=\"https://aur.archlinux.org/packages/${pkgname_in_pkgfile}\">${pkgname_in_pkgfile}</a>"
		else
			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
nof_missing_state_files=`cat ${data_dir}/missing_state_file | wc -l`
echo "missing_state_files\t${nof_missing_state_files}" >> "${data_dir}/stats"

# find dangling references from the state repo not having a package repo

> "${data_dir}/missing_package_repo"
for pkg in `find "${state_dir}"/{core,extra}-{any,x86_64} -type f | \
	rev | cut -f 1,2 -d / | rev | sort`; do
	pkgfile_in_repo=`echo ${packages_dir}/${pkg}/PKGBUILD`
	if test ! -f "${pkgfile_in_repo}"; then
		echo "${pkg}\tno git repo" >> "${data_dir}/missing_package_repo"
	fi
done