Skip to content

Commit

Permalink
Minor fixes for Flathub
Browse files Browse the repository at this point in the history
* Removed "flathub" as a submodule (was messing with Flathub
build system).
* Fixes in the "pypi-dependencies"

Signed-off-by: Alvaro Saurin <alvaro.saurin@gmail.com>
  • Loading branch information
inercia committed May 29, 2020
1 parent ddb6df6 commit 1af52e7
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.flatpak-builder
build
.vscode
.idea

# Python
*.pyc
Expand All @@ -10,3 +11,5 @@ __pycache__

/*.xz
/*.flatpak

build-aux/flatpak-pip-generator
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "shared-modules"]
path = shared-modules
url = /~https://github.com/flathub/shared-modules.git
[submodule "flathub"]
path = flathub
url = /~https://github.com/inercia/flathub.git
branch = k3x
73 changes: 55 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ APP_SRC_DATA = $(wildcard data/*.in) $(wildcard data/*.xml)

FLATPAK_SDK = org.gnome.Sdk
FLATPAK_RUNTIME = org.gnome.Platform
FLATPAK_RUNTIME_VERSION = 3.34
FLATPAK_RUNTIME_VERSION = 3.36

FLATPAK_BASE_APP = io.elementary.BaseApp
FLATPAK_BASE_VERSION = juno-19.08

FLATPAK_MANIFEST = $(PROJECT_ROOT)/com.github.inercia.k3x.json
BUILD_ROOT = $(PROJECT_ROOT)/.flatpak-builder
Expand Down Expand Up @@ -49,7 +52,7 @@ FLATPAK_RUN_ARGS = \

FLATPAK_RUN_SHARES = \
--share=ipc \
--socket=x11 \
--socket=fallback-x11 \
--share=network \
--socket=wayland \
--filesystem=xdg-run/dconf \
Expand All @@ -73,7 +76,16 @@ FLATPAK_BUILDER_ARGS = \
FLATPAK_BUILD_ARGS = \
$(FLATPAK_RUN_ARGS) $(FLATPAK_RUN_SHARES) $(BUILD_DIR)

TAG ?=
# the submodule for flathub
FLATHUB_DIR = $(PROJECT_ROOT)/flathub
FLATHUB_PATCH = $(PROJECT_ROOT)/build-aux/flathub-diff.patch


# pep8 ignores
PEP8_IGNORE = E402,E501,E722

TAG ?=
TAG_LATEST = $(shell git describe --abbrev=0)

NINJA_TARGET ?=

Expand Down Expand Up @@ -102,9 +114,22 @@ help: ## Show this help screen
##############################
# Development
##############################

##@ Development

pypi-dependencies.json: build-aux/flatpak-pip-generator requirements.txt
build-aux/flatpak-pip-generator --requirements-file=requirements.txt --output pypi-dependencies

build-aux/flatpak-pip-generator:
curl -o build-aux/flatpak-pip-generator https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/pip/flatpak-pip-generator
chmod 755 build-aux/flatpak-pip-generator

deps: ## Install all the required dependencies for building/running
@printf "$(CYN)>>> $(GRN)Adding flatpak dependencies (apps, frameworks...)...$(END)\n"
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install -y flathub $(FLATPAK_RUNTIME)/x86_64/$(FLATPAK_RUNTIME_VERSION)
flatpak --user install -y flathub $(FLATPAK_SDK)/x86_64/$(FLATPAK_RUNTIME_VERSION)
flatpak --user install -y flathub $(FLATPAK_BASE_APP)/x86_64/$(FLATPAK_BASE_VERSION)

$(BUILD_DIR):
@printf "$(CYN)>>> $(GRN)Creating build dir $(BUILD_DIR) ...$(END)\n"
$(Q)mkdir -p $(BUILD_DIR)
Expand All @@ -123,7 +148,7 @@ $(BUILD_DIR)/build.ninja: $(BUILD_DIR) $(FLATPAK_MANIFEST) $(APP_SRC_MESONS)
$(Q)flatpak build --build-dir=$(BUILD_DIR) $(FLATPAK_BUILD_ARGS) meson $(PROJECT_ROOT) . --prefix=/app

.PHONY: build
build: $(BUILD_DIR)/build.ninja ## Build the application
build: pypi-dependencies.json $(BUILD_DIR)/build.ninja ## Build the application

##@ Local dev loop

Expand All @@ -149,7 +174,7 @@ run: $(BUILD_DIR)/build.ninja ## Run the application locally
.PHONY: clean
clean: ## Clean build products
@printf "$(CYN)>>> $(GRN)Doing a quick clean-up...$(END)\n"
$(Q)rm -rf $(BUILD_DIR) $(RELEASE_DIR) $(FLATPAK_BUNDLE)
$(Q)rm -rf $(BUILD_DIR) $(RELEASE_DIR) $(FLATPAK_BUNDLE) pypi-dependencies.json

.PHONY: distclean
distclean: ## Clean-up everything
Expand All @@ -163,11 +188,11 @@ distclean: ## Clean-up everything
##@ Development: checks and tests

.PHONY: clean
check: pep8 ## check code style
check: pep8 ## Check code style

.PHONY: pep8
pep8:
$(Q)find src -name \*.py -exec pycodestyle --ignore=E402,E501,E722 {} +
$(Q)find src -name \*.py -exec pycodestyle --ignore=$(PEP8_IGNORE) {} +

##############################
# Packaging
Expand Down Expand Up @@ -204,16 +229,31 @@ release: ## Adds a new TAG and pushes it to the origin for forcing a new releas
@printf "$(CYN)>>> $(GRN)Pushing tags $(TAG$)$(END)\n"
$(Q)git push --tags || { printf "$(CYN)>>> $(RED)Failed to push new tag $(TAG) to origin$(END)\n" ; exit 1 ; }

##############################
# Flathub
##############################
##@ Flathub packages

flathub-pull: ## Pull changes in the flathub
# other flatpak stuff

flathub-pull: ## Pull changes from the Flathub repository to the submodule
@printf "$(CYN)>>> $(GRN)Pulling changes in 'flathub' submodule$(END)\n"
$(Q)git submodule update --remote --merge -- flathub
$(Q)git submodule update --remote --merge -- $(FLATHUB_DIR)
@printf "$(CYN)>>> $(GRN)Done$(END)\n"

flathub-commit:
@printf "$(CYN)>>> $(GRN)Committing current state of flathub$(END)\n"
$(Q)git add flathub && git commit -m "Updated flathub"
@printf "$(CYN)>>> $(GRN)Done. You can now 'git push'$(END)\n"
flathub-update: pypi-dependencies.json ## Update the contents of the Flatub submodule
$(Q)[ -d "$(FLATHUB_DIR)" ] || { printf "$(CYN)>>> $(RED)No $(FLATHUB_DIR) directory$(END)\n" ; exit 1 ; }

@printf "$(CYN)>>> $(GRN)Copying pypi dependencies$(END)\n"
$(Q)cp -f pypi-dependencies.json $(FLATHUB_DIR)/

@printf "$(CYN)>>> $(GRN)Copying manifest$(END)\n"
$(Q)rm -f $(FLATHUB_DIR)/$(FLATPAK_MANIFEST)
$(Q)cp -f $(FLATPAK_MANIFEST) $(FLATHUB_DIR)/

@printf "$(CYN)>>> $(GRN)Patching manifest$(END)\n"
$(Q)cd $(FLATHUB_DIR) && \
cat $(FLATHUB_PATCH) | sed -e 's|@TAG@|$(TAG_LATEST)|g' | patch -p0

##############################
# CI
Expand All @@ -225,10 +265,7 @@ ci/setup:
sudo apt-get update -q
sudo apt-get install -y flatpak flatpak-builder elfutils

@printf "$(CYN)>>> $(GRN)Adding flatpak remote...$(END)\n"
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install -y flathub $(FLATPAK_RUNTIME)/x86_64/$(FLATPAK_RUNTIME_VERSION)
flatpak --user install -y flathub $(FLATPAK_SDK)/x86_64/$(FLATPAK_RUNTIME_VERSION)
make deps

@printf "$(CYN)>>> $(GRN)Installing pep8...$(END)\n"
sudo apt-get -y install python3-pip
Expand Down
14 changes: 14 additions & 0 deletions build-aux/flathub-diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- com.github.inercia.k3x.json 2020-05-28 13:42:29.761854808 +0200
+++ com.github.inercia.k3x.json 2020-05-28 13:42:29.761854808 +0200
@@ -73,8 +73,9 @@
"buildsystem": "meson",
"sources": [
{
- "type": "dir",
- "path": "."
+ "type": "git",
+ "url": "/~https://github.com/inercia/k3x.git",
+ "tag": "@TAG@"
}
]
}
56 changes: 8 additions & 48 deletions com.github.inercia.k3x.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
{
"app-id": "com.github.inercia.k3x",
"runtime": "org.gnome.Platform",
"runtime-version": "3.34",
"sdk": "org.gnome.Sdk",
"base": "io.elementary.BaseApp",
"base-version": "juno-19.08",
"runtime": "org.freedesktop.Platform",
"sdk": "org.freedesktop.Sdk",
"runtime-version": "19.08",
"command": "k3x",
"finish-args": [
"--device=dri",
"--share=ipc",
"--socket=x11",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=ssh-auth",
"--share=network",
"--env=LD_LIBRARY_PATH=/app/lib:/app/lib/x86_64-linux-gnu:/lib64:/lib:/usr/lib64:/usr/lib:/usr/local/lib",
"--filesystem=/run/docker.sock",
"--talk-name=org.freedesktop.Notifications",
"--talk-name=org.kde.StatusNotifierWatcher",
"--talk-name=com.canonical.indicator.application",
"--talk-name=org.ayatana.indicator.application",
"--talk-name=ca.desrt.dconf",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf",
"--filesystem=home:rw"
],
"cleanup": [
Expand All @@ -37,33 +34,9 @@
"*.la",
"*.a"
],
"copy-icon": true,
"modules": [
"shared-modules/libappindicator/libappindicator-gtk3-introspection-12.10.json",
{
"name": "libappindicator"
},
{
"name": "granite",
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "/~https://github.com/elementary/granite.git",
"tag": "5.3.1"
}
]
},
{
"name": "elementary-icons",
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "/~https://github.com/elementary/icons.git",
"tag": "5.0"
}
]
},
{
"name": "kubectl",
"buildsystem": "simple",
Expand All @@ -79,20 +52,7 @@
}
]
},
{
"name": "requirements",
"buildsystem": "simple",
"build-options": {
"build-args": [
"--share=network"
]
},
"build-commands": [
"pip3 install --prefix=${FLATPAK_DEST} xcffib xpybutil system_hotkey",
"pip3 install --prefix=${FLATPAK_DEST} pyyaml",
"pip3 install --prefix=${FLATPAK_DEST} docker"
]
},
"pypi-dependencies.json",
{
"name": "k3d",
"buildsystem": "simple",
Expand Down
1 change: 0 additions & 1 deletion flathub
Submodule flathub deleted from e57025
Loading

0 comments on commit 1af52e7

Please sign in to comment.