Merge ~chad.smith/ubuntu/+source/pollinate:ubuntu/xenial-devel into ubuntu/+source/pollinate:ubuntu/xenial-devel

Proposed by Chad Smith
Status: Merged
Merge reported by: Scott Moser
Merged at revision: 06dad938384c9154a8db5be450f81a52f66295b0
Proposed branch: ~chad.smith/ubuntu/+source/pollinate:ubuntu/xenial-devel
Merge into: ubuntu/+source/pollinate:ubuntu/xenial-devel
Diff against target: 303 lines (+219/-14)
4 files modified
ChangeLog (+84/-2)
debian/changelog (+13/-0)
pollinate (+119/-12)
pollinate.1 (+3/-0)
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Review via email: mp+347078@code.launchpad.net

Commit message

Upstream snapshot of pollinate 4.33 into xenial devel. No packaging behavior changes made.

To post a comment you must log in.
06dad93... by Chad Smith

Import version 4.33-0ubuntu1~16.04.1 to ubuntu/xenial-proposed

New changelog entries:
  * New upstream release (LP: #1761240):
    - Add '--print-user-agent' flag.
    - Speedups when collecting information for user-agent.
    - Add hypervisor to useragent string
    - Get logger version via logger -V rather than dpkg query.
    - Add cloud image build info and data in /etc/pollinate/add-user-agent
      to user-agent string.
    - Perform as safe read of /proc/uptime

Revision history for this message
Scott Moser (smoser) wrote :

I made a small change here, to the changelog, just to clean up english:
- - Perform as safe read of /proc/uptime
+ - Perform a safe read of /proc/uptime

And then uploaded.

https://code.launchpad.net/~smoser/ubuntu/+source/pollinate/+git/pollinate/+ref/bug/1761240-sru-xenial

review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

marking merged as uploaded to queue.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ChangeLog b/ChangeLog
2index b0fe4c3..40a1039 100644
3--- a/ChangeLog
4+++ b/ChangeLog
5@@ -1,4 +1,86 @@
6-pollinate (4.25) released; urgency=medium
7+pollinate (4.33) released; urgency=medium
8+
9+ * pollinate: fix bug on xen when not booted with systemd. user-agent
10+ would contain virt/virt/xen rather than virt/xen. (LP: #1774043)
11+ * pollinate: use systemd-detect-virt if available rather than detecting
12+ its availability based on /run/systemd.
13+
14+ -- Scott Moser <smoser@ubuntu.com> Fri, 25 May 2018 12:30:15 -0400
15+
16+pollinate (4.32-0ubuntu1) cosmic; urgency=medium
17+
18+ * pollinate: include img/build_name/server in user-agent.
19+
20+ -- Scott Moser <smoser@ubuntu.com> Fri, 25 May 2018 12:30:06 -0400
21+
22+pollinate (4.31-0ubuntu1) bionic; urgency=medium
23+
24+ [ Scott Moser ]
25+ * pollinate: add '--print-user-agent' flag.
26+ * pollinate: Speedups when collecting information for user-agent.
27+
28+ -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 14 Feb 2018 11:01:18 -0600
29+
30+pollinate (4.30-0ubuntu1) bionic; urgency=medium
31+
32+ * debian/pollinate.postinst:
33+ - don't try to chown a dir to the user, potentially before the user exists
34+
35+ -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 31 Jan 2018 07:24:33 -0600
36+
37+pollinate (4.29-0ubuntu1) bionic; urgency=medium
38+
39+ * No change rebuild, release error in 4.28
40+
41+ -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 30 Jan 2018 16:41:13 -0600
42+
43+pollinate (4.28-0ubuntu1) bionic; urgency=medium
44+
45+ [ Dustin Kirkland ]
46+ * pollinate:
47+ - add hypervisor to useragent string
48+ * debian/pollinate.postinst:
49+ - ensure that the pollinate user owns /var/cache/pollinate;
50+ to be safe, we're going to do this just after the mkdir, and
51+ after the adduser;
52+ this avoids the warning:
53+ + adduser: Warning: The home directory /var/cache/pollinate
54+ does not belong to the user you are currently creating.
55+
56+ [ Steve Langasek ]
57+ * Minor enhancements to pollinate runtime:
58+ - dpkg | awk is unnecessary, dpkg-query --showformat does this
59+ * dpkg -l is a fairly heavyweight operation (.1s); ask logger directly
60+ what its version number is (.01s)
61+
62+ [ Scott Moser ]
63+ * pollinate:
64+ - Add cloud image build info and data in /etc/pollinate/add-user-agent.
65+ - Use systemd-detect-virt and namespace virt/<type> in useragent
66+
67+ -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 30 Jan 2018 16:31:24 -0600
68+
69+pollinate (4.27-0ubuntu1) artful; urgency=medium
70+
71+ * Fixup maintscript & version missmatch from the previous upload.
72+
73+ -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 18 Aug 2017 13:13:16 +0100
74+
75+pollinate (4.26-0ubuntu1) artful; urgency=medium
76+
77+ [ Scott Moser ]
78+ * Perform as safe read of /proc/uptime LP: #1708461
79+
80+ [ Dimitri John Ledkov ]
81+ * Drop upstart system job
82+ * Drop no longer needed build-deps, and redundantly specified essential
83+ bsdutils
84+ * Fix spelling typo in the description
85+ * Bump debhelper compat to 9, previous levels are deprecated
86+
87+ -- Dustin Kirkland <kirkland@ubuntu.com> Sat, 14 Jan 2017 08:45:46 +0100
88+
89+pollinate (4.25-0ubuntu1) zesty; urgency=medium
90
91 [ Stefano Rivera ]
92 * debian/control: Add missing dependency on xxd. (LP: #1656484)
93@@ -6,7 +88,7 @@ pollinate (4.25) released; urgency=medium
94 [ Dustin Kirkland ]
95 * debian/control: xxd is provided by vim-common in older Ubuntu releases
96
97- -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 02 Nov 2016 14:47:01 +0200
98+ -- Dustin Kirkland <kirkland@ubuntu.com> Sat, 14 Jan 2017 08:45:44 +0100
99
100 pollinate (4.24-0ubuntu1) zesty; urgency=medium
101
102diff --git a/debian/changelog b/debian/changelog
103index 20e028d..6a9699c 100644
104--- a/debian/changelog
105+++ b/debian/changelog
106@@ -1,3 +1,16 @@
107+pollinate (4.33-0ubuntu1~16.04.1) xenial-updates; urgency=medium
108+
109+ * New upstream release (LP: #1761240):
110+ - Add '--print-user-agent' flag.
111+ - Speedups when collecting information for user-agent.
112+ - Add hypervisor to useragent string
113+ - Get logger version via logger -V rather than dpkg query.
114+ - Add cloud image build info and data in /etc/pollinate/add-user-agent
115+ to user-agent string.
116+ - Perform as safe read of /proc/uptime
117+
118+ -- Chad Smith <chad.smith@canonical.com> Wed, 30 May 2018 10:24:15 -0600
119+
120 pollinate (4.25-0ubuntu1~16.04.1) xenial; urgency=medium
121
122 * New upstream release (LP: #1708192):
123diff --git a/pollinate b/pollinate
124index a69cd9f..4a4cbbd 100755
125--- a/pollinate
126+++ b/pollinate
127@@ -17,6 +17,7 @@
128 # along with this program. If not, see <http://www.gnu.org/licenses/>.
129
130 set -e
131+set -f
132
133 PKG="pollinate"
134 TMPDIR=$(mktemp -d -t "${PKG}.XXXXXXXXXXXX")
135@@ -28,8 +29,8 @@ HOSTNAME=$(hostname)
136 STRICT=0
137
138 # Only recent logger version supports --id=[ID]
139-logger_ver=$(dpkg -l bsdutils | tail -n1 | awk '{print $3}')
140-dpkg --compare-versions $logger_ver ge 1:2.26.2 && LOGGER="logger --id=$$" || LOGGER="logger"
141+logger_ver=$(logger -V 2>&1 | awk '{print $4}')
142+dpkg --compare-versions $logger_ver ge 2.26.2 && LOGGER="logger --id=$$" || LOGGER="logger"
143 # Log to both syslog, and stderr, if we're on an interactive terminal
144 [ -t 0 ] && LOGGER="$LOGGER -s"
145
146@@ -88,20 +89,121 @@ hash_and_write() {
147 log "client hashed response from [${1}]"
148 }
149
150+read_build_info() {
151+ # ubuntu images place build information in /etc/cloud/build.info
152+ # format of file is '<key>: <value>' put these under img/<key>/<value>
153+ local bifile="${1:-/etc/cloud/build.info}" ret=""
154+ _RET=""
155+ [ -s "$bifile" ] || return 0
156+ ret=$(awk '{
157+ gsub(/#.*/, ""); gsub(/\s+$/, "");
158+ if ($0 == "" || $0 !~ /:/) next;
159+ gsub(/:\s*/, "/");
160+ printf("img/%s ", $0) }' "$bifile") || return
161+ _RET="${ret% }"
162+}
163+
164+read_addl_info() {
165+ # allow additinal info file to contain entries one per line. lines must
166+ # have a '/' in them. remove trailing space and '#' as comment. example:
167+ # key/value
168+ # fookey/foovalue # written by foo
169+ local aifile="${1:-/etc/pollinate/add-user-agent}" ret=""
170+ _RET=""
171+ [ -s "$aifile" ] || return 0
172+ ret=$(awk '{
173+ gsub(/#.*/, ""); gsub(/\s+$/, "");
174+ if ($0 == "" || $0 !~ /\//) next;
175+ printf("%s ", $0); }' "$aifile") || return
176+ _RET=${ret% }
177+}
178+
179+read_virt() {
180+ # return virt/<value> where value is the virtualization platform the
181+ # system is running on.
182+ local ret=""
183+ _RET=""
184+ if command -v systemd-detect-virt >/dev/null; then
185+ ret=$(systemd-detect-virt)
186+ # systemd-detect-virt returns 1 for 'none'
187+ [ $? -eq 0 -o "$ret" = "none" ] || ret=""
188+ else
189+ # trusty would take this path.
190+ if [ -d /dev/xen ]; then
191+ ret="xen"
192+ elif [ -d /dev/lxd ]; then
193+ # call this 'lxc' for consistency with systemd-detect-virt.
194+ ret="lxc"
195+ elif dmesg | grep --quiet " kvm-clock:"; then
196+ ret="kvm"
197+ fi
198+ fi
199+ [ -n "$ret" ] || return
200+ _RET="virt/$ret"
201+}
202+
203+read_package_versions() {
204+ local pkgs="pollinate curl cloud-init" data="" p=""
205+ data=$(dpkg-query \
206+ -W --showformat='${Package}/${Version} ' $pkgs 2>/dev/null) || :
207+ # fill in 'package/' for any package not installed.
208+ for p in ${pkgs}; do
209+ [ "${data#*$p/}" = "$data" ] && data="${data} $p/"
210+ done
211+ if [ -n "$TESTING" ]; then
212+ p="pollinate"
213+ data="${data%%$p/*}$p${TESTING}/${data#*$p/}"
214+ fi
215+ set -- $data
216+ _RET="$*"
217+}
218+
219+read_uname_info() {
220+ # taken from cloud-init ds-identify.
221+ # run uname, and parse output.
222+ # uname is tricky to parse as it outputs always in a given order
223+ # independent of option order. kernel-version is known to have spaces.
224+ # 1 -s kernel-name
225+ # 2 -n nodename
226+ # 3 -r kernel-release
227+ # 4.. -v kernel-version(whitespace)
228+ # N-2 -m machine
229+ # N-1 -o operating-system
230+ local out="" krel="" machine="" os=""
231+ out=$(uname -snrvmo) || { _RET=""; return; }
232+ set -- $out
233+ krel="$3"
234+ shift 3
235+ while [ $# -gt 2 ]; do
236+ shift
237+ done
238+ machine=$1
239+ os=$2
240+ _RET="$os/$krel/$machine"
241+ return 0
242+}
243+
244 user_agent() {
245 # Construct a user agent, with useful debug information
246 # Very similar to Firefox and Chrome
247- local pollinate_ver="$(dpkg -l pollinate | awk '$1 == "ii" { print($3); exit(0); }')"
248- local curl_ver="$(dpkg -l curl | awk '$1 == "ii" { print($3); exit(0); }')"
249- local cloud_init_ver="$(dpkg -l cloud-init 2>/dev/null | awk '$1 == "ii" { print($3); exit(0); }')"
250+
251 . /etc/lsb-release
252- local lsb=$(echo "${DISTRIB_DESCRIPTION}" | sed -e "s/ /\//g")
253- local platform="$(uname -o)/$(uname -r)/$(uname -m)"
254- local cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")"
255- local up idle
256- read up idle < /proc/uptime
257- local uptime="uptime/$up/$idle"
258- USER_AGENT="pollinate${TESTING}/${pollinate_ver} curl/${curl_ver} cloud-init/${cloud_init_ver} ${lsb} ${platform} ${cpu} ${uptime}"
259+
260+ local pkg_info="" lsb="" platform="" cpu="" up="NA" idle="NA" uptime
261+ read_package_versions && pkg_info="$_RET"
262+ read_uname_info && platform="$_RET"
263+
264+ lsb=$(echo "${DISTRIB_DESCRIPTION}" | sed -e "s/ /\//g")
265+ cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")"
266+ { read up idle < /proc/uptime ; } >/dev/null 2>&1 || :
267+ uptime="uptime/$up/$idle"
268+
269+ local addl_data="" build_info="" virt=""
270+ read_build_info && build_info="${_RET}"
271+ read_addl_info && addl_data="${_RET}"
272+ read_virt && virt="${_RET}"
273+
274+ USER_AGENT="${pkg_info} ${lsb} ${platform} ${cpu} ${uptime}${virt:+ ${virt}}${build_info:+ ${build_info}}${addl_data:+ ${addl_data}}"
275 }
276
277 exchange() {
278@@ -203,6 +305,11 @@ while [ ! -z "$1" ]; do
279 WAIT="$2"
280 shift 2
281 ;;
282+ --print-user-agent)
283+ user_agent || error "Failed to get user-agent."
284+ echo "${USER_AGENT}"
285+ exit
286+ ;;
287 *)
288 error "Unknown options [$1]"
289 ;;
290diff --git a/pollinate.1 b/pollinate.1
291index f7890ee..8e2b9ce 100644
292--- a/pollinate.1
293+++ b/pollinate.1
294@@ -45,6 +45,9 @@ silence any log messages
295 .TP
296 \fB-w|--wait\fP WAIT
297 time in seconds you're willing to wait for a response from the server, uses \fBtimeout\fP(1)
298+.TP
299+\fB --print-user-agent\fP
300+Print the user-agent that is used and exit immediately.
301
302 .SH SEE ALSO
303 \fBpollen\fP(8), \fBtimeout\fP(1)

Subscribers

People subscribed via source and target branches