Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
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 |
| 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 | 3 : ${LOCAL_REPO:=LocalRepo} |
| 4 : ${FREEBSD_REPO:=FreeBSD} | |
| 5 : ${PORTS_DIRECT_INSTALLED_REPO:=unknown-repository} | |
| 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 | 22 do_rquery() { |
| 23 _repo="$1" | |
| 24 _packagage_name="$2" | |
| 25 | |
| 26 remote_ver=$(pkg rquery -U -r ${_repo} '%v' ${_package_name}) | |
| 27 } | |
| 28 | |
| 29 remote_data() { | |
| 30 _repo="$1" | |
| 31 shift | |
| 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 | 34 _rv=$? |
| 35 eval remote_${_repo}_data="\"\${_temp}\"" | |
| 36 return ${_rv} | |
| 37 } | |
| 38 | |
| 39 all_remote_data() { | |
| 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 | 42 _rv=$? |
| 43 eval remote_${_repo}_data="\"\${_temp}\"" | |
| 44 return ${_rv} | |
| 45 } | |
| 46 | |
| 47 query_repo() { | |
| 48 _repo="$1" | |
| 49 _package_name="$2" | |
| 50 | |
| 51 eval _repo_packages="\${remote_${_repo}_data}" | |
| 52 while read _p _v ; do | |
| 53 if [ "$_p" = "${_package_name}" ] ; then | |
| 54 repo_version="${_v}" | |
| 55 return 0 | |
| 56 fi | |
| 57 done <<EOFABCDEFG43 | |
| 58 ${_repo_packages} | |
| 59 EOFABCDEFG43 | |
| 60 repo_version="" | |
| 61 return 1 | |
| 62 } | |
| 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 | 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 | 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 | 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 | 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 | 83 else |
| 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 |
