From f027e82e76dd258583d3903e09e14ff31b26835f Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 17 Feb 2018 17:01:46 +0100 Subject: [PATCH] avidemux: rewrite derivation This drastically reduces the complexity of the `avidemux` derivation and adds QT5 support (see #33248). Rather than invoking `cmake` over preconfigured hooks, it's much easier to use the `bootStrap.bash` script provided by the developers to do the installation tasks. Furthermore this script makes it way easier to configure which parts of `avidemux` should be used (e.g. CLI-only) or without the plugins. In order to create a CLI-only instance you can simply override the derivation: ``` avidemux.override { withQT = false; } ``` It's possible to set the default executable as well (`avidemux` creates a `avidemux_qt5` and `avidemux_cli` executable by default): ``` avidemux.override { default = "cli"; # default is `qt5` } ``` The GTK support has been dropped entirely since it was originally broken in our system and can't be built ATM. Other distros such as ArchLinux don't support GTK anymore (see https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/avidemux#n64) --- .../video/avidemux/bootstrap_logging.patch | 26 +++ pkgs/applications/video/avidemux/default.nix | 156 ++++++------------ pkgs/applications/video/avidemux/wrapper.nix | 24 --- pkgs/top-level/all-packages.nix | 6 +- 4 files changed, 82 insertions(+), 130 deletions(-) create mode 100644 pkgs/applications/video/avidemux/bootstrap_logging.patch delete mode 100644 pkgs/applications/video/avidemux/wrapper.nix diff --git a/pkgs/applications/video/avidemux/bootstrap_logging.patch b/pkgs/applications/video/avidemux/bootstrap_logging.patch new file mode 100644 index 00000000000..8f45251d26c --- /dev/null +++ b/pkgs/applications/video/avidemux/bootstrap_logging.patch @@ -0,0 +1,26 @@ +diff --git a/bootStrap.bash b/bootStrap.bash +index 646a5e048..6429199ba 100644 +--- a/bootStrap.bash ++++ b/bootStrap.bash +@@ -4,6 +4,7 @@ + # + # By default we use qt5 now + # ++set -e # hard fail if something fails + packages_ext="" + rebuild=0 + do_core=1 +@@ -66,10 +67,10 @@ Process() + fi + cd $BUILDDIR + cmake $COMPILER $PKG $FAKEROOT $QT_FLAVOR -DCMAKE_EDIT_COMMAND=vim $INSTALL_PREFIX $EXTRA $BUILD_QUIRKS $ASAN $DEBUG -G "$BUILDER" $SOURCEDIR || fail cmakeZ +- make $PARAL >& /tmp/log$BUILDDIR || fail "make, result in /tmp/log$BUILDDIR" +- if [ "x$PKG" != "x" ] ; then ++ make $PARAL ++ if [ "x$PKG" != "x" ] ; then + $FAKEROOT_COMMAND make package DESTDIR=$FAKEROOT_DIR/tmp || fail package +- fi ++ fi + # we need the make install so that other packcges can be built against this one + make install DESTDIR=$FAKEROOT_DIR + } diff --git a/pkgs/applications/video/avidemux/default.nix b/pkgs/applications/video/avidemux/default.nix index 76b42acef3e..62b819c600c 100644 --- a/pkgs/applications/video/avidemux/default.nix +++ b/pkgs/applications/video/avidemux/default.nix @@ -1,6 +1,7 @@ { stdenv, lib, fetchurl, cmake, pkgconfig, lndir , zlib, gettext, libvdpau, libva, libXv, sqlite -, yasm, freetype, fontconfig, fribidi, gtk3, qt4 +, yasm, freetype, fontconfig, fribidi +, makeWrapper, libXext, mesa_glu, qttools, qtbase , alsaLib , withX265 ? true, x265 , withX264 ? true, x264 @@ -12,9 +13,18 @@ , withFAAD ? true, faad2 , withOpus ? true, libopus , withVPX ? true, libvpx +, withQT ? true +, withCLI ? true +, default ? "qt5" +, withPlugins ? true }: -let +assert withQT -> qttools != null && qtbase != null; +assert default != "qt5" -> default == "cli"; +assert !withQT -> default != "qt5"; + +stdenv.mkDerivation rec { + name = "avidemux-${version}"; version = "2.7.0"; src = fetchurl { @@ -22,112 +32,54 @@ let sha256 = "1bf4l9qwxq3smc1mx5pybydc742a4qqsk17z50j9550d9iwnn7gy"; }; - common = { - inherit version src; + patches = [ ./dynamic_install_dir.patch ./bootstrap_logging.patch ]; - patches = [ ./dynamic_install_dir.patch ]; + nativeBuildInputs = [ yasm cmake pkgconfig ]; + buildInputs = [ + zlib gettext libvdpau libva libXv sqlite fribidi fontconfig + freetype alsaLib libXext mesa_glu makeWrapper + ] ++ lib.optional withX264 x264 + ++ lib.optional withX265 x265 + ++ lib.optional withXvid xvidcore + ++ lib.optional withLAME lame + ++ lib.optional withFAAC faac + ++ lib.optional withVorbis libvorbis + ++ lib.optional withPulse libpulseaudio + ++ lib.optional withFAAD faad2 + ++ lib.optional withOpus libopus + ++ lib.optionals withQT [ qttools qtbase ] + ++ lib.optional withVPX libvpx; - enableParallelBuilding = false; + buildCommand = '' + unpackPhase + cd "$sourceRoot" + patchPhase - nativeBuildInputs = [ cmake pkgconfig yasm ]; - buildInputs = [ zlib gettext libvdpau libva libXv sqlite fribidi fontconfig freetype alsaLib ] - ++ lib.optional withX264 x264 - ++ lib.optional withX265 x265 - ++ lib.optional withXvid xvidcore - ++ lib.optional withLAME lame - ++ lib.optional withFAAC faac - ++ lib.optional withVorbis libvorbis - ++ lib.optional withPulse libpulseaudio - ++ lib.optional withFAAD faad2 - ++ lib.optional withOpus libopus - ++ lib.optional withVPX libvpx - ; + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${libXext}/lib" + ${stdenv.shell} bootStrap.bash \ + --with-core \ + ${if withQT then "--with-qt" else "--without-qt"} \ + ${if withCLI then "--with-cli" else "--without-cli"} \ + ${if withPlugins then "--with-plugins" else "--without-plugins"} - meta = { - homepage = http://fixounet.free.fr/avidemux/; - description = "Free video editor designed for simple video editing tasks"; - maintainers = with stdenv.lib.maintainers; [ viric abbradar ]; - platforms = with stdenv.lib.platforms; linux; - license = stdenv.lib.licenses.gpl2; - }; - }; + mkdir $out + cp -R install/usr/* $out - core = stdenv.mkDerivation (common // { - name = "avidemux-${version}"; + for i in $out/bin/*; do + wrapProgram $i \ + --set ADM_ROOT_DIR $out \ + --prefix LD_LIBRARY_PATH ":" "${libXext}/lib" + done + ln -s "$out/bin/avidemux3_${default}" "$out/bin/avidemux" - preConfigure = '' - cd avidemux_core - ''; - }); + fixupPhase + ''; - buildPlugin = args: stdenv.mkDerivation (common // { - name = "avidemux-${args.pluginName}-${version}"; - - buildInputs = (args.buildInputs or []) ++ common.buildInputs ++ [ lndir ]; - - cmakeFlags = [ "-DPLUGIN_UI=${args.pluginUi}" ]; - - passthru.isUi = args.isUi or false; - - buildCommand = '' - unpackPhase - cd "$sourceRoot" - patchPhase - - mkdir $out - lndir ${core} $out - - export cmakeFlags="$cmakeFlags -DAVIDEMUX_SOURCE_DIR=$(pwd)" - - for i in ${toString (args.buildDirs or [])} avidemux_plugins; do - ( cd "$i" - cmakeConfigurePhase - buildPhase - installPhase - ) - done - - fixupPhase - ''; - - meta = common.meta // args.meta or {}; - }); - -in { - avidemux_core = core; - - avidemux_cli = buildPlugin { - pluginName = "cli"; - pluginUi = "CLI"; - isUi = true; - buildDirs = [ "avidemux/cli" ]; - }; - - avidemux_qt4 = buildPlugin { - pluginName = "qt4"; - buildInputs = [ qt4 ]; - pluginUi = "QT4"; - isUi = true; - buildDirs = [ "avidemux/qt4" ]; - }; - - avidemux_gtk = buildPlugin { - pluginName = "gtk"; - buildInputs = [ gtk3 ]; - pluginUi = "GTK"; - isUi = true; - buildDirs = [ "avidemux/gtk" ]; - # Code seems unmaintained. - meta.broken = true; - }; - - avidemux_common = buildPlugin { - pluginName = "common"; - pluginUi = "COMMON"; - }; - - avidemux_settings = buildPlugin { - pluginName = "settings"; - pluginUi = "SETTINGS"; + meta = with stdenv.lib; { + homepage = http://fixounet.free.fr/avidemux/; + description = "Free video editor designed for simple video editing tasks"; + maintainers = with maintainers; [ viric abbradar ma27 ]; + platforms = platforms.linux; + license = licenses.gpl2; }; } diff --git a/pkgs/applications/video/avidemux/wrapper.nix b/pkgs/applications/video/avidemux/wrapper.nix deleted file mode 100644 index 7f05b81baec..00000000000 --- a/pkgs/applications/video/avidemux/wrapper.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ symlinkJoin, avidemux_unwrapped, makeWrapper -# GTK version is broken upstream, see https://bugzilla.redhat.com/show_bug.cgi?id=1244340 -, withUi ? "qt4" -}: - -let ui = builtins.getAttr "avidemux_${withUi}" avidemux_unwrapped; in - -assert ui.isUi; - -symlinkJoin { - name = "avidemux-${withUi}-${ui.version}"; - - paths = [ ui avidemux_unwrapped.avidemux_common avidemux_unwrapped.avidemux_settings ]; - - buildInputs = [ makeWrapper ]; - - postBuild = '' - for i in $out/bin/*; do - wrapProgram $i --set ADM_ROOT_DIR $out - done - ''; - - meta = ui.meta; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7f0827e4839..6bda20ba31b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14530,12 +14530,10 @@ with pkgs; autopanosiftc = callPackage ../applications/graphics/autopanosiftc { }; - avidemux_unwrapped = callPackage ../applications/video/avidemux { - libva = libva-full; # also wants libva-x11 + avidemux = libsForQt5.callPackage ../applications/video/avidemux { + libva = libva-full; }; - avidemux = callPackage ../applications/video/avidemux/wrapper.nix { }; - avogadro = callPackage ../applications/science/chemistry/avogadro { eigen = eigen2; };