#!/bin/bash # ------- # File: llxcfg-cpkg-apt # Description: Simple frontend to llxcfg-cpkg from apt scripts # Author: Luis Garcia Gisbert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- set -e # ---- # main # ---- CPKG="/usr/share/lliurex/llxcfg-backend/llxcfg-cpkg-backend" [ -x "$CPKG" ] || exit 0 rc=0 case $1 in post-dpkg) $CPKG --verbose "$1" "$2" || rc=$? ;; pre-dpkg) PKG_LIST="$2" if [ "$PKG_LIST" -a -s "$PKG_LIST" ] ; then # read list of cpkgs to desintall # 1. build list of ".list" files in /var/lib/dpkg/info related to debian packages that are going to be removed # 2. find /var/lib/llxcfg/cpkg/packages path (this lives in CPKG_ORIGINAL variable from /usr/share/lliurex/llxcfg-common/llxcfg-common.sh) LIB_FILE="/usr/share/lliurex/llxcfg-common/llxcfg-common.sh" if [ -r "$LIB_FILE" ] ; then . $LIB_FILE CPKG_LIST="$(sed -ne "\%^${CPKG_ORIGINAL}/[^/]\+$%{s%^${CPKG_ORIGINAL}/%%;p}" $(sed -ne "/[[:blank:]]-[[:blank:]]*$/{s%^%/var/lib/dpkg/info/%;s%[[:blank:]]\+-[[:blank:]]*$%.list%;p}" "$PKG_LIST") 2>/dev/null || true)" if [ "$CPKG_LIST" ] ; then $CPKG --verbose revert $CPKG_LIST || rc=$? fi fi fi ;; esac exit $rc