summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrimi2017-03-18 20:22:39 +0100
committergrimi2017-03-18 20:22:39 +0100
commitd133b204bc74550a8fc8cb4dfde9bfe83cb37c1b (patch)
tree9caf51dda885a8b2c43e5e9cb6649b638d54dd11
parent18b425f5eb1d3631e501415dba10801b469ea148 (diff)
downloadaur-d133b204bc74550a8fc8cb4dfde9bfe83cb37c1b.tar.gz
Update: 0.3.6.4, support for hooks added
-rw-r--r--.SRCINFO14
-rw-r--r--PKGBUILD19
-rw-r--r--hook-script.sh11
-rw-r--r--install.hook10
-rw-r--r--mime-archpkg.install9
-rw-r--r--mime-archpkg.sh114
-rw-r--r--remove.hook10
-rw-r--r--update.hook10
8 files changed, 142 insertions, 55 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 5e65635961b..b7d8dddebca 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = mime-archpkg
pkgdesc = mime type for archlinux packages
- pkgver = 0.3.6.3
- pkgrel = 2
+ pkgver = 0.3.6.4
+ pkgrel = 1
url = http://www.archlinux.org
install = mime-archpkg.install
arch = any
@@ -24,8 +24,12 @@ pkgbase = mime-archpkg
source = breeze.svgz
source = FaenzaFlattr2-Zephyr.svgz
source = elementary.svgz
+ source = install.hook
+ source = update.hook
+ source = remove.hook
+ source = hook-script.sh
sha256sums = e3fc45b1121fa845a245c115704715ec0b6a17860a507202cc5e1b02d01c797b
- sha256sums = 8b2af3bc0dc2b1e2c6d4390d051f6eebbce5cdeb4e7676f9e218d1ca276eed27
+ sha256sums = 9b3418ba5cb6acf32ea63bb9868554efcc0375b1f60aa8f244be38174c4f004c
sha256sums = fc9b1f43e5993e994707285d89e0da28be48b69046f4cac68578a8d0beef4653
sha256sums = a59eb69c6fcdf7e8017c2596384cff0635dee46e3db5949370de766273451a85
sha256sums = 0a4951fd15afb85229ee17629686f914b5e5ed0583846dde2350e0c247007975
@@ -38,6 +42,10 @@ pkgbase = mime-archpkg
sha256sums = 8af276bc4afecede207a6742a5ef9320155650364339af183f9d47e1614c30a7
sha256sums = 3f0177c13377ad94745ec0f0324ab5fb58eeccac4e4b56695ac0f2113fb4d5bb
sha256sums = a99c2b48796d6f8299867034242c69fbddef4c380df0b68a678ee2727c841f29
+ sha256sums = 814ec6d8b1318ffde6732c6ba468d66bc32534e79e486e4a4aaace0147b00d22
+ sha256sums = 372f44c4e8d5d9dcca7cf80bd2e2b8ef3874aad6f6051073f4e98839dd9ed531
+ sha256sums = 622ee32d6ddbcb46671dcc46c7b31f4b7d9d4083e416af0100ab4bcc9829bd06
+ sha256sums = 2c553f584aa0be02e5d62bc1b7af005b963124dba8987af9b13c5fbd8707fb2f
pkgname = mime-archpkg
diff --git a/PKGBUILD b/PKGBUILD
index e226719f372..fd67faf7300 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,17 +1,18 @@
# Contributor: grimi <grimi at poczta dot fm>
pkgname=mime-archpkg
-pkgver=0.3.6.3
-pkgrel=2
+pkgver=0.3.6.4
+pkgrel=1
pkgdesc="mime type for archlinux packages"
arch=('any')
url="http://www.archlinux.org"
license=('GPL')
depends=('shared-mime-info' 'gtk-update-icon-cache' 'librsvg' 'imagemagick')
install=${pkgname}.install
-source=(${pkgname}.{xml,sh} {hicolor,gnome,Tango,oxygen,nuoveXT2,Faenza,Faience,NITRUX,Numix,breeze,FaenzaFlattr2-Zephyr,elementary}.svgz)
+source=(${pkgname}.{xml,sh} {hicolor,gnome,Tango,oxygen,nuoveXT2,Faenza,Faience,NITRUX,Numix,breeze,FaenzaFlattr2-Zephyr,elementary}.svgz
+ {install,update,remove}.hook hook-script.sh)
sha256sums=('e3fc45b1121fa845a245c115704715ec0b6a17860a507202cc5e1b02d01c797b'
- '8b2af3bc0dc2b1e2c6d4390d051f6eebbce5cdeb4e7676f9e218d1ca276eed27'
+ '9b3418ba5cb6acf32ea63bb9868554efcc0375b1f60aa8f244be38174c4f004c'
'fc9b1f43e5993e994707285d89e0da28be48b69046f4cac68578a8d0beef4653'
'a59eb69c6fcdf7e8017c2596384cff0635dee46e3db5949370de766273451a85'
'0a4951fd15afb85229ee17629686f914b5e5ed0583846dde2350e0c247007975'
@@ -23,7 +24,11 @@ sha256sums=('e3fc45b1121fa845a245c115704715ec0b6a17860a507202cc5e1b02d01c797b'
'a26a86877f36d7ba61851659871ce6461a86b3004d3270b465931a611b64e0ef'
'8af276bc4afecede207a6742a5ef9320155650364339af183f9d47e1614c30a7'
'3f0177c13377ad94745ec0f0324ab5fb58eeccac4e4b56695ac0f2113fb4d5bb'
- 'a99c2b48796d6f8299867034242c69fbddef4c380df0b68a678ee2727c841f29')
+ 'a99c2b48796d6f8299867034242c69fbddef4c380df0b68a678ee2727c841f29'
+ '814ec6d8b1318ffde6732c6ba468d66bc32534e79e486e4a4aaace0147b00d22'
+ '372f44c4e8d5d9dcca7cf80bd2e2b8ef3874aad6f6051073f4e98839dd9ed531'
+ '622ee32d6ddbcb46671dcc46c7b31f4b7d9d4083e416af0100ab4bcc9829bd06'
+ '2c553f584aa0be02e5d62bc1b7af005b963124dba8987af9b13c5fbd8707fb2f')
package() {
@@ -31,6 +36,10 @@ package() {
install -Dm755 ${pkgname}.sh "${pkgdir}"/usr/bin/${pkgname}
install -d "${pkgdir}"/usr/share/${pkgname}
install -m644 *.svgz "${pkgdir}"/usr/share/${pkgname}/
+ install -Dm755 hook-script.sh "${pkgdir}"/usr/share/libalpm/scripts/${pkgname}
+ install -Dm644 install.hook "${pkgdir}"/usr/share/libalpm/hooks/${pkgname}-install.hook
+ install -Dm644 update.hook "${pkgdir}"/usr/share/libalpm/hooks/${pkgname}-update.hook
+ install -Dm644 remove.hook "${pkgdir}"/usr/share/libalpm/hooks/${pkgname}-remove.hook
}
diff --git a/hook-script.sh b/hook-script.sh
new file mode 100644
index 00000000000..bef1b8d1967
--- /dev/null
+++ b/hook-script.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+while read -r path; do
+ name="$(/usr/bin/basename "$path")"
+ case "$1" in
+ -i) /usr/bin/mime-archpkg -q -a "$name" ;;
+ -u) /usr/bin/mime-archpkg -q -u "$name" ;;
+ -r) /usr/bin/mime-archpkg -q -r "$name" ;;
+ esac
+done
+
diff --git a/install.hook b/install.hook
new file mode 100644
index 00000000000..8987baf544b
--- /dev/null
+++ b/install.hook
@@ -0,0 +1,10 @@
+[Trigger]
+Type = File
+Operation = Install
+Target = usr/share/icons/*/
+
+[Action]
+Description = Adding archpkg mimetypes icons...
+When = PostTransaction
+Exec = /usr/share/libalpm/scripts/mime-archpkg -i
+NeedsTargets
diff --git a/mime-archpkg.install b/mime-archpkg.install
index 08db0418da7..3377ad8c547 100644
--- a/mime-archpkg.install
+++ b/mime-archpkg.install
@@ -1,12 +1,7 @@
post_install() {
- mime-archpkg -u
+ mime-archpkg -a
}
-post_upgrade() {
- mime-archpkg -r
- mime-archpkg -u
-}
-
-post_remove() {
+pre_remove() {
mime-archpkg -r
}
diff --git a/mime-archpkg.sh b/mime-archpkg.sh
index f93c56c65c1..f75e91f4d81 100644
--- a/mime-archpkg.sh
+++ b/mime-archpkg.sh
@@ -5,66 +5,63 @@
declare MODE=usage
declare MYDIR=/usr/share/mime-archpkg
-declare MYTHEME="$2"
declare -r NAME=application-x-archpkg
+declare MUTE=0
-update() {
- local file theme elem suf abc
- local -i size
+add() {
+ # $1 = theme (if not present, add for all), $2 = [0|1] mute
+ local file theme elem suf abc one="$1"
+ local -i size mute=${2:-$MUTE}
local -a taba tab
if [[ -d $MYDIR ]]; then
cd "$MYDIR"
for file in *.svgz; do
theme="/usr/share/icons/${file%.svgz}"
- if [[ ${MYTHEME} ]]; then
- if [[ ${file%.svgz} != $MYTHEME ]]; then
+ if [[ $one ]]; then
+ if [[ ${file%.svgz} != $one ]]; then
continue
fi
fi
if [[ -f $theme/index.theme ]]; then
- echo ">> Updating mimetype icons in $theme... <<"
+ if [[ $mute -ne 1 ]]; then
+ echo ">> Adding mimetype icons for $theme... <<"
+ fi
taba=($(grep "\[.*mimetypes.*\]" "$theme/index.theme"|sed 's/\[//; s/\]//'))
for elem in "${taba[@]}"; do
tab=($(echo $elem|sed 's/\//\n/'))
- if [[ ${tab[0]/[0-9]/} != ${tab[0]} ]]; then
- if [[ -h $theme/${tab[0]} ]]; then # skip link
- continue
- fi
- if [[ ${tab[0]/@2x/} != ${tab[0]} ]]; then
- abc=${tab[0]/@2x/}
- size=${abc/x*/}
- size=$size*2
+ if [[ ${elem/scalable/} != ${elem} ]]; then
+ size=0
+ else
+ if [[ ${tab[0]/[0-9]/} != ${tab[0]} ]]; then
+ abc="${tab[0]}"
+ elif [[ ${tab[1]/[0-9]/} != ${tab[1]} ]]; then
+ abc="${tab[1]}"
else
- size=${tab[0]/x*/}
+ continue
fi
- elif [[ ${tab[1]/[0-9]/} != ${tab[1]} ]]; then
- if [[ -h $theme/${tab[1]} ]]; then # skip link
+ if [[ -h $theme/$abc ]]; then # skip link
continue
fi
- if [[ ${tab[1]/@2x/} != ${tab[1]} ]]; then
- abc=${tab[1]/@2x/}
+ if [[ ${abc/@2x/} != $abc ]]; then
+ abc=${abc/@2x/}
size=${abc/x*/}
size=$size*2
else
- size=${tab[1]/x*/}
+ size=${abc/x*/}
fi
- elif [[ ${elem/scalable/} != ${elem} ]]; then
- size=0
fi
- if [[ $size ]]; then
- if [[ $size -ne 0 ]]; then
- if [[ -f $theme/$elem/package.svg ]]; then
- suf=svg
- else
- suf=png
- fi
- convert -resize ${size}x${size} -background none "$file" /tmp/archpkg.$suf
- install -m644 /tmp/archpkg.$suf "$theme/$elem/$NAME.$suf"
+ if [[ $size -ne 0 ]]; then
+ if [[ -f $theme/$elem/package.svg ]]; then
+ suf=svg
else
- rsvg-convert -o /tmp/archpkg.svg -f svg "$file"
- install -m644 /tmp/archpkg.svg "$theme/$elem/$NAME.svg"
+ suf=png
fi
+ convert -resize ${size}x${size} -background none "$file" /tmp/archpkg.$suf
+ install -m644 /tmp/archpkg.$suf "$theme/$elem/$NAME.$suf"
+ else
+ rsvg-convert -o /tmp/archpkg.svg -f svg "$file"
+ install -m644 /tmp/archpkg.svg "$theme/$elem/$NAME.svg"
fi
done
if [[ -f $theme/icon-theme.cache ]]; then
@@ -76,18 +73,21 @@ update() {
}
remove() {
- local file theme
+ # $1 = theme (if not present, remove from all)
+ local file theme one="$1"
if [[ -d $MYDIR ]]; then
cd "$MYDIR"
for file in *.svgz; do
theme="/usr/share/icons/${file%.svgz}"
- if [[ ${MYTHEME} ]]; then
- if [[ ${file%.svgz} != $MYTHEME ]]; then
+ if [[ $one ]]; then
+ if [[ ${file%.svgz} != $one ]]; then
continue
fi
fi
if [[ -d $theme ]]; then
- echo ">> Removing installed mimetype icons from $theme... <<"
+ if [[ $MUTE -ne 1 ]]; then
+ echo ">> Removing installed mimetype icons from $theme... <<"
+ fi
find "$theme/" -type f -name $NAME.png -exec rm "{}" \;
find "$theme/" -type f -name $NAME.svg -exec rm "{}" \;
if [[ -f $theme/icon-theme.cache ]]; then
@@ -98,15 +98,49 @@ remove() {
fi
}
+update() {
+ # $1 = theme (if not present, update for all)
+ local file theme one="$1"
+ if [[ -d $MYDIR ]]; then
+ cd "$MYDIR"
+ for file in *.svgz; do
+ theme="/usr/share/icons/${file%.svgz}"
+ if [[ $one ]]; then
+ if [[ ${file%.svgz} != $one ]]; then
+ continue
+ fi
+ fi
+ if [[ -d $theme && -f $theme/index.theme ]]; then
+ if [[ $MUTE -ne 1 ]]; then
+ echo ">> Updating installed mimetype icons for $theme... <<"
+ fi
+ find "$theme/" -type f -name $NAME.png -exec rm "{}" \;
+ find "$theme/" -type f -name $NAME.svg -exec rm "{}" \;
+ add "${file%.svgz}" 1
+ fi
+ done
+ fi
+
+}
+
usage() {
- echo "USAGE: [-u|-r] [theme]"
+ echo "USAGE: [-q] <-a|-u|-r> [theme]"
+ echo " -q: don't comment action"
+ echo " -a: add archpkg mime icons"
echo " -u: update archpkg mime icons"
echo " -r: remove archpkg mime icons"
echo " theme: action only for entered theme"
}
+if [[ $1 == "-q" ]]; then
+ MUTE=1
+ shift
+fi
+
+
case "$1" in
+ -a) MODE=add ;;
-u) MODE=update ;;
-r) MODE=remove ;;
esac
@@ -116,6 +150,6 @@ if [[ $MODE != "usage" && $USER != "root" ]]; then
exit 1
fi
-eval $MODE
+$MODE "$2"
diff --git a/remove.hook b/remove.hook
new file mode 100644
index 00000000000..560e3b0c7a3
--- /dev/null
+++ b/remove.hook
@@ -0,0 +1,10 @@
+[Trigger]
+Type = File
+Operation = Remove
+Target = usr/share/icons/*/
+
+[Action]
+Description = Removing archpkg mimetypes icons...
+When = PreTransaction
+Exec = /usr/share/libalpm/scripts/mime-archpkg -r
+NeedsTargets
diff --git a/update.hook b/update.hook
new file mode 100644
index 00000000000..ae0f4e32715
--- /dev/null
+++ b/update.hook
@@ -0,0 +1,10 @@
+[Trigger]
+Type = File
+Operation = Upgrade
+Target = usr/share/icons/*/
+
+[Action]
+Description = Updating archpkg mimetypes icons...
+When = PostTransaction
+Exec = /usr/share/libalpm/scripts/mime-archpkg -u
+NeedsTargets