Skip to content

Commit

Permalink
flatpak: allow building with QSV enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jstebbins committed Mar 7, 2019
1 parent bdb6e72 commit 3062c43
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
5 changes: 4 additions & 1 deletion pkg/linux/flatpak/fr.handbrake.ghb.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
{
"name": "handbrake",
"no-autogen": true,
"config-opts": ["--flatpak", "--disable-gtk-update-checks"],
"config-opts": [
"--flatpak",
"--disable-gtk-update-checks"
],
"builddir": true,
"post-install": ["install -d /app/extensions"],
"sources": [
Expand Down
4 changes: 4 additions & 0 deletions pkg/linux/module.defs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ ifneq ($(PGP_ID),)
PGPSIGN = --gpg-sign=$(PGP_ID)
endif

ifeq (1,$(FEATURE.qsv))
FPQSV = -q
endif

ifneq ($(FP_RUNTIME),)
FPRUNTIME = -r $(FP_RUNTIME)
endif
Expand Down
8 changes: 4 additions & 4 deletions pkg/linux/module.rules
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ $(PKG.rpm.stamp): $(PKG.native.rpm.stamp)
#
$(PKG.gui.flathub.manifest):
$(MKDIR.exe) -p $(PKG.out.flatpak/)
$(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)
$(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -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.cli.flathub.manifest):
$(MKDIR.exe) -p $(PKG.out.flatpak/)
$(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)
$(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -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.tar.bz2)
$(MKDIR.exe) -p $(STAGE.out.flatpak/)
$(MKDIR.exe) -p $(PKG.out.flatpak/)
$(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
$(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -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 --default-branch=$(PKG.flatpak.branch) --disable-cache --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.flatpak.branch)

$(PKG.cli.flatpak): GNUmakefile $(PKG.src.tar.bz2)
$(MKDIR.exe) -p $(STAGE.out.flatpak/)
$(MKDIR.exe) -p $(PKG.out.flatpak/)
$(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
$(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -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 --default-branch=$(PKG.flatpak.branch) --disable-cache --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 $(PKG.flatpak.branch)

Expand Down
17 changes: 13 additions & 4 deletions scripts/create_flatpak_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ def __init__(self, url, entry_type, sha256=None):
self.sha256 = sha256

class FlatpakManifest:
def __init__(self, source_list, runtime, template=None):
def __init__(self, source_list, runtime, qsv, template=None):
if template != None:
with open(template, 'r') as fp:
self.manifest = json.load(fp, object_pairs_hook=OrderedDict)

self.finish_args = self.manifest["finish-args"]
self.modules = self.manifest["modules"]
self.hbmodule = self.modules[len(self.modules) - 1]
self.hbconfig = self.hbmodule["config-opts"]
self.sources = [None]

self.hbmodule["sources"] = self.sources
Expand All @@ -54,10 +55,14 @@ def __init__(self, source_list, runtime, template=None):
self.manifest["modules"] = self.modules
self.modules[0] = self.hbmodule
self.hbmodule["sources"] = self.sources
self.hbconfig = [None]

if runtime != None:
self.manifest["runtime-version"] = runtime

if qsv:
self.hbconfig.append("--enable-qsv");

handbrake_found = False
for key, value in source_list.items():
source = OrderedDict()
Expand Down Expand Up @@ -93,13 +98,14 @@ def usage():
print " -s --sha256 - sha256 of previous file on command line"
print " -t --template - Flatpak manifest template"
print " -r --runtime - Flatpak SDK runtime version"
print " -q --qsv - Build with Intel QSV support"
print " -h --help - Show this message"

if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "a:c:s:t:r:h",
opts, args = getopt.getopt(sys.argv[1:], "a:c:s:t:r:qh",
["archive=", "contrib=", "sha265=",
"template=", "runtime=", "help"])
"template=", "runtime=", "qsv", "help"])
except getopt.GetoptError:
print "Error: Invalid option"
usage()
Expand All @@ -112,6 +118,7 @@ def usage():
source_list = OrderedDict()
current_source = None
runtime = None
qsv = 0
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
Expand All @@ -135,13 +142,15 @@ def usage():
template = arg
elif opt in ("-r", "--runtime"):
runtime = arg
elif opt in ("-q", "--qsv"):
qsv = 1;

if len(args) > 0:
dst = args[0]
else:
dst = None

manifest = FlatpakManifest(source_list, runtime, template)
manifest = FlatpakManifest(source_list, runtime, qsv, template)
if dst != None:
with open(dst, 'w') as fp:
json.dump(manifest.manifest, fp, ensure_ascii=False, indent=4)
Expand Down

0 comments on commit 3062c43

Please sign in to comment.