annotate bin/check-ports @ 4:ba95569a12b1 last-query-implementation

Use standars word separators again (i.e. don't change IFS)
author Franz Glasner <hg@dom66.de>
date Sat, 14 Oct 2017 22:07:58 +0200
parents 86209db28490
children 53c3500894d2
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
4
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
33 _temp=$(pkg rquery -U -r "${_repo}" '%n %v' "$@")
1
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"
4
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
41 _temp=$(pkg rquery -U -r "${_repo}" --all '%n %v')
1
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
4
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
64 installed_data="$(pkg query '%n %v %R' $installed_packages)"
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
65
3
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
66 remote_data FreeBSD ${installed_packages}
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
67 remote_data LocalRepo ${installed_packages}
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 while read vn vv vR ; do
3
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
70 if [ "${vR}" = "${PORTS_DIRECT_INSTALLED_REPO}" ] ; then
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
71 _local_ver_label="$(pkg version -U -I -n ${vn} | sed -E -e 's/.+[[:space:]]+//')"
4
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
72 echo ${_local_ver_label}
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
73 elif [ "${vR}" = "${LOCAL_REPO}" ] ; then
3
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
74 if ! query_repo "${vR}" "${vn}" ; then
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
75 echo "ERROR: ${vn} ${vR}"
4
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
76 else
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
77 echo "REPO: ${repo_version} vs. installed version ${vv}"
3
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
78 fi
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
79 elif [ "${vR}" = "${FREEBSD_REPO}" ] ; then
3
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
80 if ! query_repo "${vR}" "${vn}" ; then
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
81 echo "ERROR 2: ${vn} ${vR}"
86209db28490 Check return value of "query_repo" and query only for installed packages
Franz Glasner <hg@dom66.de>
parents: 1
diff changeset
82 fi
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
83 else
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
84 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
85 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
86 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
87 ${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
88 EOFEOFEOF687