-
Notifications
You must be signed in to change notification settings - Fork 95
/
snapcraft.yaml
115 lines (105 loc) · 3.79 KB
/
snapcraft.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: dynamips
base: core24
summary: Dynamips
description: |
Dynamips is an emulator designed to run Cisco IOS images.
apps: # TODO test and review needed plugs
dynamips:
command: bin/dynamips_amd64_stable
plugs:
- network
- network-bind
x86: # dynamips.x86
command: bin/dynamips_x86_stable
plugs:
- network
- network-bind
unstable: # dynamips.unstable
command: bin/dynamips_amd64_unstable
plugs:
- network
- network-bind
x86-unstable: # dynamips.x86-unstable
command: bin/dynamips_x86_unstable
plugs:
- network
- network-bind
udp-send: # dynamips.udp-send
command: bin/udp_send
plugs:
- network
- network-bind
udp-recv: # dynamips.udp-recv
command: bin/udp_send
plugs:
- network
- network-bind
nvram-export: # dynamips.nvram-export
command: bin/nvram_export
adopt-info: dynamips # grade and version are set in override-pull
confinement: strict
platforms:
amd64: # builds the amd64 version and x86 version
parts:
dynamips:
plugin: nil
source: .
override-pull: |
craftctl default
# set grade and version
if [ -d "./.git" ]; then # can use git as reference
apt-get install -y git
_version=$(git describe --all --tags)
if [[ $_version == "tags/v"* ]]; then # is a release
craftctl set grade=stable
else # is not a release
_version=$(git describe --all --tags --long --abbrev=10) # add hash
craftctl set grade=devel
fi
_version="${_version/heads\//}" # remove "heads/"
_version="${_version/tags\//}" # remove "tags/"
# TODO how should version be normalized?
craftctl set version=$_version
else # has unknown version
craftctl set grade=devel
craftctl set version=unknown
fi
build-packages:
- cmake
- gcc-i686-linux-gnu
- g++-i686-linux-gnu
- gcc-x86-64-linux-gnu
- g++-x86-64-linux-gnu
override-build: |
# TODO how to make build-packages install i386 packages reliably? adding the architecture in a previous part can fail rebuilds
dpkg --add-architecture i386
apt-get update
apt-get install -y libelf-dev libelf-dev:i386
# XXX libpcap0.8-dev and libpcap0.8-dev:i386 cannot coexist
# build with x86 jit code
mkdir -p "${CRAFT_PART_BUILD_WORK}/build_x86"
cd "${CRAFT_PART_BUILD_WORK}/build_x86"
apt-get remove -y libpcap0.8-dev
apt-get install -y libpcap0.8-dev:i386
export CC=i686-linux-gnu-gcc
export CXX=i686-linux-gnu-g++
cmake "${CRAFT_PART_SRC_WORK}" -G "Unix Makefiles" "-DCMAKE_INSTALL_PREFIX=${CRAFT_PART_INSTALL}" -DDYNAMIPS_RENAME= -DDYNAMIPS_CODE=both -DBUILD_NVRAM_EXPORT=ON -DBUILD_UDP_SEND=ON -DBUILD_UDP_RECV=ON
cmake --build . -- "-j${CRAFT_PARALLEL_BUILD_COUNT}"
cmake --build . --target install
# build with amd64 jit code
mkdir -p "${CRAFT_PART_BUILD_WORK}/build_amd64"
cd "${CRAFT_PART_BUILD_WORK}/build_amd64"
apt-get remove -y libpcap0.8-dev:i386
apt-get install -y libpcap0.8-dev
export CC=x86_64-linux-gnu-gcc
export CXX=x86_64-linux-gnu-g++
cmake "${CRAFT_PART_SRC_WORK}" -G "Unix Makefiles" "-DCMAKE_INSTALL_PREFIX=${CRAFT_PART_INSTALL}" -DDYNAMIPS_RENAME= -DDYNAMIPS_CODE=both -DBUILD_NVRAM_EXPORT=ON -DBUILD_UDP_SEND=ON -DBUILD_UDP_RECV=ON
cmake --build . -- "-j${CRAFT_PARALLEL_BUILD_COUNT}"
cmake --build . --target install
override-stage: |
# TODO how to make stage-packages install i386 packages reliably? adding the architecture in a previous part can fail rebuilds
dpkg --add-architecture i386
apt-get update
apt-get install -y libelf1 libelf1:i386
apt-get install -y libpcap0.8 libpcap0.8:i386
craftctl default