summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a001626db34127bbcb314b7fac41197200dad0fb (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
# Maintainer: dszryan
pkgname=pacmanity-git
pkgver=r53.e181875
pkgrel=1
epoch=2
pkgdesc="Keeps a list of installed packages in a Gist at your GitHub account"
arch=('x86_64' 'i686')
url="https://github.com/dszryan/${pkgname/-git/}"
license=('GPL')
#groups=('ALPM' 'Backup' 'gist' 'pacman')
depends=('pacman>=5.0' 'gist>=4.5.0')
makedepends=('git')
conflicts=('pacmanity')
source=("${pkgname/-git/}::git+https://github.com/dszryan/${pkgname/-git/}.git#branch=master")
sha256sums=('SKIP')

pkgver() {
  cd "$srcdir/${pkgname/-git/}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  echo "A list of installed packages will be automatically maintained"
  echo "by Pacmanity in a private Gist at your GitHub account."

  echo -e "\n- Step 1: Log in to Gist using your GitHub account:"
  [[ -f ~/.gist ]] || gist --login # dont save login details in package, due to securiry concerns

  # if file is present, assume it is maanged externally (via a build system)
  [[ -r /etc/pacmanity ]] && source /etc/pacmanity
  if [ -z "$GIST_ID" ]; then
    echo -e "\n- Step 2: Save list of currently installed packages to Gist:"
    GIST_URL=$(echo . | gist -p -f $HOSTNAME.pacmanity -d "$HOSTNAME: List of installed packages")
    GIST_ID=$(echo "$GIST_URL" | sed "s|https://gist.github.com/||g")
    echo "GIST_ID=$GIST_ID" > "$srcdir/gist_id"
  else
    "$srcdir/${pkgname/-git/}/pacmanity.sh"
    GIST_URL=https://gist.github.com/$GIST_ID
  fi

  echo "An automatically mantained list of installed packages"
  echo "has been successfully created in your GitHub Gist."
  echo "Visit https://gist.github.com or the direct link below:"
  echo "$GIST_URL"
}

package() {
  # copy gist_id if exists
  [[ -r "$srcdir/gist_id" ]] && (mkdir -p "$pkgdir/etc" && install -m644 "$srcdir/gist_id" "$pkgdir/etc/pacmanity")

  # copy required script files
  mkdir -p "$pkgdir/usr/lib/pacmanity" "$pkgdir/usr/share/libalpm/hooks"
  install -m774 "$srcdir/${pkgname/-git/}/pacmanity.sh"   "$pkgdir/usr/lib/pacmanity/pacmanity.sh"
  install -m664 "$srcdir/${pkgname/-git/}/pacmanity.hook" "$pkgdir/usr/share/libalpm/hooks/zzz-pacmanity.hook"
}