From d6c1db477756f60b22a980b142c5f67ff7272432 Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Thu, 19 May 2005 13:48:50 +0000 Subject: [PATCH] Stefan Fiedler: add a simple postinstall package (0.1) example postinstall script included Index: package/base/postinstall/postinstall.conf =================================================================== [2005050322440104290] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@6002 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/base/postinstall/postinstall | 118 ++++++++++++++++++ .../base/postinstall/postinstall-example.sh | 13 ++ package/base/postinstall/postinstall.conf | 11 ++ package/base/postinstall/postinstall.desc | 41 ++++++ 4 files changed, 183 insertions(+) create mode 100644 package/base/postinstall/postinstall create mode 100644 package/base/postinstall/postinstall-example.sh create mode 100644 package/base/postinstall/postinstall.conf create mode 100644 package/base/postinstall/postinstall.desc diff --git a/package/base/postinstall/postinstall b/package/base/postinstall/postinstall new file mode 100644 index 000000000..4dd0fe592 --- /dev/null +++ b/package/base/postinstall/postinstall @@ -0,0 +1,118 @@ +#!/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}.?????? + diff --git a/package/base/postinstall/postinstall-example.sh b/package/base/postinstall/postinstall-example.sh new file mode 100644 index 000000000..4943940e2 --- /dev/null +++ b/package/base/postinstall/postinstall-example.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +if any_installed ".*\.so"; then + echo "dynamic libraries installed, run ldconfig!" +fi + +if any_removed ".*\.so"; then + echo "dynamic libraries removed, run ldconfig!" +fi + +all_installed ".*" | while read M; do echo "Installed: $M"; done +all_removed ".*" | while read M; do echo "Removed: $M"; done + diff --git a/package/base/postinstall/postinstall.conf b/package/base/postinstall/postinstall.conf new file mode 100644 index 000000000..5a2eaa771 --- /dev/null +++ b/package/base/postinstall/postinstall.conf @@ -0,0 +1,11 @@ +postinstall_main () +{ + mkdir -p /var/adm/postinstall + mkdir -p /etc/postinstall + mkdir -p /etc/postinstall/postremove + cp -a /$confdir/postinstall /usr/sbin/ + chmod +x /usr/sbin/postinstall + cp -a /$confdir/postinstall-example.sh /etc/postinstall +} + +mainfunction=postinstall_main diff --git a/package/base/postinstall/postinstall.desc b/package/base/postinstall/postinstall.desc new file mode 100644 index 000000000..887efac15 --- /dev/null +++ b/package/base/postinstall/postinstall.desc @@ -0,0 +1,41 @@ + +[COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN --- +[COPY] +[COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch. +[COPY] Please add additional copyright information _after_ the line containing +[COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by +[COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text! +[COPY] +[COPY] ROCK Linux: rock-src/package/base/psmisc/psmisc.desc +[COPY] ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf +[COPY] +[COPY] This program is free software; you can redistribute it and/or modify +[COPY] it under the terms of the GNU General Public License as published by +[COPY] the Free Software Foundation; either version 2 of the License, or +[COPY] (at your option) any later version. A copy of the GNU General Public +[COPY] License can be found at Documentation/COPYING. +[COPY] +[COPY] Many people helped and are helping developing ROCK Linux. Please +[COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM +[COPY] file for details. +[COPY] +[COPY] --- ROCK-COPYRIGHT-NOTE-END --- + +[I] runs post-install/-remove actions + +[T] Some packages require actions to be performed after files have been +[T] installed or removed. +[T] postinstall is used to execute the postinstall scripts that every +[T] package can supply. + +[A] Stefan Fiedler +[M] Stefan Fiedler + +[C] base/tool +[F] CORE + +[L] OpenSource +[S] Stable +[V] 0.1 +[P] X -?-3-----9 186.900 +