Skip to content

Commit 685ec23

Browse files
Sergio Schvezovyonghong-song
authored andcommitted
snap: update and cleanup snapcraft.yaml
A couple of issues fixed: - put snapcraft.yaml in the snap directory so it is picked up by snapcraft when run from the project root. - use snap/local for local snapcraft assets. - setup.py.in should not add root for sdist targets - cleanup snap/README.md. - re-arrange parts in snapcraft.yaml and move to python3. Signed-off-by: Sergio Schvezov <[email protected]>
1 parent 6878949 commit 685ec23

File tree

5 files changed

+56
-94
lines changed

5 files changed

+56
-94
lines changed
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,28 @@ creating efficient kernel tracing and manipulation programs.
55

66
First, install snapcraft, e.g. on Ubuntu:
77

8-
sudo apt install snapcraft
8+
sudo snap install snapcraft --classic
99

1010
Clone the bcc repo (if you haven't done so already) and create the snap:
1111

12-
git clone https://github.com/iovisor/bcc.git
13-
cd snapcraft
14-
make
12+
git clone https://github.com/iovisor/bcc.git
13+
snapcraft
1514

16-
Note: running `make` just gets the version from the current bcc gito
17-
repository and uses this in the snapcraft yaml file to version the bcc
18-
snap. The Makefile basically runs snapcraft to snap up bcc.
15+
Install the snap by running (`--dangerous` is required as the snap is
16+
not coming from the Snap Store):
1917

20-
Install the snap by running:
18+
sudo snap install --dangerous bcc_*.snap
2119

22-
sudo snap install --devmode bcc_*.snap
20+
One may need to ensure the snap interfaces are connected for the snap
21+
using:
2322

24-
One may need to ensure the snap plugins are enabled for the snap using:
25-
26-
sudo snap connect bcc:mount-observe
27-
sudo snap connect bcc:system-observe
28-
sudo snap connect bcc:system-trace
23+
sudo snap connect bcc:mount-observe
24+
sudo snap connect bcc:system-observe
25+
sudo snap connect bcc:system-trace
2926

3027
Now run a bcc tool, for example, to run opensnoop use:
3128

32-
sudo bcc.opensnoop
29+
sudo bcc.opensnoop
3330

3431
Note that this may fail to build and run if you do not have the kernel
3532
headers installed or perhaps the kernel config is not set up correctly.
Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2016 Canonical
2+
# Copyright (C) 2016,2020 Canonical
33
#
44
# This program is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU General Public License
@@ -16,7 +16,6 @@
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717
#
1818
name: bcc
19-
version: 0.9.0-20190318-2991-6cf63612
2019
summary: BPF Compiler Collection (BCC)
2120
description: A toolkit for creating efficient kernel tracing and manipulation programs
2221
confinement: strict
@@ -27,52 +26,70 @@ plugs:
2726
system-trace: null
2827
assumes: [snapd2.37]
2928
base: core18
29+
adopt-info: bcc
3030

3131
parts:
3232
bcc:
3333
plugin: cmake
3434
override-pull: |
3535
snapcraftctl pull
36-
find . -type f -exec sed -i 's|^#\!/usr/bin/python|#\!/usr/bin/env python|' {} \;
36+
37+
find . -type f -exec sed -i 's|^#\!/usr/bin/python|#\!/usr/bin/env python3|' {} \;
38+
39+
version=$(git tag | sort -V | tail -1 | cut -c2-)
40+
commits=$(git log --oneline | wc -l)
41+
sha=$(git log -1 --oneline | cut -d' ' -f1)
42+
date=$(date +'%Y%m%d')
43+
snapcraftctl set-version "$version-$date-$commits-$sha"
3744
configflags:
3845
- '-DCMAKE_INSTALL_PREFIX=/usr'
39-
source: ..
40-
source-type: git
41-
stage-packages:
42-
- libbz2-1.0
43-
- liblzma5
44-
- libncursesw5
45-
- libtinfo5
46-
- libzzip-0-13
46+
- '-DPYTHON_CMD=$SNAPCRAFT_STAGE/usr/bin/python3'
47+
- '-DCMAKE_VERBOSE_MAKEFILE=ON'
48+
source: .
4749
build-packages:
4850
- bison
4951
- build-essential
50-
- cmake
5152
- flex
53+
- git
54+
- iperf
55+
- libclang-4.0-dev
5256
- libedit-dev
57+
- libelf-dev
5358
- libllvm4.0
5459
- llvm-4.0-dev
55-
- libclang-4.0-dev
56-
- python
5760
- zlib1g-dev
58-
- libelf-dev
59-
- iperf
6061
prime:
61-
- usr/share/bcc/tools
62-
- usr/lib/python2.7
63-
- usr/lib/*/lib*.so*
6462
- -usr/share/bcc/tools/doc
63+
- usr/lib/*/lib*.so*
64+
- usr/lib/python3
65+
- usr/lib/python3.6*
66+
- usr/share/bcc/tools
67+
after:
68+
- stage
6569

66-
python-deps:
67-
plugin: python
68-
python-version: python2
70+
stage:
71+
plugin: nil
72+
stage-packages:
73+
- libbz2-1.0
74+
- liblzma5
75+
- libncursesw5
76+
- libtinfo5
77+
- libzzip-0-13
78+
- python3
79+
- python3-distutils
80+
- python3-distutils-extra
81+
- python3-pip
82+
- python3-setuptools
83+
prime:
84+
- -usr/lib/*/perl
85+
- -usr/lib/*/perl5
86+
- usr/bin
87+
- usr/lib
6988

7089
wrapper:
7190
plugin: dump
7291
after: [bcc]
73-
source: .
74-
organize:
75-
wrapper: bin/bcc-wrapper
92+
source: snap/local
7693

7794
apps:
7895
argdist:

snapcraft/Makefile

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/python/setup.py.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ from distutils.core import setup
44
import os
55
import sys
66

7-
if os.environ.get('DESTDIR'):
7+
# sdist does not support --root.
8+
if "sdist" not in sys.argv and os.environ.get('DESTDIR'):
89
sys.argv += ['--root', os.environ['DESTDIR']]
910

1011
setup(name='bcc',

0 commit comments

Comments
 (0)