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

Proposed by Chad Smith
Status: Merged
Merge reported by: Scott Moser
Merged at revision: dd579e69f849ae998f1f93d40584ee422a5aae99
Proposed branch: ~chad.smith/ubuntu/+source/pollinate:ubuntu/artful-devel
Merge into: ubuntu/+source/pollinate:ubuntu/artful-devel
Diff against target: 272 lines (+196/-12)
4 files modified
ChangeLog (+63/-1)
debian/changelog (+12/-0)
pollinate (+118/-11)
pollinate.1 (+3/-0)
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Review via email: mp+347074@code.launchpad.net

Commit message

Upstream snapshot of pollinate 4.32 into artful devel. No packaging bahavior changes made.

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

Import version 4.33-0ubuntu1~14.04.1 to ubuntu/artful-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.

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

I made a small change to this to revert the changes to ChangeLog in the upstream source.
 https://code.launchpad.net/~smoser/ubuntu/+source/pollinate/+git/pollinate/+ref/bug/1761240-sru-artful

Then uploaded that.

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 aedfd52..f744d0c 100644
3--- a/ChangeLog
4+++ b/ChangeLog
5@@ -1,4 +1,66 @@
6-pollinate (4.27) released; urgency=medium
7+pollinate (4.33-0ubuntu1) artful-updates; 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) artful-updates; 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) artful-updates; 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) artful-updates; 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) artful-updates; 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) artful-updates; 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
73diff --git a/debian/changelog b/debian/changelog
74index 436a2ab..c95c528 100644
75--- a/debian/changelog
76+++ b/debian/changelog
77@@ -1,3 +1,15 @@
78+pollinate (4.33-0ubuntu1~17.10.1) artful-updates; urgency=medium
79+
80+ * New upstream release (LP: #1761240):
81+ - Add '--print-user-agent' flag.
82+ - Speedups when collecting information for user-agent.
83+ - Add hypervisor to useragent string
84+ - Get logger version via logger -V rather than dpkg query.
85+ - Add cloud image build info and data in /etc/pollinate/add-user-agent
86+ to user-agent string.
87+
88+ -- Chad Smith <chad.smith@canonical.com> Wed, 30 May 2018 10:27:35 -0600
89+
90 pollinate (4.27-0ubuntu1) artful; urgency=medium
91
92 * Fixup maintscript & version missmatch from the previous upload.
93diff --git a/pollinate b/pollinate
94index 5ec305c..4a4cbbd 100755
95--- a/pollinate
96+++ b/pollinate
97@@ -17,6 +17,7 @@
98 # along with this program. If not, see <http://www.gnu.org/licenses/>.
99
100 set -e
101+set -f
102
103 PKG="pollinate"
104 TMPDIR=$(mktemp -d -t "${PKG}.XXXXXXXXXXXX")
105@@ -28,8 +29,8 @@ HOSTNAME=$(hostname)
106 STRICT=0
107
108 # Only recent logger version supports --id=[ID]
109-logger_ver=$(dpkg -l bsdutils | tail -n1 | awk '{print $3}')
110-dpkg --compare-versions $logger_ver ge 1:2.26.2 && LOGGER="logger --id=$$" || LOGGER="logger"
111+logger_ver=$(logger -V 2>&1 | awk '{print $4}')
112+dpkg --compare-versions $logger_ver ge 2.26.2 && LOGGER="logger --id=$$" || LOGGER="logger"
113 # Log to both syslog, and stderr, if we're on an interactive terminal
114 [ -t 0 ] && LOGGER="$LOGGER -s"
115
116@@ -88,20 +89,121 @@ hash_and_write() {
117 log "client hashed response from [${1}]"
118 }
119
120+read_build_info() {
121+ # ubuntu images place build information in /etc/cloud/build.info
122+ # format of file is '<key>: <value>' put these under img/<key>/<value>
123+ local bifile="${1:-/etc/cloud/build.info}" ret=""
124+ _RET=""
125+ [ -s "$bifile" ] || return 0
126+ ret=$(awk '{
127+ gsub(/#.*/, ""); gsub(/\s+$/, "");
128+ if ($0 == "" || $0 !~ /:/) next;
129+ gsub(/:\s*/, "/");
130+ printf("img/%s ", $0) }' "$bifile") || return
131+ _RET="${ret% }"
132+}
133+
134+read_addl_info() {
135+ # allow additinal info file to contain entries one per line. lines must
136+ # have a '/' in them. remove trailing space and '#' as comment. example:
137+ # key/value
138+ # fookey/foovalue # written by foo
139+ local aifile="${1:-/etc/pollinate/add-user-agent}" ret=""
140+ _RET=""
141+ [ -s "$aifile" ] || return 0
142+ ret=$(awk '{
143+ gsub(/#.*/, ""); gsub(/\s+$/, "");
144+ if ($0 == "" || $0 !~ /\//) next;
145+ printf("%s ", $0); }' "$aifile") || return
146+ _RET=${ret% }
147+}
148+
149+read_virt() {
150+ # return virt/<value> where value is the virtualization platform the
151+ # system is running on.
152+ local ret=""
153+ _RET=""
154+ if command -v systemd-detect-virt >/dev/null; then
155+ ret=$(systemd-detect-virt)
156+ # systemd-detect-virt returns 1 for 'none'
157+ [ $? -eq 0 -o "$ret" = "none" ] || ret=""
158+ else
159+ # trusty would take this path.
160+ if [ -d /dev/xen ]; then
161+ ret="xen"
162+ elif [ -d /dev/lxd ]; then
163+ # call this 'lxc' for consistency with systemd-detect-virt.
164+ ret="lxc"
165+ elif dmesg | grep --quiet " kvm-clock:"; then
166+ ret="kvm"
167+ fi
168+ fi
169+ [ -n "$ret" ] || return
170+ _RET="virt/$ret"
171+}
172+
173+read_package_versions() {
174+ local pkgs="pollinate curl cloud-init" data="" p=""
175+ data=$(dpkg-query \
176+ -W --showformat='${Package}/${Version} ' $pkgs 2>/dev/null) || :
177+ # fill in 'package/' for any package not installed.
178+ for p in ${pkgs}; do
179+ [ "${data#*$p/}" = "$data" ] && data="${data} $p/"
180+ done
181+ if [ -n "$TESTING" ]; then
182+ p="pollinate"
183+ data="${data%%$p/*}$p${TESTING}/${data#*$p/}"
184+ fi
185+ set -- $data
186+ _RET="$*"
187+}
188+
189+read_uname_info() {
190+ # taken from cloud-init ds-identify.
191+ # run uname, and parse output.
192+ # uname is tricky to parse as it outputs always in a given order
193+ # independent of option order. kernel-version is known to have spaces.
194+ # 1 -s kernel-name
195+ # 2 -n nodename
196+ # 3 -r kernel-release
197+ # 4.. -v kernel-version(whitespace)
198+ # N-2 -m machine
199+ # N-1 -o operating-system
200+ local out="" krel="" machine="" os=""
201+ out=$(uname -snrvmo) || { _RET=""; return; }
202+ set -- $out
203+ krel="$3"
204+ shift 3
205+ while [ $# -gt 2 ]; do
206+ shift
207+ done
208+ machine=$1
209+ os=$2
210+ _RET="$os/$krel/$machine"
211+ return 0
212+}
213+
214 user_agent() {
215 # Construct a user agent, with useful debug information
216 # Very similar to Firefox and Chrome
217- local pollinate_ver="$(dpkg -l pollinate | awk '$1 == "ii" { print($3); exit(0); }')"
218- local curl_ver="$(dpkg -l curl | awk '$1 == "ii" { print($3); exit(0); }')"
219- local cloud_init_ver="$(dpkg -l cloud-init 2>/dev/null | awk '$1 == "ii" { print($3); exit(0); }')"
220+
221 . /etc/lsb-release
222- local lsb=$(echo "${DISTRIB_DESCRIPTION}" | sed -e "s/ /\//g")
223- local platform="$(uname -o)/$(uname -r)/$(uname -m)"
224- local cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")"
225- local up="NA" idle="NA"
226+
227+ local pkg_info="" lsb="" platform="" cpu="" up="NA" idle="NA" uptime
228+ read_package_versions && pkg_info="$_RET"
229+ read_uname_info && platform="$_RET"
230+
231+ lsb=$(echo "${DISTRIB_DESCRIPTION}" | sed -e "s/ /\//g")
232+ cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")"
233 { read up idle < /proc/uptime ; } >/dev/null 2>&1 || :
234- local uptime="uptime/$up/$idle"
235- USER_AGENT="pollinate${TESTING}/${pollinate_ver} curl/${curl_ver} cloud-init/${cloud_init_ver} ${lsb} ${platform} ${cpu} ${uptime}"
236+ uptime="uptime/$up/$idle"
237+
238+ local addl_data="" build_info="" virt=""
239+ read_build_info && build_info="${_RET}"
240+ read_addl_info && addl_data="${_RET}"
241+ read_virt && virt="${_RET}"
242+
243+ USER_AGENT="${pkg_info} ${lsb} ${platform} ${cpu} ${uptime}${virt:+ ${virt}}${build_info:+ ${build_info}}${addl_data:+ ${addl_data}}"
244 }
245
246 exchange() {
247@@ -203,6 +305,11 @@ while [ ! -z "$1" ]; do
248 WAIT="$2"
249 shift 2
250 ;;
251+ --print-user-agent)
252+ user_agent || error "Failed to get user-agent."
253+ echo "${USER_AGENT}"
254+ exit
255+ ;;
256 *)
257 error "Unknown options [$1]"
258 ;;
259diff --git a/pollinate.1 b/pollinate.1
260index f7890ee..8e2b9ce 100644
261--- a/pollinate.1
262+++ b/pollinate.1
263@@ -45,6 +45,9 @@ silence any log messages
264 .TP
265 \fB-w|--wait\fP WAIT
266 time in seconds you're willing to wait for a response from the server, uses \fBtimeout\fP(1)
267+.TP
268+\fB --print-user-agent\fP
269+Print the user-agent that is used and exit immediately.
270
271 .SH SEE ALSO
272 \fBpollen\fP(8), \fBtimeout\fP(1)

Subscribers

People subscribed via source and target branches