annotate bin/check-ports @ 7:2712d249c371

Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
author Franz Glasner <hg@dom66.de>
date Sun, 22 Oct 2017 14:36:16 +0200
parents 0d9a499e89e9
children 208545b92d43
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
5
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
7 get_remote_repo_versions() {
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
8 _repo="$1"
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
9
5
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
10 _data=$(pkg version -U -R -r ${_repo} -v)
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
11 _rv=$?
5
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
12 eval remote_${_repo}_versions=\"\${_data}\"
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
13 return ${_rv}
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
14 }
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
15
5
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
16 get_local_index_versions() {
6
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
17 local_index_versions=$(pkg version -I -v)
1
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
18 }
7c9ddbea00c8 Work on the check script
Franz Glasner <hg@dom66.de>
parents: 0
diff changeset
19
7
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
20 assert_local_version() {
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
21 _name=$1
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
22 _version=$2
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
23 while read _n _v _r ; do
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
24 if [ ${_name} = ${_n} ] ; then
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
25 if [ ${_version} != ${_v} ] ; then
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
26 return 1
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
27 else
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
28 return 0
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
29 fi
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
30 fi
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
31 done <<EOF223
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
32 ${installed_data}
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
33 EOF223
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
34 return 2
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
35 }
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
36
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
37 installed_packages=$(pkg query '%n')
4
ba95569a12b1 Use standars word separators again (i.e. don't change IFS)
Franz Glasner <hg@dom66.de>
parents: 3
diff changeset
38 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
39
5
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
40 get_remote_repo_versions ${LOCAL_REPO}
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
41 get_remote_repo_versions ${FREEBSD_REPO}
53c3500894d2 Begin a new implementation algorithm
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
42 get_local_index_versions
6
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
43
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
44 while read lfqp llabel ldescr ; do
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
45 _installed_name=${lfqp%-*}
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
46 _installed_version=${lfqp##*-}
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
47 echo $lfqp ${_installed_name} ${_installed_version} ${llabel}
7
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
48 if ! assert_local_version ${_installed_name} ${_installed_version} ; then
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
49 echo "Assertion failed" >&2
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
50 exit 1
2712d249c371 Assert that the installed version number we get from "pkg query" is the same as the version in "pkg version"
Franz Glasner <hg@dom66.de>
parents: 6
diff changeset
51 fi
6
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
52 done <<EOF856661111299999
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
53 ${local_index_versions}
0d9a499e89e9 More tests with regard to the new algorithm
Franz Glasner <hg@dom66.de>
parents: 5
diff changeset
54 EOF856661111299999