summaryrefslogtreecommitdiff
path: root/create-hook
blob: 70adc95824461a759888fe65e6a558ff2d4fa1a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

input='/usr/share/libalpm/hooks/90-linux.hook'
target=$(
  grep -m1 'Target = ' "${input}" | \
    cut -d'=' -f2 | \
    sed 's|\s\+||g'
)
sed '
  /Description =/{
    s/=\s*/= Test permissions for /
    a When = PreTransaction\
Exec = /usr/bin/bash -c '"'"'[ -w /'"${target}"' ]'"'"'\
AbortOnFail
    q
  }
' "${input}"