void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

appstream-cache (1517B)


      1#!/bin/sh
      2#
      3# Updates the appstream AppData cache during installation of packages and
      4# deletes it when AppStream is removed
      5#
      6# Arguments:	$ACTION = [run/targets]
      7#		$TARGET = [post-install/post-remove]
      8#		$PKGNAME
      9#		$VERSION
     10#		$UPDATE = [yes/no]
     11#
     12ACTION="$1"
     13TARGET="$2"
     14PKGNAME="$3"
     15VERSION="$4"
     16UPDATE="$5"
     17
     18# The appstreamcli binary program.
     19APPSTREAMCLI="usr/bin/appstreamcli"
     20
     21# Paths that hold appstream metadata files
     22# the first one is the traditional one where most package reside but it is
     23# considered deprecated by upstream
     24# the other 3 are the ones used by upstream as noted in as-pool.c#L93-95
     25APPDATA_DATAPATHS="usr/share/appdata usr/share/app-info var/lib/app-info var/cache/app-info"
     26
     27# Location where the cache files go when they are generated they are most
     28# of the time compressed with gvz extension
     29APPSTREAM_CACHE="var/cache/app-info/gv"
     30
     31case "$ACTION" in
     32targets)
     33	echo "post-install post-remove"
     34	;;
     35run)
     36	case "$TARGET" in
     37	post-install|post-remove)
     38		if [ $PKGNAME = "AppStream" -a $TARGET = "post-remove" ]; then
     39			for f in ${APPSTREAM_CACHE}/*; do
     40				rm -f ${f}
     41			done
     42			echo "Removing AppStream cache..."
     43			rmdir ${APPSTREAM_CACHE}
     44			exit 0
     45		fi
     46
     47		if [ ! -x "$APPSTREAMCLI" ]; then
     48			exit 0
     49		fi
     50
     51		for path in ${APPDATA_DATAPATHS}; do
     52			APPSTREAM_PATHS="${APPSTREAM_PATHS} --datapath ${path}"
     53		done
     54
     55		echo "Updating AppStream cache..."
     56		${APPSTREAMCLI} refresh-cache --force ${APPSTREAM_PATHS} --cachepath ${APPSTREAM_CACHE}
     57		;;
     58	esac
     59	;;
     60*)
     61	exit 1
     62	;;
     63esac
     64
     65exit 0