annotate bin/check-ports @ 1:7c9ddbea00c8

Work on the check script
author Franz Glasner <hg@dom66.de>
date Wed, 11 Oct 2017 09:24:41 +0200
parents 08cf7bf119b7
children 86209db28490
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
1 #!/bin/sh
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
2
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
3 : ${LOCAL_REPO:=LocalRepo}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
4 : ${FREEBSD_REPO:=FreeBSD}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
5 : ${PORTS_DIRECT_INSTALLED_REPO:=unknown-repository}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
6
0
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
7 installed_packages=$(pkg query '%n')
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
8
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
9 #for p in ${installed_packages} ; do
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
10 # echo -n $p" "
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
11 # pkg query '%v' $p
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
12 # pkg rquery '%v' $p
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
13 #done
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
14
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
15 #pkg query '%n %v %R' $installed_packages |
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
16 # while read vn vv vR ; do#
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
17 # remote_ver=$(pkg rquery -r FreeBSD '%v' $vn)
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
18 # version_compare=$(pkg version --test-version ${vv} ${remote_ver})
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
19 # echo $vn $vv ${remote_ver} ${version_compare} $vR
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
20 # done
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
21
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
22 do_rquery() {
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
23 _repo="$1"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
24 _packagage_name="$2"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
25
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
26 remote_ver=$(pkg rquery -U -r ${_repo} '%v' ${_package_name})
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
27 }
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
28
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
29 remote_data() {
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
30 _repo="$1"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
31 shift
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
32
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
33 _temp=$(pkg rquery -U -r "${_repo}" '%n|%v' "$@")
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
34 _rv=$?
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
35 eval remote_${_repo}_data="\"\${_temp}\""
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
36 return ${_rv}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
37 }
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
38
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
39 all_remote_data() {
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
40 _repo="$1"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
41 _temp=$(pkg rquery -U -r "${_repo}" --all '%n|%v')
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
42 _rv=$?
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
43 eval remote_${_repo}_data="\"\${_temp}\""
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
44 return ${_rv}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
45 }
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
46
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
47 query_repo() {
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
48 _repo="$1"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
49 _package_name="$2"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
50
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
51 eval _repo_packages="\${remote_${_repo}_data}"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
52 while read _p _v ; do
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
53 if [ "$_p" = "${_package_name}" ] ; then
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
54 repo_version="${_v}"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
55 return 0
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
56 fi
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
57 done <<EOFABCDEFG43
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
58 ${_repo_packages}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
59 EOFABCDEFG43
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
60 repo_version=""
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
61 return 1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
62 }
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
63
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
64 installed_data="$(pkg query '%n|%v|%R' $installed_packages)"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
65
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
66 all_remote_data FreeBSD
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
67 all_remote_data LocalRepo
0
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
68
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
69 _OLDIFS="${IFS}"
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
70 IFS='|'
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
71
0
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
72 while read vn vv vR ; do
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
73 if [ "${vR}" = "unknown-repository" ] ; then
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
74 _local_ver_label="$(pkg version -U -I -n ${vn} | sed -E -e 's/.+[[:space:]]+//')"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
75 elif [ "${vR}" = "${LOCAL_REPO}" ] ; then
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
76 query_repo "${vR}" "${vn}"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
77 elif [ "${vR}" = "${FREEBSD_REPO}" ] ; then
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
78 query_repo "${vR}" "${vn}"
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
79 else
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
80 echo "UNKNOWN REPOSITORY \`${vR}' for packet \`${vn}'" >&2
0
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
81 fi
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
82 done <<EOFEOFEOF687
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
83 ${installed_data}
08cf7bf119b7 Current version of a tool to check the versions of installed ports against the source ports tree and other binary repositories
Franz Glasner <hg@dom66.de>
parents:
diff changeset
84 EOFEOFEOF687