Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build 7.3.4 on core24 #41

Open
wants to merge 4 commits into
base: 7.3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 56 additions & 39 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic.

# 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,37 +108,35 @@ 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
- libpcre3
- libpcrecpp0v5
- libboost-system1.71.0
- libboost-iostreams1.71.0
- libboost-filesystem1.71.0
- libboost-program-options1.71.0
- libgoogle-perftools4
- libyaml-cpp0.8
- to amd64:
- libgoogle-perftools4t64
- to arm64:
- libgoogle-perftools4t64
- to ppc64el:
- libgoogle-perftools4t64
build-packages:
# isn't available on s390x, only needed on the rest anyway.
- try:
- libgoogle-perftools-dev
- to amd64:
- libgoogle-perftools-dev
- to arm64:
- libgoogle-perftools-dev
- to ppc64el:
- libgoogle-perftools-dev
- libssl-dev
- liblzma-dev
- libcurl4-openssl-dev
# python packages cribbed from deb, might need changed.
- python-typing
- python3-cheetah
- python3-pip
- python3-pkg-resources
- python3-pymongo
- python3-yaml
- python3-psutil
- python3.11
- python3.11-venv
- python3.11-dev
# I think these and some of the above will be needed as staging packages too (for when its installed and being run).
# - python-requests
# - python-subprocess32
Expand All @@ -140,24 +145,30 @@ parts:
- zlib1g-dev
- libsnappy-dev
- libyaml-cpp-dev
- libpcre3-dev
- libboost-iostreams-dev
- libpcre2-dev
# packages from the mongodb wiki/doc
- build-essential
- libboost-log-dev
- libboost-filesystem-dev
- libboost-program-options-dev
- libboost-system-dev
- libboost-thread-dev
# required packages
- valgrind
- rust-all

override-build: |
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# We need to use Python 3.11 to build.
python3.11 -m venv _build --prompt mongo
source _build/bin/activate
python3 -m pip install --upgrade pip

python3 -m pip install distlib
# Later mongo source has a build script for poetry.
# But for 7.x we need to do it manually.
python3 -m pip install poetry
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
python3 -m poetry update poetry pyproject-hooks distlib virtualenv packaging cryptography pkgutil
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="--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 @@ -168,12 +179,12 @@ parts:
if [ $arch = "s390x" ]; then
SCONSFLAGS="$SCONSFLAGS --allocator=system"
else
SCONSFLAGS="$SCONSFLAGS --allocator=tcmalloc"
SCONSFLAGS="$SCONSFLAGS --use-system-tcmalloc --allocator=tcmalloc"
fi
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 +195,13 @@ 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

package-repositories:
- type: apt
ppa: deadsnakes/ppa