# Maintainer: Alex S. # Contributor: Jonathon Fernyhough # Contributor: Andrew Shark # Hardware support is limited. # See https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=56878&p=456990#p456924 pkgname=davinci-resolve _pkgname=resolve pkgver=15.2.3 pkgrel=2 pkgdesc='Professional A/V post-production software suite from Blackmagic Design' arch=('x86_64') url="https://www.blackmagicdesign.com/" license=('Commercial') depends=('glu' 'gtk2' 'gstreamer' 'libpng12' 'lib32-libpng12' 'ocl-icd' 'openssl-1.0' 'opencl-driver' 'qt4' 'qt5-base' 'qt5-svg' 'qt5-webkit' 'qt5-webengine' 'qt5-websockets') # TODO check that all of these needed. Also explore `ldd ./installer` and `ldd resolve`. makedepends=('libarchive') options=('!strip') install=${pkgname}.install conflicts=('davinci-resolve-beta' 'davinci-resolve-studio' 'davinci-resolve-studio-beta') # This was originally written by Daniel Bermond in blackmagic-decklink-sdk pkgbuild # It is sufficient to just replace _downloadid to correspond new release version # It can be obtained from chromium -> Developer Tools -> Network -> XHR and Fetch -> the next one after latest-version _downloadid='89633cfa41e142c9bdc1724fbb5ff873' # dr 15.2.3 _referid='4f929ebb222c4ce68567cbe38d735ffe' _srcurl="https://www.blackmagicdesign.com/api/register/us/download/${_downloadid}" source=("DaVinci_Resolve_${pkgver}_Linux.zip"::"$_srcurl") sha256sums=('d0123739c68b3b03565a1478625a3ebafbb067eb5631a7c7b0a41726f5d5c854') _useragent="User-Agent: Mozilla/5.0 (X11; Linux ${CARCH}) \ AppleWebKit/537.36 (KHTML, like Gecko) \ Chrome/70.0.3538.77 \ Safari/537.36" _reqjson="{ \ \"platform\": \"Linux\", \ \"country\": \"us\", \ \"firstname\": \"Arch\", \ \"lastname\": \"Linux\", \ \"email\": \"someone@archlinux.org\", \ \"phone\": \"202-555-0194\", \ \"state\": \"New York\", \ \"city\": \"AUR\", \ \"hasAgreedToTerms\": true, \ \"product\": \"Desktop Video ${pkgver} SDK\" \ }" _reqjson="$( printf '%s' "$_reqjson" | sed 's/[[:space:]]\+/ /g')" _useragent="$(printf '%s' "$_useragent" | sed 's/[[:space:]]\+/ /g')" _useragent_escaped="${_useragent// /\\ }" DLAGENTS=("https::/usr/bin/curl \ -gqb '' -C - --retry 3 --retry-delay 3 \ -H Host:\ sw.blackmagicdesign.com \ -H Upgrade-Insecure-Requests:\ 1 \ -H ${_useragent_escaped} \ -H Accept:\ text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 \ -H Accept-Language:\ en-US,en;q=0.9 \ -o %o \ --compressed \ $(curl \ -s \ -H 'Host: www.blackmagicdesign.com' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Origin: https://www.blackmagicdesign.com' \ -H "$_useragent" \ -H 'Content-Type: application/json;charset=UTF-8' \ -H "Referer: https://www.blackmagicdesign.com/support/download/${_referid}/Linux" \ -H 'Accept-Encoding: gzip, deflate, br' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Authority: www.blackmagicdesign.com' \ -H 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \ --data-binary "$_reqjson" \ --compressed \ "$_srcurl" )" ) PKGEXT=".pkg.tar" # for maintainers # Order of the official installation procedure: # You download .zip from blackmagicdesign site. # Then you unpack it. Two files are inside: pdf and run. # In pdf there is a link to dedicated centos iso installer with dr, which we may use for tests. # .run file is actually AppImage. It starts AppRun file, which calls "installer" executable. # For some reason they made it binary, so we cannot see what else it does. But here is order of its actions: # - run scripts/pre_install.sh # - copy all files except AppRun and .DirIcon to /opt/resolve # - run scripts/post_install.sh # So this pkgbuild is remake of these actions. prepare() { rm -rf "${srcdir}/unpacked" # to prevent removed from distribution files to be copied to new versions builds mkdir -p "${srcdir}"/unpacked bsdtar x -f DaVinci_Resolve_${pkgver}_Linux.run -C "${srcdir}"/unpacked } package() { # pre_install.sh reimplementation start INSTALL_DIR="${pkgdir}"/opt/resolve # USER_UID=0 # USER_HOME="${pkgdir}"/root # Installing Resolve as root may cause issues with file permissions when running Resolve as a non-root user. # from pdf manual. Check for correctness. # mkdir -m 0775 -p "$INSTALL_DIR" # this is from original script # chown $USER_UID "$INSTALL_DIR" -R # this is from original script # We will instead give 777 permissions to specific dirs to allow users to write there but deny touching package files # Alternatively, we could require user to be in users group and change group of files/dirs to users to allow writing mkdir -p "$INSTALL_DIR" # Permissions tweaks are done below # pre_install.sh reimplementation end # ./installer reimplementation start cp -rpT "${srcdir}"/unpacked "${pkgdir}/opt/resolve" rm "${pkgdir}"/opt/resolve/{AppRun,.DirIcon,installer,installer.dat,filelist.txt} rm "${pkgdir}"/opt/resolve/graphics/watermark.png # clutter used by gui installer rm "${pkgdir}"/opt/resolve/docs/Welcome.txt # clutter used by gui installer rm "${pkgdir}"/opt/resolve/scripts/{pre_install.sh,post_install.sh,uninstall.sh,script.update} # not needed # ./installer reimplementation end # post_install.sh reimplementation start # COMMON_DATA_DIR=/var/davinci/resolve # never used RESOLVE_APP_NAME=com.blackmagicdesign.resolve # DBUS_SERVICE_DIR=/usr/share/dbus-1/services # never used FILES=( "${pkgdir}"/opt/resolve/share/DaVinciResolve.desktop "${pkgdir}"/opt/resolve/share/DaVinciResolveInstaller.desktop "${pkgdir}"/opt/resolve/share/DaVinciResolveCaptureLogs.desktop "${pkgdir}"/opt/resolve/share/DaVinciResolvePanelSetup.desktop "${pkgdir}"/opt/resolve/share/DaVinciResolve.directory "${pkgdir}"/opt/resolve/share/DaVinciResolve.menu ) ABSOLUTE_INSTALL_DIR="/opt/resolve" for file in "${FILES[@]}"; do sed -i -e "s:RESOLVE_INSTALL_LOCATION:${ABSOLUTE_INSTALL_DIR}:g" "$file" done mkdir -p "${pkgdir}"/usr/share/applications/ mkdir -p "${pkgdir}"/usr/share/desktop-directories/ mkdir -p "${pkgdir}"/etc/xdg/menus/applications-merged mv "${pkgdir}"/opt/resolve/share/DaVinciResolve.desktop "${pkgdir}"/usr/share/applications/${RESOLVE_APP_NAME}.desktop sed -i 's/Revolutionary new tools for editing, visual effects, color correction and professional audio post production, all in a single application!/Professional non-linear editing/g' "${pkgdir}"/usr/share/applications/${RESOLVE_APP_NAME}.desktop # my own patch echo "Categories=AudioVideo;AudioVideoEditing;" >> "${pkgdir}"/usr/share/applications/${RESOLVE_APP_NAME}.desktop # my own patch rm "${pkgdir}"/opt/resolve/share/DaVinciResolveInstaller.desktop rm "${pkgdir}"/opt/resolve/graphics/DV_Uninstall.png mv "${pkgdir}"/opt/resolve/share/DaVinciResolveCaptureLogs.desktop "${pkgdir}"/usr/share/applications/${RESOLVE_APP_NAME}-CaptureLogs.desktop mv "${pkgdir}"/opt/resolve/share/DaVinciResolvePanelSetup.desktop "${pkgdir}"/usr/share/applications/${RESOLVE_APP_NAME}-Panels.desktop mv "${pkgdir}"/opt/resolve/share/DaVinciResolve.directory "${pkgdir}"/usr/share/desktop-directories/${RESOLVE_APP_NAME}.directory mv "${pkgdir}"/opt/resolve/share/DaVinciResolve.menu "${pkgdir}"/etc/xdg/menus/applications-merged/${RESOLVE_APP_NAME}.menu sed -i 's/com.blackmagicdesign.resolve-Installer.desktop<\/Filename>//g' "${pkgdir}"/etc/xdg/menus/applications-merged/${RESOLVE_APP_NAME}.menu mkdir -p "${pkgdir}"/usr/share/icons/hicolor/128x128 mkdir -p "${pkgdir}"/usr/share/mime/packages XDG_DATA_DIRS="${pkgdir}"/usr/share xdg-icon-resource install --size 128 "${INSTALL_DIR}"/graphics/DV_Resolve.png DaVinci-Resolve xdg-icon-resource install --size 128 "${INSTALL_DIR}"/graphics/DV_ResolveProj.png DaVinci-ResolveProj xdg-icon-resource install --size 128 --context mimetypes "${INSTALL_DIR}"/graphics/DV_ResolveProj.png application-x-resolveproj # xdg-mime install --novendor "${INSTALL_DIR}"/share/resolve.xml # not needed, handled by pacman # instead we just copy resolve.xml cp "${INSTALL_DIR}"/share/resolve.xml "${pkgdir}"/usr/share/mime/packages mkdir -p "${pkgdir}"/usr/lib/udev/rules.d/ echo 'SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="096e", MODE="0666"' > "${pkgdir}"/usr/lib/udev/rules.d/75-davincipanel.rules echo 'SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="1edb", MODE="0666"' > "${pkgdir}"/usr/lib/udev/rules.d/75-sdx.rules PANEL_DRIVER_DIR="${pkgdir}/usr/lib" mkdir -p "${pkgdir}"/usr/lib # already created in udev rules, but just to be sure tar -xf "${INSTALL_DIR}"/share/panels/dvpanel-framework-linux-x86_64.tgz libDaVinciPanelAPI.so # I have not used a lib folder from archive mv libDaVinciPanelAPI.so "${PANEL_DRIVER_DIR}" rm "${INSTALL_DIR}"/share/panels/dvpanel-framework-linux-x86_64.tgz # From original: # # We install the default app associations here, because xdg-mime is buggy in centos6 # install_default_application ${RESOLVE_APP_NAME}.desktop application/x-resolveproj # # We install the default application system-wide. Per user default-app preferences are buggy for Centos6 # install_default_application() # { # $1 is .desktop # $2 is mime/type # DEFAULT_MIME_FILE="/usr/share/applications/defaults.list" # grep -v "$2=" $DEFAULT_MIME_FILE > ${DEFAULT_MIME_FILE}.new 2> /dev/null # if ! grep "[Default Applications]" ${DEFAULT_MIME_FILE}.new > /dev/null; then # echo "[Default Applications]" >> ${DEFAULT_MIME_FILE}.new # fi # echo $2=$1 >> ${DEFAULT_MIME_FILE}.new # mv ${DEFAULT_MIME_FILE}.new $DEFAULT_MIME_FILE # } # # We do not need this defaults.list in Arch, because it is deprecated and out of current desktop spec. # See this: https://specifications.freedesktop.org/mime-apps-spec/latest/ # This is from original script # LIST_OF_USER_FILES=( # "configs" # "easyDCP" # "logs" # "Developer" # "DolbyVision" # "LUT" # ".LUT" # ".license" # ".crashreport" # "Resolve Disk Database" # "Fairlight" # "Media" # ) # # for file in "${LIST_OF_USER_FILES[@]}"; do # mkdir -p -m 0775 "$INSTALL_DIR/$file" # chown $USER_UID "$INSTALL_DIR/$file" # done # This is ours # We will create dirs, to which dr wants to write and allow everybody to write there # I have added only directories, that I am sure dr really wants to write to. # If you notice that dr unable to write to some dir, please contact maintainer and he will add it to writable dirs. LIST_OF_WRITABLE_DIRS=( "configs" # needed # "easyDCP" "logs" # needed # "Developer" # "DolbyVision" "LUT" # needed ".LUT" # needed # ".license" # ".crashreport" "Resolve Disk Database" # needed "Fairlight" # needed "Media" # not necessary, but can be used ) for dir in "${LIST_OF_WRITABLE_DIRS[@]}"; do mkdir -m 0777 -p "${pkgdir}/opt/${_pkgname}/$dir" done # to actually watch what else files dr may create, we need to allow it to create files in install dir. # chmod 777 "${pkgdir}/opt/${_pkgname}" # for maintainers backup=( opt/resolve/configs/config.dat opt/resolve/configs/log-conf.xml opt/resolve/DolbyVision/config.bin ) # We will keep default configs in unwritable share for simplicity of restoring. See restore-opt-resolve.sh cp "${INSTALL_DIR}"/share/default-config-linux.dat "${INSTALL_DIR}"/configs/config.dat chmod 777 "${INSTALL_DIR}"/configs/config.dat # allow write to normal user cp "${INSTALL_DIR}"/share/log-conf.xml "${INSTALL_DIR}"/configs/log-conf.xml chmod 777 "${INSTALL_DIR}"/configs/log-conf.xml # allow write to normal user mkdir "${INSTALL_DIR}"/DolbyVision cp "${INSTALL_DIR}"/share/default_cm_config.bin "${INSTALL_DIR}"/DolbyVision/config.bin chmod 777 "${INSTALL_DIR}"/DolbyVision/config.bin # allow write to normal user # post_install.sh reimplementation end # for simplicity of launching I'll create symlink mkdir "${pkgdir}"/usr/bin/ ln -s "/opt/resolve/bin/resolve" "${pkgdir}"/usr/bin/davinci-resolve # export BMD_PLUGIN_PATH=$CURRENT_DIR/libs/plugins # from AppRun, used by ./installer. Do not know its effect. }