launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28727
Re: [Merge] ~lgp171188/launchpad:charming-extract-launchpad-build into launchpad:master
Diff comments:
> diff --git a/charm/Makefile b/charm/Makefile
> new file mode 100644
> index 0000000..0988922
> --- /dev/null
> +++ b/charm/Makefile
> @@ -0,0 +1,96 @@
> +# The charmcraft tool is shipped as a snap, so make sure it's on $PATH.
> +export PATH := $(PATH):/snap/bin
> +
> +APP_NAME := launchpad
> +
> +BUILDDIR := $(CURDIR)/dist
> +TMPDIR := $(CURDIR)/tmp
> +CHARM_LAYERS_DIR := $(TMPDIR)/deps/ols-layers/layer
> +CHARM_INTERFACES_DIR := $(TMPDIR)/deps/ols-layers/interface
> +
> +CHARM_SERIES ?= 18.04
> +ARCH := $(shell dpkg --print-architecture)
> +charm_file = $(1)_ubuntu-$(CHARM_SERIES)-$(ARCH).charm
> +
> +BUILD_LABEL = $(shell git rev-parse HEAD)
> +TARBALL = $(APP_NAME).tar.gz
> +ASSET = ../build/$(BUILD_LABEL)/$(TARBALL)
> +
> +CHARMS := launchpad
> +
> +help: ## display this help message
Colin, if you are okay with this, I'd like to introduce something similar for all the `Makefile`s too where running `make` (we can leave it be if the current behaviour has to be retained) and `make help` lists the available targets and their usage.
> + @echo "Please use \`make <target>' where <target> is one of"
> + @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
> +
> +all: ## alias to build
> +all: build
> +
> +$(BUILDDIR) $(TMPDIR):
> + @mkdir -p $@
> +
> +# We have to clone our dependencies by hand rather than letting charmcraft
> +# do it, since some of them are in private repositories and charmcraft
> +# doesn't have suitable credentials.
> +CHARM_DEPS := $(CHARM_LAYERS_DIR)/.done $(CHARM_INTERFACES_DIR)/.done
> +$(CHARM_DEPS): $(CURDIR)/dependencies.txt | $(TMPDIR)
> + @echo "Fetching dependencies..."
> + @mkdir -p $(TMPDIR)/deps
> + @cd $(TMPDIR)/deps && codetree $<
> + @touch $(CHARM_DEPS)
> +
> +build: ## build all the charms
> +build: $(foreach charm,$(CHARMS),build-$(charm))
> +
> +build-launchpad: ## build the launchpad charm
> +build-launchpad: dist/$(call charm_file,launchpad)
> +
> +dist/%_ubuntu-$(CHARM_SERIES)-$(ARCH).charm: $(CHARM_DEPS) | $(BUILDDIR)
> + @echo "Building $*..."
> + @rm -rf $*/tmp
> + @cp -a tmp $*/tmp
> + @cd $* && charmcraft pack
> + @cp -a $*/$(call charm_file,$*) dist/
> + @rm -rf $*/tmp
> +
> +clean: ## clean the build environment
> +clean: $(foreach charm,$(CHARMS),clean-$(charm))
> + @find . -name \*.pyc -delete
> + @find . -depth -name '__pycache__' -exec rm -rf '{}' \;
> + @rm -f bundle.yaml
> + @rm -f layer/*/codetree-collect-info.yaml
> + @rm -rf $(BUILDDIR) $(TMPDIR)
> +
> +clean-%:
> + @echo "Cleaning $*..."
> + @cd $* && charmcraft clean
> + @rm -f dist/$(call charm_file,$*)
> +
> +bundle.yaml: ## create the bundle.yaml file from the bundle.yaml.in template
> +bundle.yaml: bundle.yaml.in
> + sed \
> + -e 's/%BUILD_LABEL%/$(BUILD_LABEL)/g' \
> + bundle.yaml.in >bundle.yaml
> +
> +deploy: ## deploy the built charm
> +deploy: build bundle.yaml
> + @echo "Deploying $(APP_NAME)..."
> + @juju deploy ./bundle.yaml
> +
> +payload: ## build a launchpad tarball
> +payload: $(ASSET)
> +$(ASSET):
> + @echo "Building asset for $(BUILD_LABEL)..."
> + @$(MAKE) -C .. build-tarball
> +
> +
> +setup-jenkaas: ## prepare a Jenkins-as-a-service container for charm building
> +setup-jenkaas:
> + sudo systemctl stop snapd.socket
> + sudo systemctl stop snapd
> + echo SNAPPY_STORE_NO_CDN=1 | sudo tee -a /etc/environment >/dev/null
> + echo SNAPPY_TESTING=1 | sudo tee -a /etc/environment >/dev/null
> + sudo systemctl start snapd.socket
> + sudo snap install --classic charm
> +
> +.PHONY: $(foreach charm,$(CHARMS),build-$(charm))
> +.PHONY: all build clean deploy payload setup-jenkaas
--
https://code.launchpad.net/~lgp171188/launchpad/+git/launchpad/+merge/426198
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/launchpad:charming-extract-launchpad-build into launchpad:master.
References