Merge ~sahnaseredini/ubuntu-cve-tracker:amir-dev into ubuntu-cve-tracker:master

Proposed by Amir Naseredini
Status: Merged
Approved by: Amir Naseredini
Approved revision: 9b58c370f87ca2bc4f00668ffcbaeb8f8ca5cd66
Merged at revision: 1203150c0f53fb1b33406914a010e05eef1d7036
Proposed branch: ~sahnaseredini/ubuntu-cve-tracker:amir-dev
Merge into: ubuntu-cve-tracker:master
Diff against target: 72 lines (+16/-8)
2 files modified
scripts/pkg_history (+10/-5)
scripts/pkg_status (+6/-3)
Reviewer Review Type Date Requested Status
Spyros Seimenis Approve
Review via email: mp+444985@code.launchpad.net

Commit message

Changing the relative addresses to absolute addresses

Description of the change

There are some cases where a relative address is used in scripts/pkg_history
and scripts/pkg_status which doesn't let the code to run correctly everywhere.
This PR proposes the changes required to change the relative addresses to
absolute addresses in order to solve the issue.

To post a comment you must log in.
Revision history for this message
Spyros Seimenis (sespiros) wrote :

Hey Amir, thanks for the fixes. pkg_history might need an extra change as as it is, it would break for people using it with shells that are not bash (due to "BASH_SOURCE" missing). For example I am on zsh and I get:

scripts/pkg_history: 13: Bad substitution
dirname: missing operand

A workaround would be to simply change the shebang at the top of the pkg_history script to explicitly invoke #!/usr/bin/bash rather than #!/bin/sh (which is linked to dash in Ubuntu). pkg_status already uses #!/bin/bash and I see most scripts in UCT do the same so I guess that would be fine.

Apparently this seems like one of those rabbit-hole issues if you wanted to do that while still being POSIX compliant i.e check out https://stackoverflow.com/questions/29832037/how-to-get-script-directory-in-posix-sh

review: Needs Fixing
Revision history for this message
Amir Naseredini (sahnaseredini) wrote :

Hey Spyros, thanks for the review and comments. I made the following change:

* changed the shebang to invoke bash

Let me know what you think. Thanks

Revision history for this message
Spyros Seimenis (sespiros) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/scripts/pkg_history b/scripts/pkg_history
index 8bc0677..022ce2d 100755
--- a/scripts/pkg_history
+++ b/scripts/pkg_history
@@ -1,4 +1,4 @@
1#!/bin/sh1#!/bin/bash
22
3# Author: Jamie Strandboge <jamie@ubuntu.com>3# Author: Jamie Strandboge <jamie@ubuntu.com>
4# Copyright (C) 2013 Canonical Ltd.4# Copyright (C) 2013 Canonical Ltd.
@@ -9,6 +9,9 @@
99
10set -e10set -e
1111
12# finding ubuntu-cve-tracker
13UCT_DIR="$( dirname $( dirname "${BASH_SOURCE[0]}" ))"
14
12showfull="no"15showfull="no"
13release=16release=
14showstatus="no"17showstatus="no"
@@ -59,17 +62,19 @@ for pkg in "$@"; do
59 dirs="active"62 dirs="active"
60 fi63 fi
61 for d in ${dirs} ; do64 for d in ${dirs} ; do
62 for cve in `grep "$pattern" ./$d/CVE-* | \65 for cve in `grep "$pattern" "${UCT_DIR}/${d}/CVE-"* | \
63 cut -d ':' -f 1 | \66 cut -d ':' -f 1 | \
64 cut -d '/' -f 3 | \67 rev | \
68 cut -d '/' -f 1 | \
69 rev | \
65 sort -u` ; do70 sort -u` ; do
66 if [ "$showfull" = "yes" ]; then71 if [ "$showfull" = "yes" ]; then
67 echo ""72 echo ""
68 cat "./$d/$cve"73 cat "${UCT_DIR}/$d/$cve"
69 echo ""74 echo ""
70 else75 else
71 if [ "$showstatus" = "yes" ]; then76 if [ "$showstatus" = "yes" ]; then
72 status=$(grep "^$pattern" "./${d}/${cve}" | cut -d ':' -f 2-)77 status=$(grep "^$pattern" "${UCT_DIR}/${d}/${cve}" | cut -d ':' -f 2-)
73 echo "${cve}${status}"78 echo "${cve}${status}"
74 else79 else
75 echo "$cve"80 echo "$cve"
diff --git a/scripts/pkg_status b/scripts/pkg_status
index 78fe49b..87f218a 100755
--- a/scripts/pkg_status
+++ b/scripts/pkg_status
@@ -11,6 +11,9 @@
11set -e11set -e
12set -o pipefail12set -o pipefail
1313
14# finding ubuntu-cve-tracker
15UCT_DIR="$( dirname $( dirname "${BASH_SOURCE[0]}" ))"
16
14#17#
15# Usage:18# Usage:
16# ./scripts/pkg_status pkgname1 pkgname2 ...19# ./scripts/pkg_status pkgname1 pkgname2 ...
@@ -54,10 +57,10 @@ for p in "$@"; do
54 pkgs="${pkgs} -p ${p}"57 pkgs="${pkgs} -p ${p}"
55done58done
56if [ "$showfull" = "yes" ]; then59if [ "$showfull" = "yes" ]; then
57 CVES=$(./scripts/ubuntu-table $only_release $skip_esm $subproject $assigned $released_info --supported $nvd $pkgs 2>/dev/null | sort -k 2 | grep -v '^ ' | awk '{print $1}')60 CVES=$(${UCT_DIR}/scripts/ubuntu-table $only_release $skip_esm $subproject $assigned $released_info --supported $nvd $pkgs 2>/dev/null | sort -k 2 | grep -v '^ ' | awk '{print $1}')
58 echo "$CVES" | xargs ./scripts/cve_status -f61 echo "$CVES" | xargs ${UCT_DIR}/scripts/cve_status -f
59else62else
60 REPORT=$(./scripts/ubuntu-table $only_release $skip_esm $subproject $assigned $released_info --supported $nvd $pkgs 2>/dev/null)63 REPORT=$(${UCT_DIR}/scripts/ubuntu-table $only_release $skip_esm $subproject $assigned $released_info --supported $nvd $pkgs 2>/dev/null)
61 if [ -n "$REPORT" ]; then64 if [ -n "$REPORT" ]; then
62 echo "$REPORT" | head -n165 echo "$REPORT" | head -n1
63 echo "$REPORT" | tail -n +2 | sort -n66 echo "$REPORT" | tail -n +2 | sort -n

Subscribers

People subscribed via source and target branches