Skip to content

Commit

Permalink
feat: build 7.3.4 on core24
Browse files Browse the repository at this point in the history
Update snapcraft yaml to buil on core24
Build latest mongodb 7.x and relevant tools binaries.
  • Loading branch information
wallyworld committed Aug 20, 2024
1 parent 4f156bf commit 20a455c
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: juju-db
version: '4.4.24'
version: '7.3.4'
summary: MongoDB object/document oriented database used internally by Juju.
description: |
MongoDB object/document oriented database used internally by Juju.
confinement: strict
grade: stable
base: core20
base: core24
license: SSPL-1.0

apps:
Expand Down Expand Up @@ -72,22 +72,29 @@ parts:
mongo-tools:
source: https://github.com/mongodb/mongo-tools
source-type: git
source-tag: "100.6.1"
plugin: go
source-tag: "100.10.0"
plugin: nil
build-snaps:
- go
build-packages:
- pkg-config
- libssl-dev
- libpcap0.8-dev
- libsasl2-dev
- libkrb5-dev
stage-packages:
- libssl1.1
- libssl3
- libpcap0.8
- libsasl2-2
go-channel: 1.19/stable
override-build: |
export GOROOT=/snap/go/current
export GOPATH=$(realpath ..)
# mongo tools hard codes the build platform to bionic
# and panics if built on anything else :-(
# Tricking it into thinking it's running in CI
# forces it to look at an env var for the platform.
export CI=anything
export EVG_VARIANT=ubuntu2404
./make build
mkdir -p ${SNAPCRAFT_PART_INSTALL}/bin/
mongo_tools="mongodump mongorestore mongotop mongostat"
Expand All @@ -101,31 +108,32 @@ parts:
after: [mongo-tools]
source: https://github.com/mongodb/mongo
source-type: git
source-tag: "r4.4.24"
source-tag: "r7.3.4"
plugin: nil
stage-packages:
- libssl1.1
- libssl3
- libcurl4
- libstemmer0d
- zlib1g
- libsnappy1v5
- libyaml-cpp0.6
- libyaml-cpp0.8
- libpcre3
- libpcrecpp0v5
- libboost-system1.71.0
- libboost-iostreams1.71.0
- libboost-filesystem1.71.0
- libboost-program-options1.71.0
- libboost-system1.74.0
- libboost-iostreams1.74.0
- libboost-filesystem1.74.0
- libboost-program-options1.74.0
- libgoogle-perftools4
build-packages:
# isn't available on s390x, only needed on the rest anyway.
- try:
- to amd64,arm64,ppc64el:
- libgoogle-perftools-dev
- libssl-dev
- liblzma-dev
- libcurl4-openssl-dev
# python packages cribbed from deb, might need changed.
- python-typing
- python3.11-venv
- python3.11-dev
- python-dev-is-python3
- python3-cheetah
- python3-pip
- python3-pkg-resources
Expand Down Expand Up @@ -153,11 +161,23 @@ parts:
- valgrind

override-build: |
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# We need to use Python 3.11 to build.
add-apt-repository -y ppa:deadsnakes/ppa
apt install -y python3.11
ln -sf /usr/bin/python3.11 /usr/bin/python3
python3 -m venv _build --prompt mongo
source _build/bin/activate
pip install --upgrade pip
# Later mongo source has a build script for poetry.
# But for 7.x we need to do it manually.
python3 -m pip install 'poetry==1.5.1'
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
python3 -m poetry install --no-root --sync
# don't care: --server-js=off
# Use system tcmalloc as it's more 'trusted' and would be updated by kernel/security team.
SCONSFLAGS="--use-system-tcmalloc --disable-warnings-as-errors --use-system-pcre --use-system-snappy --use-system-zlib --use-system-valgrind --use-system-stemmer --use-system-yaml --ssl"
SCONSFLAGS="--use-system-tcmalloc --disable-warnings-as-errors --use-system-pcre2 --use-system-snappy --use-system-zlib --use-system-valgrind --use-system-stemmer --use-system-yaml --ssl"
arch=$(uname -m)
if [ $arch = "aarch64" ]; then
ccflags_arg="CCFLAGS=-march=armv8-a+crc"
Expand All @@ -173,7 +193,7 @@ parts:
export SCONSFLAGS
export DESTDIR=$SNAPCRAFT_PART_INSTALL
python3 buildscripts/scons.py install-mongo install-mongod $ccflags_arg
python3 buildscripts/scons.py install-mongo install-mongod --linker=gold $ccflags_arg
# Strip binaries down to a usable size.
for file in $SNAPCRAFT_PART_BUILD/build/install/bin/mongo*;
Expand All @@ -184,7 +204,9 @@ parts:
logrotate:
plugin: dump
source: logrotate
source-type: local
stage-packages:
- logrotate
organize:
juju-db.conf: etc/logrotate-juju-db.conf
override-build: |
snapcraftctl build
install --mode 0644 juju-db.conf ${SNAPCRAFT_PART_INSTALL}/etc/logrotate-juju-db.conf

0 comments on commit 20a455c

Please sign in to comment.