summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4305ea473836d036d09f0c843c0407a3c4e539a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Maintainer: begin-theadventure <begin-thecontact.ncncb at dralias dot com>

_pkgname=youtube-dl-gui
pkgname=$_pkgname-bin
pkgver=2.5.4
pkgrel=1
pkgdesc="A cross-platform GUI for youtube-dl made in Electron and node.js (binary release)"
url="https://github.com/StefanLobbenmeier/youtube-dl-gui"
license=('AGPL3')
arch=('x86_64')
depends=('libappindicator-gtk3' 'libnotify' 'libxss' 'libxtst')
provides=($_pkgname)
conflicts=($_pkgname)
_appimage=Open-Video-Downloader-$pkgver.AppImage
source=("$url/releases/download/v$pkgver/$_appimage")
sha256sums=('9ead12d7de796ef2f259f7bd09f84e9adbaccc6227b8d5a599478327df184a39')

_fix_permissions() (
  target=$1

  if [[ -L "$target" ]]; then
    return 0
  fi

  if [[ -d "$target" || -x "$target" ]]; then
    chmod 755 "$target"
    return 0
  fi

  if [[ -f "$target" ]]; then
    chmod 644 "$target"
    return 0
  fi

  echo "Unrecognizable filesystem entry: $target" >&2
  return 1
)

prepare() {
  # Extract the AppImage
  chmod +x "./$_appimage"
  "./$_appimage" --appimage-extract
  # Edit the shortcut
  mv squashfs-root/open-video-downloader.desktop "$srcdir/$_pkgname.desktop"
  sed -i -E "s|Name=Open-Video-Downloader|Name=Open Video Downloader|g" $_pkgname.desktop
  sed -i -E "s|Exec=AppRun --no-sandbox %U|Exec=$_pkgname %U|g" $_pkgname.desktop
  sed -i '/X-AppImage-Version/d' $_pkgname.desktop
  echo "Keywords=$_pkgname;youtubedlgui;yt-dl-gui;ytdlgui;" >> $_pkgname.desktop
  # Remove the updater
  rm squashfs-root/resources/app-update.yml
}

package() {
  # Create folders
  mkdir -p "$pkgdir/opt/$_pkgname" "$pkgdir/usr/bin"
  # Install
  install -Dm644 $_pkgname.desktop -t "$pkgdir/usr/share/applications"
  cd squashfs-root
  install -Dm644 usr/share/icons/hicolor/0x0/apps/open-video-downloader.png "$pkgdir/usr/share/icons/hicolor/1024x1024/apps/$pkgname.png"
  rm -dr usr AppRun open-video-downloader open-video-downloader.png .DirIcon
  ln -s /opt/$_pkgname/open-video-downloader.bin "$pkgdir/usr/bin/$_pkgname"
  mv * "$pkgdir/opt/$_pkgname"
  # Fix permissions
  find "$pkgdir/opt/$_pkgname" | while read -r target; do
    _fix_permissions "$target"
  done
}