summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/include/contrib.defs5
-rw-r--r--pkg/linux/flatpak/fr.handbrake.HandBrakeCLI.json2
-rw-r--r--pkg/linux/flatpak/fr.handbrake.ghb.json5
-rw-r--r--pkg/linux/module.defs13
-rw-r--r--pkg/linux/module.rules33
-rwxr-xr-xscripts/create_flatpak_manifest.py154
6 files changed, 182 insertions, 30 deletions
diff --git a/make/include/contrib.defs b/make/include/contrib.defs
index 5223fb45e..3d2aa9074 100644
--- a/make/include/contrib.defs
+++ b/make/include/contrib.defs
@@ -10,6 +10,11 @@ CONTRIB.spec = $(if $(filter 1,$(BUILD.cross)),$(HOST.spec))
##
define import.CONTRIB.defs
##
+ ## keep a list of the enabled contrib packages
+ ##
+ CONTRIBS += $(1)
+
+ ##
## import gcc/g++ support mainly so we can force contrib choice of
## gcc executable, and debug/optimization flags.
##
diff --git a/pkg/linux/flatpak/fr.handbrake.HandBrakeCLI.json b/pkg/linux/flatpak/fr.handbrake.HandBrakeCLI.json
index ae64f64f5..5acef796f 100644
--- a/pkg/linux/flatpak/fr.handbrake.HandBrakeCLI.json
+++ b/pkg/linux/flatpak/fr.handbrake.HandBrakeCLI.json
@@ -5,9 +5,7 @@
"sdk": "org.gnome.Sdk",
"command": "HandBrakeCLI",
"finish-args": [
- /* Needs video */
"--filesystem=xdg-videos",
- /* Home */
"--filesystem=home"
],
"modules": [
diff --git a/pkg/linux/flatpak/fr.handbrake.ghb.json b/pkg/linux/flatpak/fr.handbrake.ghb.json
index 0b5aea05f..27947def0 100644
--- a/pkg/linux/flatpak/fr.handbrake.ghb.json
+++ b/pkg/linux/flatpak/fr.handbrake.ghb.json
@@ -5,16 +5,11 @@
"sdk": "org.gnome.Sdk",
"command": "ghb",
"finish-args": [
- /* X11 + XShm access */
"--share=ipc", "--socket=x11",
- /* Wayland access */
"--socket=wayland",
- /* Needed for dconf to work */
"--filesystem=xdg-run/dconf", "--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf", "--env=DCONF_USER_CONFIG_DIR=.config/dconf",
- /* Needs video */
"--filesystem=xdg-videos",
- /* Home */
"--filesystem=home"
],
"modules": [
diff --git a/pkg/linux/module.defs b/pkg/linux/module.defs
index ad4f559bc..b17aaa377 100644
--- a/pkg/linux/module.defs
+++ b/pkg/linux/module.defs
@@ -18,6 +18,15 @@ ifneq ($(PGP_ID),)
PGPSIGN = --gpg-sign=$(PGP_ID)
endif
+ifneq ($(FP_RUNTIME),)
+ FPRUNTIME = -r $(FP_RUNTIME)
+endif
+
+ifneq ($(HB_URL),)
+ifneq ($(HB_SHA256),)
+ FLATHUB_MANIFEST = $(PKG.gui.flathub.manifest) $(PKG.cli.flathub.manifest)
+endif
+endif
###############################################################################
@@ -48,8 +57,8 @@ PKG.rpm.stamp = $(PKG.out/).rpm.stamp
PKG.out.flatpak/ = $(PKG.out/)flatpak/
STAGE.out.flatpak/ = $(STAGE.out/)flatpak/
-PKG.src.flatpak = $(STAGE.out.flatpak/)handbrake.tar.bz2
-PKG.contrib.flatpak = $(STAGE.out.flatpak/)download.tgz
+PKG.gui.flathub.manifest = $(PKG.out.flatpak/)/fr.handbrake.ghb.json
+PKG.cli.flathub.manifest = $(PKG.out.flatpak/)/fr.handbrake.HandBrakeCLI.json
PKG.gui.manifest.flatpak = $(PKG.flatpak/)fr.handbrake.ghb.json
PKG.cli.manifest.flatpak = $(PKG.flatpak/)fr.handbrake.HandBrakeCLI.json
PKG.gui.build.flatpak = $(STAGE.out.flatpak/)$(HB.name)-$(HB.version)-$(BUILD.machine).build
diff --git a/pkg/linux/module.rules b/pkg/linux/module.rules
index 757698687..dcbc36289 100644
--- a/pkg/linux/module.rules
+++ b/pkg/linux/module.rules
@@ -1,4 +1,5 @@
-pkg.create.flatpak:: contrib.fetch $(PKG.gui.flatpak) $(PKG.cli.flatpak)
+pkg.create.flatpak:: contrib.fetch $(PKG.gui.flatpak) $(PKG.cli.flatpak) $(FLATHUB_MANIFEST)
+pkg.create.flathub:: $(FLATHUB_MANIFEST)
pkg.create.deb:: $(PKG.gui.deb) $(PKG.cli.deb)
pkg.create.rpm:: $(PKG.rpm.stamp)
pkg.create.src.deb:: $(PKG.src.deb.stamp)
@@ -9,7 +10,6 @@ DEBIAN_CHANGELOG_DATE = $(shell date -R)
#
# CLI Tar Package
#
-
$(PKG.cli.tar): | $(dir $(PKG.cli.tar))
$(PKG.cli.tar): | $(STAGE.out.cli/)
cd $(STAGE.out.cli/) && $(TAR.exe) cjf $(call fn.ABSOLUTE,$(PKG.cli.tar)) .
@@ -61,32 +61,23 @@ $(PKG.rpm.stamp): $(PKG.native.rpm.stamp)
#
# Flatpak binary package rules
#
-$(PKG.src.flatpak): $(PKG.src.tar.bz2)
- $(MKDIR.exe) -p $(STAGE.out.flatpak/)
- -$(RM.exe) -rf $(BUILD/).flatpak-builder
- $(CP.exe) $(PKG.src.tar.bz2) $(PKG.src.flatpak)
+$(PKG.gui.flathub.manifest):
+ $(SRC/)scripts/create_flatpak_manifest.py -a "$(HB_URL)" -s "$(HB_SHA256)" -t $(PKG.gui.manifest.flatpak) $(foreach m,$(CONTRIBS),-c "$(word 1,$($m.FETCH.url))" -s "$(word 1,$($m.FETCH.sha256))") $(FPRUNTIME) $(PKG.gui.flathub.manifest)
-$(PKG.contrib.flatpak):
- $(MKDIR.exe) -p $(STAGE.out.flatpak/)
- $(TAR.exe) -C $(SRC/) -czf $(PWD)/$(PKG.contrib.flatpak) download
+$(PKG.cli.flathub.manifest):
+ $(SRC/)scripts/create_flatpak_manifest.py -a "$(HB_URL)" -s "$(HB_SHA256)" -t $(PKG.cli.manifest.flatpak) $(foreach m,$(CONTRIBS),-c "$(word 1,$($m.FETCH.url))" -s "$(word 1,$($m.FETCH.sha256))") $(FPRUNTIME) $(PKG.cli.flathub.manifest)
-$(PKG.gui.flatpak): GNUmakefile $(PKG.src.flatpak) $(PKG.contrib.flatpak)
- make contrib.fetch
+$(PKG.gui.flatpak): GNUmakefile $(PKG.src.tar.bz2)
+ $(MKDIR.exe) -p $(STAGE.out.flatpak/)
$(MKDIR.exe) -p $(PKG.out.flatpak/)
- # Relative paths in the manifest are relative to the location
- # of the manifest. So put it where we have staged the files that
- # it needs.
- $(CP.exe) $(PKG.gui.manifest.flatpak) $(STAGE.out.flatpak/)fr.handbrake.ghb.json
+ $(SRC/)scripts/create_flatpak_manifest.py -a "$(abspath $(PKG.src.tar.bz2))" -t $(PKG.gui.manifest.flatpak) $(foreach m,$(CONTRIBS),-c "$(abspath $(CONTRIB.download/)$($m.FETCH.basename))") $(STAGE.out.flatpak/)fr.handbrake.ghb.json
flatpak-builder --force-clean $(PGPSIGN) --repo=$(PKG.repo.flatpak) $(PKG.gui.build.flatpak) $(STAGE.out.flatpak/)fr.handbrake.ghb.json
flatpak build-bundle $(PKG.repo.flatpak) $(PKG.gui.flatpak) fr.handbrake.ghb
-$(PKG.cli.flatpak): GNUmakefile $(PKG.src.flatpak) $(PKG.contrib.flatpak)
- make contrib.fetch
+$(PKG.cli.flatpak): GNUmakefile $(PKG.src.tar.bz2)
+ $(MKDIR.exe) -p $(STAGE.out.flatpak/)
$(MKDIR.exe) -p $(PKG.out.flatpak/)
- # Relative paths in the manifest are relative to the location
- # of the manifest. So put it where we have staged the files that
- # it needs.
- $(CP.exe) $(PKG.cli.manifest.flatpak) $(STAGE.out.flatpak/)fr.handbrake.HandBrakeCLI.json
+ $(SRC/)scripts/create_flatpak_manifest.py -a "$(abspath $(PKG.src.tar.bz2))" -t $(PKG.cli.manifest.flatpak) $(foreach m,$(CONTRIBS),-c "$(abspath $(CONTRIB.download/)$($m.FETCH.basename))") $(STAGE.out.flatpak/)fr.handbrake.HandBrakeCLI.json
flatpak-builder --force-clean $(PGPSIGN) --repo=$(PKG.repo.flatpak) $(PKG.cli.build.flatpak) $(STAGE.out.flatpak/)fr.handbrake.HandBrakeCLI.json
flatpak build-bundle $(PKG.repo.flatpak) $(PKG.cli.flatpak) fr.handbrake.HandBrakeCLI
diff --git a/scripts/create_flatpak_manifest.py b/scripts/create_flatpak_manifest.py
new file mode 100755
index 000000000..537191923
--- /dev/null
+++ b/scripts/create_flatpak_manifest.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+
+import types
+import os
+import sys
+import json
+import getopt
+import posixpath
+try:
+ from urlparse import urlsplit
+ from urllib import unquote
+except ImportError: # Python 3
+ from urllib.parse import urlsplit, unquote
+
+
+def url2filename(url):
+ path = urlsplit(url).path
+ return posixpath.basename(unquote(path))
+
+def islocal(url):
+ result = urlsplit(url)
+ return result.scheme == "" and result.netloc == ""
+
+class SourceType:
+ contrib = 1
+ archive = 2
+
+class SourceEntry:
+ def __init__(self, url, entry_type, sha256=None):
+ self.url = url
+ self.entry_type = entry_type
+ self.sha256 = sha256
+
+class FlatpakManifest:
+ def __init__(self, source_list, runtime, template=None):
+ if template != None:
+ with open(template, 'r') as fp:
+ self.manifest = json.load(fp)
+
+ self.finish_args = self.manifest["finish-args"]
+ self.modules = self.manifest["modules"]
+ self.hbmodule = self.modules[0]
+ self.sources = [None] * 2
+
+ self.hbmodule["sources"] = self.sources
+ else:
+ self.manifest = {}
+ self.finish_args = []
+ self.modules = []
+ self.hbmodule = {}
+ self.sources = [None] * 2
+
+ self.manifest["finish-args"] = self.finish_args
+ self.manifest["modules"] = self.modules
+ self.modules[0] = self.hbmodule
+ self.hbmodule["sources"] = self.sources
+
+ self.manifest["runtime-version"] = runtime
+
+ # create "shell" source to 'mkdir download'
+ source = {}
+ source["type"] = "shell"
+ source["commands"] = [ "mkdir -p download" ]
+ self.sources[1] = source
+
+ handbrake_found = False
+ for key, value in source_list.items():
+ source = {}
+ if islocal(value.url):
+ source["path"] = value.url
+ else:
+ if value.sha256 == "" or value.sha256 == None:
+ continue
+ source["url"] = value.url
+ source["sha256"] = value.sha256
+
+ if value.entry_type == SourceType.archive:
+ if handbrake_found:
+ print "Error: only one archive source permitted"
+ sys.exit(3)
+
+ source["type"] = "archive"
+ source["strip-components"] = 1
+ self.sources[0] = source
+ handbrake_found = True
+
+ elif value.entry_type == SourceType.contrib:
+ source["type"] = "file"
+ source["dest-filename"] = "download/" + url2filename(value.url)
+ self.sources.append(source)
+
+
+def usage():
+ print "create_flatpak_manifest [-a <archive>] [-c <contrib>] [-s <sha265>] [-t <template>] [-r <sdk-runtime-version] [-h] [<dst>]"
+ print " -a --archive - Main archive (a.k.a. HB sources)"
+ print " -c --contrib - Contrib download URL (can be repeated)"
+ print " -s --sha256 - sha256 of previous file on command line"
+ print " -t --template - Flatpak manifest template"
+ print " -r --runtime - Flatpak SDK runtime version"
+ print " -h --help - Show this message"
+
+if __name__ == "__main__":
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "a:c:s:t:r:h",
+ ["archive=", "contrib=", "sha265=",
+ "template=", "runtime=", "help"])
+ except getopt.GetoptError:
+ print "Error: Invalid option"
+ usage()
+ sys.exit(2)
+
+ if len(args) > 1:
+ usage()
+ exit(2)
+
+ source_list = {}
+ current_source = None
+ runtime = "3.28"
+ for opt, arg in opts:
+ if opt in ("-h", "--help"):
+ usage()
+ sys.exit()
+ elif opt in ("-a", "--archive"):
+ if arg != None and arg != "":
+ current_source = arg
+ source_list[arg] = SourceEntry(arg, SourceType.archive)
+ else:
+ current_source = None
+ elif opt in ("-c", "--contrib"):
+ if arg != None and arg != "":
+ current_source = arg
+ source_list[arg] = SourceEntry(arg, SourceType.contrib)
+ else:
+ current_source = None
+ elif opt in ("-s", "--sha256"):
+ if current_source != None:
+ source_list[current_source].sha256 = arg
+ elif opt in ("-t", "--template"):
+ template = arg
+ elif opt in ("-r", "--runtime"):
+ runtime = arg
+
+ if len(args) > 0:
+ dst = args[0]
+ else:
+ dst = None
+
+ manifest = FlatpakManifest(source_list, runtime, template)
+ if dst != None:
+ with open(dst, 'w') as fp:
+ json.dump(manifest.manifest, fp, ensure_ascii=False, indent=4)
+ else:
+ print json.dumps(manifest.manifest, ensure_ascii=False, indent=4)
+