mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

118 lines
3.1 KiB

#!/bin/bash
#
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
#
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
#
# ROCK Linux: rock-src/scripts/Build-Pkg
# ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
#
# 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. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
#
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
#
# --- ROCK-COPYRIGHT-NOTE-END ---
# Helper functions
is_installed ()
{
if [ install_checks_true == 1 ]; then return 0; fi
[ -e "$1" ];
}
is_removed ()
{
if [ remove_checks_true == 1 ]; then return 0; fi
[ ! -e "$1" ];
}
all_installed () {
for N in /var/adm/postinstall/*-install.??????;
do
#echo $N
if [ ! -e "$N" ]; then return 0; fi
grep "$1" "$N" | cut -f2 -d' ' |
while read M; do
if is_installed "/$M"; then echo "/$M"; fi;
done
done | sort -u
}
all_removed () {
for N in /var/adm/postinstall/*-remove.??????;
do
if [ ! -e "$N" ]; then return 0; fi
grep "$1" "$N" | cut -f2 -d' ' |
while read M; do
if is_removed "/$M"; then echo "/$M"; fi;
done
done | sort -u
}
any_installed () {
if [ install_checks_true == 1 ]; then return 0; fi
# This is a hack. Simply returning 0 if a file is found does not work?!
if [ "`all_installed $1`" != "" ]; then return 0; else return 1; fi
}
any_removed () {
if [ remove_checks_true == 1 ]; then return 0; fi
# This is a hack. Simply returning 0 if a file is found does not work?!
if [ "`all_installed $1`" != "" ]; then return 0; else return 1; fi
}
install_checks_true=0
remove_checks_true=0
if [ "$1" == "-a" ]; then install_checks_true=1; shift; fi
if [ "$1" == "-r" ]; then remove_checks_true=1; shift; fi
if [ "$1" == "--help" ]; then
echo "Usage: $0 [ -a ] [ -r ] [ --help ]"
echo
echo " -a execute all postinstall actions"
echo " -r execute all postremove actions"
echo " --help show this help text"
echo
exit 0;
fi
# Backup postinstall scripts for postremove operation
all_installed "etc/postinstall/.*\.sh" | while read M;
do
echo "Creating backup of $M in /etc/postinstall/postremove/"
cp -af "$M" "/etc/postinstall/postremove/${M##*/}"
done
# Execute removed postinstall scripts
all_removed "etc/postinstall/.*\.sh" | while read M;
do
P="/etc/postinstall/postremove/${M##*/}"
if [ -e $P ]; then
echo "Executing postremove script $P"
. "$P"
rm -f "$P"
else
echo "WARNING: backup of $M not found in /etc/postinstall/postremove"
fi
done
# Source postinstall scripts
for N in /etc/postinstall/*.sh;
do
echo "Executing postinstall script $N"
. "$N"
done
# Remove the postinstall/postremove logs
rm -f /var/adm/postinstall/*-{install,remove}.??????