]> granicus.if.org Git - handbrake/commitdiff
flatpak: add Intel MediaSDK plugin
authorJohn Stebbins <jstebbins.hb@gmail.com>
Sun, 24 Feb 2019 20:53:56 +0000 (13:53 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 7 Mar 2019 21:59:35 +0000 (13:59 -0800)
Defines a flatpak manifest that is used to download and build all the
dependencies for MediaSDK 19.1.pre2.  These are built into a flatpak
plugin that can be installed independently from the main HandBrake flatpak.

When the plugin is installed, HandBrake gains the ability to do QSV
encoding with the latest MediaSDK and VA drivers.

When HandBrake is configured with '--flatpak --enable-qsv' and
'make pkg.create.flatpak' is run, both the HandBrake flatpak and the
MediaSDK plugin will be built.

The name of the MediaSDK plugin file is:
fr.handbrake.plugin.IntelMediaSDK-$(HB.version)-$(HB.machine).flatpak

I've also changed the the name of the HandBrake flatpak file to conform
better with flatpak naming:
fr.handbrake.ghb-$(HB.version)-$(HB.machine).flatpak
fr.handbrake.HandBrakeCLI-$(HB.version)-$(HB.machine).flatpak

pkg/linux/flatpak/fr.handbrake.plugin.IntelMediaSDK.json [new file with mode: 0644]
pkg/linux/module.defs
pkg/linux/module.rules
scripts/create_flatpak_manifest.py

diff --git a/pkg/linux/flatpak/fr.handbrake.plugin.IntelMediaSDK.json b/pkg/linux/flatpak/fr.handbrake.plugin.IntelMediaSDK.json
new file mode 100644 (file)
index 0000000..86e7125
--- /dev/null
@@ -0,0 +1,106 @@
+{
+    "app-id": "fr.handbrake.plugin.IntelMediaSDK",
+    "branch": "1",
+    "runtime": "fr.handbrake.ghb",
+    "runtime-version": "development",
+    "sdk": "org.freedesktop.Sdk//18.08",
+    "build-extension": true,
+    "separate-locales": false,
+    "appstream-compose": false,
+    "modules": [
+        {
+            "name": "intel-gmmlib",
+            "sources": [
+                {
+                    "type": "archive",
+                    "url": "https://github.com/intel/gmmlib/archive/intel-gmmlib-18.4.1.tar.gz",
+                    "sha256": "7970a8ae4e16efb98f38fbbc0346eea03227fc4462a9bd8e8077277cc3430a84"
+                }
+            ],
+            "buildsystem": "cmake",
+            "builddir": true,
+            "config-opts": [
+                "-DCMAKE_BUILD_TYPE=Release"
+            ],
+            "build-options": {
+                "prefix" : "/app/extensions/IntelMediaSDK",
+                "make-args": [
+                    "VERBOSE=1"
+                ],
+                "make-install-args": [
+                    "VERBOSE=1"
+                ]
+            }
+        },
+        {
+            "name": "libva",
+            "sources": [
+                {
+                    "type": "archive",
+                    "url": "https://github.com/intel/libva/releases/download/2.4.0/libva-2.4.0.tar.bz2",
+                    "sha256": "99263056c21593a26f2ece812aee6fe60142b49e6cd46cb33c8dddf18fc19391"
+                }
+            ],
+            "no-autogen": true,
+            "config-opts": ["--with-drivers-path=/app/extensions/IntelMediaSDK/lib/dri"],
+            "build-options": {
+                "prefix" : "/app/extensions/IntelMediaSDK"
+            }
+        },
+        {
+            "name": "libva-utils",
+            "sources": [
+                {
+                    "type": "archive",
+                    "url": "https://github.com/intel/libva-utils/releases/download/2.4.0/libva-utils-2.4.0.tar.bz2",
+                    "sha256": "5b7d1954b40fcb2c0544be20125c71a0852049715ab85a3e8aba60434a40c6b3"
+                }
+            ],
+            "no-autogen": true,
+            "build-options": {
+                "prefix" : "/app/extensions/IntelMediaSDK",
+                "prepend-pkg-config-path": "/app/extensions/IntelMediaSDK/lib/pkgconfig"
+            }
+        },
+        {
+            "name": "intel-media-driver",
+            "sources": [
+                {
+                    "type": "archive",
+                    "url": "https://github.com/VCDP/media-driver/archive/intel-media-kbl-19.1.0.tar.gz",
+                    "sha256": "d494f8cf395e9996beda9846afdc736998de6978481aab0e483d818a0c836d66"
+                }
+            ],
+            "buildsystem": "cmake",
+            "builddir": true,
+            "config-opts": [
+                "-DCMAKE_BUILD_TYPE=Release"
+            ],
+            "build-options": {
+                "prefix" : "/app/extensions/IntelMediaSDK",
+                "prepend-pkg-config-path": "/app/extensions/IntelMediaSDK/lib/pkgconfig"
+            }
+        },
+        {
+            "name": "mediasdk",
+            "sources": [
+                {
+                    "type": "archive",
+                    "url": "https://github.com/Intel-Media-SDK/MediaSDK/archive/MSS-KBL-2019-R1.tar.gz",
+                    "sha256": "ec3d23a2ca4f18144b52d2257b3050ba0f9a98f2688418dd40e8335a215be765"
+                }
+            ],
+            "buildsystem": "cmake",
+            "builddir": true,
+            "config-opts": [
+                "-DCMAKE_BUILD_TYPE=Release",
+                "-DMFX_ENABLE_SW_FALLBACK=OFF"
+            ],
+            "build-options": {
+                "prefix" : "/app/extensions/IntelMediaSDK",
+                "prepend-pkg-config-path": "/app/extensions/IntelMediaSDK/lib/pkgconfig"
+            }
+        }
+    ]
+}
+
index 954fbd4522fb4d73b12aaf4a1a31f888b5d59f44..939a62410c0d436af47d55d31210105732602eb2 100644 (file)
@@ -18,30 +18,11 @@ else ifeq ($(HB.repo.branch),)
 else
     PKG.rpm.hb.version = $(tag).$(HB.repo.shorthash).$(HB.repo.branch)
 endif
-ifeq ($(HB.repo.type),release)
-    PKG.flatpak.branch = stable
-else
-    PKG.flatpak.branch = development
-endif
 
 ifneq ($(PGP_ID),)
     PGPSIGN = --gpg-sign=$(PGP_ID)
 endif
 
-ifeq (1,$(FEATURE.qsv))
-    FPQSV = -q
-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
-
 ###############################################################################
 
 PKG.cli.tar = $(PKG.out.abs/)$(HB.name)-$(HB.version)-$(BUILD.machine)_CLI.tar.gz
@@ -55,7 +36,6 @@ PKG.rpm.src.tar.bz2 = $(STAGE.out.src.abs/)rpm/$(PKG.rpm.basename).tar.bz2
 STAGE.out.rpm.src/ = $(STAGE.out.src.abs/)rpm/
 
 PKG.debian  = $(PKG.in.abs/)linux/debian
-PKG.flatpak/  = $(PKG.in.abs/)linux/flatpak/
 PKG.cli.deb = $(PKG.out.abs/)$(HB.name)-$(HB.debversion)-Ubuntu_CLI_$(BUILD.machine).deb
 PKG.gui.deb = $(PKG.out.abs/)$(HB.name)-$(HB.debversion)-Ubuntu_GUI_$(BUILD.machine).deb
 PKG.deb.basename = $(HB.name.lower)-$(HB.debversion)
@@ -69,18 +49,6 @@ PKG.gui.tmp.deb = $(PKG.out.abs/)$(HB.name.lower)-gtk_$(HB.debversion)_$(PKG.deb
 PKG.native.rpm.stamp = $(RPM.out/).rpm.stamp
 PKG.rpm.stamp = $(PKG.out.abs/).rpm.stamp
 
-PKG.out.flatpak/ = $(PKG.out.abs/)flatpak/
-STAGE.out.flatpak/ = $(STAGE.out.abs/)flatpak/
-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
-PKG.cli.build.flatpak = $(STAGE.out.flatpak/)$(HB.name)CLI-$(HB.version)-$(BUILD.machine).build
-PKG.repo.flatpak = $(PKG.out.flatpak/)$(HB.name)-Flatpak.repo
-PKG.cli.flatpak = $(PKG.out.flatpak/)$(HB.name)CLI-$(HB.version)-$(BUILD.machine).flatpak
-PKG.gui.flatpak = $(PKG.out.flatpak/)$(HB.name)-$(HB.version)-$(BUILD.machine).flatpak
-
 PKG.gui.native.rpm = $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name.lower)-gui-$(PKG.rpm.hb.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
 PKG.cli.native.rpm = $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name.lower)-cli-$(PKG.rpm.hb.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
 
@@ -91,6 +59,66 @@ RPM.out/ = $(RPM.out)/
 RPMROOT.out  = $(STAGE.out.abs/)rpmroot
 RPMROOT.out/ = $(RPMROOT.out)/
 
+###############################################################################
+# Flatpak
+###############################################################################
+
+ifeq (1,$(FEATURE.qsv))
+    FPQSV = -q
+endif
+
+ifneq ($(FP_RUNTIME),)
+    FPRUNTIME = -r $(FP_RUNTIME)
+endif
+
+ifeq ($(HB.repo.type),release)
+    PKG.branch.flatpak = stable
+else
+    PKG.branch.flatpak = development
+endif
+PKG.plugin.version.flatpak = 1
+
+PKG.flatpak/  = $(PKG.in.abs/)linux/flatpak/
+
+PKG.out.flatpak/ = $(PKG.out.abs/)flatpak/
+STAGE.out.flatpak/ = $(STAGE.out.abs/)flatpak/
+
+PKG.repo.flatpak = $(PKG.out.flatpak/)$(HB.name)-Flatpak.repo
+
+PKG.gui.name.flatpak = fr.handbrake.ghb
+PKG.gui.manifest.flathub = $(PKG.out.flatpak/)$(PKG.gui.name.flatpak).json
+PKG.gui.template.flatpak = $(PKG.flatpak/)$(PKG.gui.name.flatpak).json
+PKG.gui.manifest.flatpak = $(STAGE.out.flatpak/)$(PKG.gui.name.flatpak).json
+PKG.gui.build.flatpak = $(STAGE.out.flatpak/)$(PKG.gui.name.flatpak)-$(HB.version)-$(BUILD.machine).build
+PKG.gui.flatpak = $(PKG.out.flatpak/)$(PKG.gui.name.flatpak)-$(HB.version)-$(BUILD.machine).flatpak
+
+PKG.cli.name.flatpak = fr.handbrake.HandBrakeCLI
+PKG.cli.manifest.flathub = $(PKG.out.flatpak/)$(PKG.cli.name.flatpak).json
+PKG.cli.template.flatpak = $(PKG.flatpak/)$(PKG.cli.name.flatpak).json
+PKG.cli.manifest.flatpak = $(STAGE.out.flatpak/)$(PKG.cli.name.flatpak).json
+PKG.cli.build.flatpak = $(STAGE.out.flatpak/)$(PKG.cli.name.flatpak)-$(HB.version)-$(BUILD.machine).build
+PKG.cli.flatpak = $(PKG.out.flatpak/)$(PKG.cli.name.flatpak)-$(HB.version)-$(BUILD.machine).flatpak
+
+PKG.mediasdk.name.flatpak = fr.handbrake.plugin.IntelMediaSDK
+PKG.mediasdk.manifest.flathub = $(PKG.out.flatpak/)$(PKG.mediasdk.name.flatpak).json
+PKG.mediasdk.template.flatpak = $(PKG.flatpak/)$(PKG.mediasdk.name.flatpak).json
+PKG.mediasdk.manifest.flatpak = $(STAGE.out.flatpak/)$(PKG.mediasdk.name.flatpak).json
+PKG.mediasdk.build.flatpak = $(STAGE.out.flatpak/)$(PKG.mediasdk.name.flatpak)-$(HB.version)-$(BUILD.machine).build
+PKG.mediasdk.flatpak = $(PKG.out.flatpak/)$(PKG.mediasdk.name.flatpak)-$(HB.version)-$(BUILD.machine).flatpak
+
+PKG.all.flatpak = $(PKG.gui.flatpak) $(PKG.cli.flatpak)
+ifeq (1,$(FEATURE.qsv))
+    PKG.all.flatpak += $(PKG.mediasdk.flatpak)
+endif
+
+PKG.plugins.flatpak = $(PKG.mediasdk.flatpak)
+
+ifneq ($(HB_URL),)
+ifneq ($(HB_SHA256),)
+       FLATHUB_MANIFEST = $(PKG.gui.manifest.flathub) $(PKG.cli.manifest.flathub)
+endif
+endif
+
 ###############################################################################
 
 BUILD.out += $(PKG.src.tar)
index 11b536c8a935c3aaf2b88f43285b96210e97e438..3fbbbe60c3df936cc3c79ecad479c7189c81eaad 100644 (file)
@@ -1,4 +1,5 @@
-pkg.create.flatpak:: contrib.fetch $(PKG.gui.flatpak) $(PKG.cli.flatpak) $(FLATHUB_MANIFEST)
+pkg.create.flatpak:: contrib.fetch $(PKG.all.flatpak)
+pkg.create.plugins.flatpak:: $(PKG.plugins.flatpak)
 pkg.create.flathub:: $(FLATHUB_MANIFEST)
 pkg.create.deb:: $(PKG.gui.deb) $(PKG.cli.deb)
 pkg.create.rpm:: $(PKG.rpm.stamp)
@@ -61,27 +62,37 @@ $(PKG.rpm.stamp): $(PKG.native.rpm.stamp)
 #
 # Flatpak binary package rules
 #
-$(PKG.gui.flathub.manifest):
+$(PKG.gui.manifest.flathub):
        $(MKDIR.exe) -p $(PKG.out.flatpak/)
-       $(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)
+       $(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -a "$(HB_URL)" -s "$(HB_SHA256)" -t $(PKG.gui.template.flatpak) $(foreach m,$(CONTRIBS),-c "$(word 1,$($m.FETCH.url))" -s "$(word 1,$($m.FETCH.sha256))") $(FPRUNTIME) $(PKG.gui.manifset.flathub)
 
-$(PKG.cli.flathub.manifest):
+$(PKG.cli.manifest.flathub):
        $(MKDIR.exe) -p $(PKG.out.flatpak/)
-       $(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)
+       $(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -a "$(HB_URL)" -s "$(HB_SHA256)" -t $(PKG.cli.template.flatpak) $(foreach m,$(CONTRIBS),-c "$(word 1,$($m.FETCH.url))" -s "$(word 1,$($m.FETCH.sha256))") $(FPRUNTIME) $(PKG.cli.manifest.flathub)
 
-$(PKG.gui.flatpak): GNUmakefile $(PKG.src.tar.bz2)
+$(PKG.gui.flatpak): GNUmakefile $(PKG.gui.template.flatpak) $(PKG.src.tar.bz2)
        $(MKDIR.exe) -p $(STAGE.out.flatpak/)
        $(MKDIR.exe) -p $(PKG.out.flatpak/)
-       $(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)
+       $(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -a "$(abspath $(PKG.src.tar.bz2))" -t $(PKG.gui.template.flatpak) $(foreach m,$(CONTRIBS),-c "$(abspath $(CONTRIB.download/)$($m.FETCH.basename))") $(PKG.gui.manifest.flatpak)
+       flatpak-builder --default-branch=$(PKG.branch.flatpak) --disable-cache --force-clean $(PGPSIGN) --repo=$(PKG.repo.flatpak) $(PKG.gui.build.flatpak) $(PKG.gui.manifest.flatpak)
+       flatpak build-bundle $(PKG.repo.flatpak) $(PKG.gui.flatpak) $(PKG.gui.name.flatpak) $(PKG.branch.flatpak)
 
-$(PKG.cli.flatpak): GNUmakefile $(PKG.src.tar.bz2)
+$(PKG.cli.flatpak): GNUmakefile $(PKG.cli.template.flatpak) $(PKG.src.tar.bz2)
        $(MKDIR.exe) -p $(STAGE.out.flatpak/)
        $(MKDIR.exe) -p $(PKG.out.flatpak/)
-       $(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)
+       $(SRC/)scripts/create_flatpak_manifest.py $(FPQSV) -a "$(abspath $(PKG.src.tar.bz2))" -t $(PKG.cli.template.flatpak) $(foreach m,$(CONTRIBS),-c "$(abspath $(CONTRIB.download/)$($m.FETCH.basename))") $(PKG.cli.manifest.flatpak)
+       flatpak-builder --default-branch=$(PKG.branch.flatpak) --disable-cache --force-clean $(PGPSIGN) --repo=$(PKG.repo.flatpak) $(PKG.cli.build.flatpak) $(PKG.cli.manifest.flatpak)
+       flatpak build-bundle $(PKG.repo.flatpak) $(PKG.cli.flatpak) $(PKG.cli.name.flatpak) $(PKG.branch.flatpak)
+
+$(PKG.mediasdk.flatpak): GNUmakefile $(PKG.mediasdk.template.flatpak) $(PKG.gui.flatpak)
+       $(MKDIR.exe) -p $(STAGE.out.flatpak/)
+       $(MKDIR.exe) -p $(PKG.out.flatpak/)
+       $(SRC/)scripts/create_flatpak_manifest.py -p -r $(PKG.branch.flatpak) -t $(PKG.mediasdk.template.flatpak) $(PKG.mediasdk.manifest.flatpak)
+       -flatpak --user remove --noninteractive $(PKG.gui.name.flatpak)//$(PKG.branch.flatpak)
+       flatpak --user install --noninteractive $(PKG.gui.flatpak)
+       flatpak-builder --default-branch=$(PKG.branch.flatpak) --disable-cache --force-clean $(PGPSIGN) --repo=$(PKG.repo.flatpak) $(PKG.mediasdk.build.flatpak) $(PKG.mediasdk.manifest.flatpak)
+       flatpak build-bundle --runtime $(PKG.repo.flatpak) $(PKG.mediasdk.flatpak) $(PKG.mediasdk.name.flatpak) $(PKG.plugin.version.flatpak)
+       -flatpak --user remove --noninteractive $(PKG.gui.name.flatpak)//$(PKG.branch.flatpak)
 
 #
 # Debian binary package rules
index 2d1373576577cbc5f15ee5aa75ea043982a30cd0..b119bd9b7006fba807476d225b1f5070c0b3301d 100755 (executable)
@@ -32,6 +32,18 @@ class SourceEntry:
         self.entry_type = entry_type
         self.sha256     = sha256
 
+class FlatpakPluginManifest:
+    def __init__(self, runtime, template=None):
+        if template != None:
+            with open(template, 'r') as fp:
+                self.manifest = json.load(fp, object_pairs_hook=OrderedDict)
+
+        else:
+            self.manifest    = OrderedDict()
+
+        if runtime != None:
+            self.manifest["runtime-version"] = runtime
+
 class FlatpakManifest:
     def __init__(self, source_list, runtime, qsv, template=None):
         if template != None:
@@ -99,13 +111,14 @@ def usage():
     print "     -t --template   - Flatpak manifest template"
     print "     -r --runtime    - Flatpak SDK runtime version"
     print "     -q --qsv        - Build with Intel QSV support"
+    print "     -p --plugin     - Manifest if for a HandBrake flatpak plugin"
     print "     -h --help       - Show this message"
 
 if __name__ == "__main__":
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "a:c:s:t:r:qh",
+        opts, args = getopt.getopt(sys.argv[1:], "a:c:s:t:r:qph",
             ["archive=", "contrib=", "sha265=",
-             "template=", "runtime=", "qsv", "help"])
+             "template=", "runtime=", "qsv", "plugin", "help"])
     except getopt.GetoptError:
         print "Error: Invalid option"
         usage()
@@ -118,6 +131,7 @@ if __name__ == "__main__":
     source_list = OrderedDict()
     current_source = None
     runtime = None
+    plugin = 0
     qsv = 0
     for opt, arg in opts:
         if opt in ("-h", "--help"):
@@ -144,13 +158,19 @@ if __name__ == "__main__":
             runtime = arg
         elif opt in ("-q", "--qsv"):
             qsv = 1;
+        elif opt in ("-p", "--plugin"):
+            plugin = 1;
 
     if len(args) > 0:
         dst = args[0]
     else:
         dst = None
 
-    manifest = FlatpakManifest(source_list, runtime, qsv, template)
+    if plugin:
+        manifest = FlatpakPluginManifest(runtime, template)
+    else:
+        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)