Merge ~sespiros/ubuntu-security-tools/+git/ubuntu-security-tools:coverity-snap-update-command into ubuntu-security-tools:master

Proposed by Spyros Seimenis
Status: Needs review
Proposed branch: ~sespiros/ubuntu-security-tools/+git/ubuntu-security-tools:coverity-snap-update-command
Merge into: ubuntu-security-tools:master
Diff against target: 88 lines (+65/-1)
2 files modified
snaps/coverity-ubuntu-security/files/bin/update (+60/-0)
snaps/coverity-ubuntu-security/snapcraft.yaml (+5/-1)
Reviewer Review Type Date Requested Status
Ubuntu Security Team Pending
Review via email: mp+454284@code.launchpad.net

Description of the change

I copied the install command to a new update command which disregards the existence of the symlink, deletes it and reinstalls a new coverity version. I also changed the snap's version to not follow the coverity versions since it doesn't make much sense. We may also want to delete the previous version's untarred files (not in this commit).

With this, if you already have the coverity snap installed, updating coverity locally should work like:

1) Download new coverity binary (+ license)
2) Run

coverity-ubuntu-security.update cov-analysis...tar.gz license...dat

To post a comment you must log in.

Unmerged commits

a84fcd6... by Spyros Seimenis

snaps/coverity: add update functionality

This adds the update command, useful for when the coverity binaries
get updated.

Since this is an utility package and doesn't actually include coverity,
it doesn't make sense for its version to follow coverity versions as in
new coverity versions don't necessarily need an updated coverity snap.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/snaps/coverity-ubuntu-security/files/bin/update b/snaps/coverity-ubuntu-security/files/bin/update
2new file mode 100755
3index 0000000..e387cc2
4--- /dev/null
5+++ b/snaps/coverity-ubuntu-security/files/bin/update
6@@ -0,0 +1,60 @@
7+#!/bin/sh
8+set -e
9+
10+install_symlink="cov-analysis-current"
11+topdir="$SNAP_USER_COMMON/$install_symlink"
12+bindir="$topdir/bin"
13+
14+if [ -z "$SNAP_USER_COMMON" ]; then
15+ echo "SNAP_USER_COMMON not set! Aborting"
16+ exit 1
17+fi
18+
19+if [ ! -e "$1" ]; then
20+ echo "Please specify the path to a cov-analysis tarball"
21+ exit 1
22+fi
23+cova="$1"
24+if echo "$cova" | grep -vq '/' ; then
25+ cova="$(pwd)/$cova"
26+fi
27+
28+if [ ! -e "$2" ]; then
29+ echo "Please specify a valid path to the license file"
30+ exit 1
31+fi
32+lic="$2"
33+if echo "$lic" | grep -vq '/' ; then
34+ lic="$(pwd)/$lic"
35+fi
36+
37+if [ ! -d "$SNAP_USER_COMMON" ]; then
38+ mkdir -p "$SNAP_USER_COMMON"
39+fi
40+
41+if [ -d "$bindir" ]; then
42+ inst=$(readlink "$SNAP_USER_COMMON/$install_symlink")
43+ echo "Previous install detected at '$inst'. Deleting..."
44+ rm $SNAP_USER_COMMON/$install_symlink
45+else
46+ echo "Previous coverity install not found. Use command \"install\" to do a fresh installation."
47+ exit 1
48+fi
49+
50+cd "$SNAP_USER_COMMON"
51+echo "Untarring '$cova' to $SNAP_USER_COMMON..."
52+tar -zxf "$cova"
53+
54+echo "Creating $install_symlink symlink in $SNAP_USER_COMMON..."
55+bn=$(basename "$cova" .tar.gz)
56+ln -s "$bn" "$install_symlink"
57+if [ ! -d "$bindir" ]; then
58+ echo "Could not find '$bindir'. Not installing license file"
59+ exit 1
60+fi
61+
62+echo "Copying '$lic' to $bindir..."
63+cp "$lic" "$bindir"
64+
65+echo "Update completed."
66+echo
67diff --git a/snaps/coverity-ubuntu-security/snapcraft.yaml b/snaps/coverity-ubuntu-security/snapcraft.yaml
68index c2d5cda..d0ff8ef 100644
69--- a/snaps/coverity-ubuntu-security/snapcraft.yaml
70+++ b/snaps/coverity-ubuntu-security/snapcraft.yaml
71@@ -1,5 +1,5 @@
72 name: coverity-ubuntu-security
73-version: "2023.03-64"
74+version: "0.0.1"
75 summary: Coverity packaging for running as a snap
76 description: |
77 Unpack cov-analysis-linux64-YYYY.MM.tar.gz to $SNAP_USER_COMMON with a symlink
78@@ -19,6 +19,10 @@ apps:
79 command: bin/install
80 plugs:
81 - home
82+ update:
83+ command: bin/update
84+ plugs:
85+ - home
86 refresh-auth-key:
87 command: bin/refresh-auth-key
88 plugs:

Subscribers

People subscribed via source and target branches