summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4cc283bc9da647362c2dad7d806ff7fb8d815379 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>
# Contributor:
#
# PKGBUILD reference: https://wiki.archlinux.org/index.php/PKGBUILD

pkgname=bash-it-git
pkgver=r1716.64abb64
pkgrel=1
pkgdesc='A community Bash framework'
arch=('any')
url='https://github.com/Bash-it/bash-it'
license=('custom:undecided')
depends=('bash' 'coreutils' 'curl' 'p7zip')
makedepends=('git')
optdepends=(
  'autojump: plugin'
  'base-devel: `makefile` completion'
  'docker: plugin'
  'git: theme integration, multiple alias/completion/plugin modules'
  'hub: completion, plugin'
  'irssi: integration'
  'java-environment-common: plugin'
  'python: plugin'
  'python3: plugin, `django` completion, `proxy` plugin'
  'packer: completion'
  'ruby: theme integration, plugin'
  'ruby-bundler: alias, completion'
  'rbenv: plugin'
  'thefuck: aliases'
  'wget: `browser` plugin'
)
conflicts=('bash-it')
options=('libtool' 'staticlibs' '!strip')
install="${pkgname}.install"
source=(
  "${pkgname}::git+https://github.com/Bash-it/bash-it.git"
  'LICENSE'
  'custom.lib.bash.shim'
  'install.sh.wrapper'
)
sha512sums=(
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
)

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

package() {
  # All upstream-provided files go into the /usr hierarchy
  mkdir -p "${pkgdir}/usr/lib/${pkgname}"
  mkdir -p "${pkgdir}/usr/share/${pkgname}"
  mkdir -p "${pkgdir}/usr/share/doc/${pkgname}"
  mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}"

  cp --preserve=mode -t \
    "${pkgdir}/usr/share/licenses/${pkgname}" \
    "${srcdir}/LICENSE"

  cp -r --preserve=mode -t "${pkgdir}/usr/lib/${pkgname}" \
    "${srcdir}/${pkgname}"/{bash_it,install,uninstall}.sh \
    "${srcdir}/${pkgname}"/{aliases,completion,custom,lib} \
    "${srcdir}/${pkgname}"/{plugins,themes}

  # Copy warning shim to `lib/custom.bash`
  cp --preserve=mode \
    "${srcdir}/custom.lib.bash.shim" \
    "${pkgdir}/usr/lib/${pkgname}/lib/custom.bash"

  # `.editorconfig` is not meant to be user-editable
  cp -r --preserve=mode -t "${pkgdir}/usr/share/${pkgname}" \
    "${srcdir}/${pkgname}/.editorconfig" \
    "${srcdir}/${pkgname}/install.sh" \
    "${srcdir}/${pkgname}/template"

  # Copy wrapper for `install.sh`
  cp --preserve=mode \
    "${srcdir}/install.sh.wrapper" \
    "${pkgdir}/usr/share/${pkgname}/install.sh"

  cp --preserve=mode -t "${pkgdir}/usr/share/doc/${pkgname}" \
    "${srcdir}/${pkgname}"/*.md

  # This is where things get a little tricky.
  # 
  # Bash-it requires a particular structure where
  # both user-customizable and upstream-provided scripts
  # share the same directories.
  #
  # This was a deliberate design decision on bash-it's end;
  # however, this design reaches its limits when we use
  # a package manager.
  #
  # We're going to apply a bit of symlink trickery so
  # Bash-it plays nice with makepkg/pacman while
  # staying true to the following goals:
  #
  # 1. Protect custom user files when upgrading
  # 2. Still allow multiple users to have their own
  #    custom scripts under /home
  # 3. Avoid patching upstream files

  # Install user-specific parts into a "home factory",
  # which will serve as a template for ~/.bash_it later on
  _factorydir="${pkgdir}/usr/share/${pkgname}/home_factory/.bash_it"

  # For aliases, completions, and plugins, create symlinks
  # to the respective `available` directories
  for _file_type in aliases completion plugins; do
    mkdir -p "${_factorydir}/${_file_type}"
    ln -fns "/usr/lib/${pkgname}/${_file_type}/available" \
      "${_factorydir}/${_file_type}/"
  done

  # Create replacement for `lib/custom.bash`
  mkdir -p "${_factorydir}/custom/lib"

  # Create symlink to `custom/example.bash`
  ln -fs \
    "/usr/lib/${pkgname}/custom/example.bash" \
    "${_factorydir}/custom/"

  # Create symlinks to remaining files
  ln -fs \
    "/usr/lib/${pkgname}"/{bash_it,install,uninstall}.sh \
    "/usr/lib/${pkgname}"/{lib,themes} \
    "/usr/share/${pkgname}"/{.editorconfig,template} \
    "/usr/share/doc/${pkgname}"/{CONTRIBUTING,README}.md \
    "${_factorydir}/"
}