Merge lp:~smoser/pollinate/trunk.speedups into lp:~pollinate/pollinate/trunk

Proposed by Scott Moser
Status: Merged
Merged at revision: 366
Proposed branch: lp:~smoser/pollinate/trunk.speedups
Merge into: lp:~pollinate/pollinate/trunk
Diff against target: 89 lines (+52/-9)
1 file modified
pollinate (+52/-9)
To merge this branch: bzr merge lp:~smoser/pollinate/trunk.speedups
Reviewer Review Type Date Requested Status
pollinate Pending
Review via email: mp+337394@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

This does change the order of packages, and makes their order in the string not guaranteed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'pollinate'
--- pollinate 2018-01-30 22:28:52 +0000
+++ pollinate 2018-02-08 22:29:35 +0000
@@ -17,6 +17,7 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19set -e19set -e
20set -f
2021
21PKG="pollinate"22PKG="pollinate"
22TMPDIR=$(mktemp -d -t "${PKG}.XXXXXXXXXXXX")23TMPDIR=$(mktemp -d -t "${PKG}.XXXXXXXXXXXX")
@@ -142,26 +143,68 @@
142 _RET="virt/$ret"143 _RET="virt/$ret"
143}144}
144145
146read_package_versions() {
147 local pkgs="pollinate curl cloud-init" data="" p=""
148 data=$(dpkg-query \
149 -W --showformat='${Package}/${Version} ' $pkgs 2>/dev/null) || :
150 # fill in 'package/' for any package not installed.
151 for p in ${pkgs}; do
152 [ "${data#*$p/}" = "$data" ] && data="${data} $p/"
153 done
154 if [ -n "$TESTING" ]; then
155 p="pollinate"
156 data="${data%%$p/*}$p${TESTING}/${data#*$p/}"
157 fi
158 set -- $data
159 _RET="$*"
160}
161
162read_uname_info() {
163 # taken from cloud-init ds-identify.
164 # run uname, and parse output.
165 # uname is tricky to parse as it outputs always in a given order
166 # independent of option order. kernel-version is known to have spaces.
167 # 1 -s kernel-name
168 # 2 -n nodename
169 # 3 -r kernel-release
170 # 4.. -v kernel-version(whitespace)
171 # N-2 -m machine
172 # N-1 -o operating-system
173 local out="" krel="" machine="" os=""
174 out=$(uname -snrvmo) || { _RET=""; return; }
175 set -- $out
176 krel="$3"
177 shift 3
178 while [ $# -gt 2 ]; do
179 shift
180 done
181 machine=$1
182 os=$2
183 _RET="$os/$krel/$machine"
184 return 0
185}
186
145user_agent() {187user_agent() {
146 # Construct a user agent, with useful debug information188 # Construct a user agent, with useful debug information
147 # Very similar to Firefox and Chrome189 # Very similar to Firefox and Chrome
148 local pollinate_ver="$(dpkg-query -W --showformat='${Version}' pollinate 2>/dev/null || true)"190
149 local curl_ver="$(dpkg-query -W --showformat='${Version}' curl 2>/dev/null || true)"
150 local cloud_init_ver="$(dpkg-query -W --showformat='${Version}' cloud-init 2>/dev/null)"
151 . /etc/lsb-release191 . /etc/lsb-release
152 local lsb=$(echo "${DISTRIB_DESCRIPTION}" | sed -e "s/ /\//g")192
153 local platform="$(uname -o)/$(uname -r)/$(uname -m)"193 local pkg_info="" lsb="" platform="" cpu="" up="NA" idle="NA" uptime
154 local cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")"194 read_package_versions && pkg_info="$_RET"
155 local up="NA" idle="NA"195 read_uname_info && platform="$_RET"
196
197 lsb=$(echo "${DISTRIB_DESCRIPTION}" | sed -e "s/ /\//g")
198 cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")"
156 { read up idle < /proc/uptime ; } >/dev/null 2>&1 || :199 { read up idle < /proc/uptime ; } >/dev/null 2>&1 || :
157 local uptime="uptime/$up/$idle"200 uptime="uptime/$up/$idle"
158201
159 local addl_data="" build_info="" virt=""202 local addl_data="" build_info="" virt=""
160 read_build_info && build_info="${_RET}"203 read_build_info && build_info="${_RET}"
161 read_addl_info && addl_data="${_RET}"204 read_addl_info && addl_data="${_RET}"
162 read_virt && virt="${_RET}"205 read_virt && virt="${_RET}"
163206
164 USER_AGENT="pollinate${TESTING}/${pollinate_ver} curl/${curl_ver} cloud-init/${cloud_init_ver} ${lsb} ${platform} ${cpu} ${uptime}${virt:+ ${virt}}${build_info:+ ${build_info}}${addl_data:+ ${addl_data}}"207 USER_AGENT="${pkg_info} ${lsb} ${platform} ${cpu} ${uptime}${virt:+ ${virt}}${build_info:+ ${build_info}}${addl_data:+ ${addl_data}}"
165}208}
166209
167exchange() {210exchange() {

Subscribers

People subscribed via source and target branches

to all changes: