summaryrefslogtreecommitdiff
path: root/community/gnuradio/gnuradio.install
blob: 1ba012bf9818f4e5ed6a6214e09e82b3ad837f49 (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

# clean up for anyone silly enough to run this as root

# it would be great if pkgname and not just pkgver was passed in the arg list

_pkg='gnuradio'
_cpython='cpython-34'

post_upgrade() {
  while read _f; do
    if [[ "${_f:(-3)}" != ".py" ]]; then
      continue
    fi
    if [[ ! -f "$_f" ]]; then
      continue
    fi
    if [[ -e "${_f}c" ]]; then
      rm -f "${_f}c"
    fi
    if [[ -e "${_f}o" ]]; then
      rm -f "${_f}o"
    fi
    _thisdir="$(dirname "$_f")/__pycache__"
    if [[ ! -d "$_thisdir" ]]; then
      continue
    fi
    _thisfile="$(basename "$_f")"
    _thisfile="${_thisfile/%.py/.${_cpython}.py}"
    if [[ -e "${_thisdir}/${_thisfile}c" ]]; then
      rm -f "${_thisdir}/${_thisfile}c"
    fi
    if [[ -e "${_thisdir}/${_thisfile}o" ]]; then
      rm -f "${_thisdir}/${_thisfile}o"
    fi
    # no good way to test for empty dir
    # would be 25% faster if there were
    rmdir --ignore-fail-on-non-empty "$_thisdir" &> /dev/null
  done <<<  "$(pacman -Qql $_pkg | grep '\.py$')"

  update-desktop-database -q
}

post_install() {
  post_upgrade $1
}

pre_remove() {
  post_upgrade $1
}