From c2228d084bb1de22b2fef19a8d379c41460b01be Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 14 Mar 2009 07:32:01 +0100 Subject: [PATCH] Add a trigger to (un)register shells from /etc/shells. --HG-- extra : convert_revision : 6f82e9b19f880b388d5e800e1d159f4f3287ab26 --- templates/xbps-base-dirs/template | 7 ++-- triggers/register-shell | 58 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100755 triggers/register-shell diff --git a/templates/xbps-base-dirs/template b/templates/xbps-base-dirs/template index 4cfb3e0413..decf59916f 100644 --- a/templates/xbps-base-dirs/template +++ b/templates/xbps-base-dirs/template @@ -1,6 +1,6 @@ # Template file for 'xbps-base-dirs' pkgname=xbps-base-dirs -version=0.4 +version=0.5 build_style=custom-install short_desc="xbps base system directories" maintainer="Juan RP " @@ -51,7 +51,8 @@ do_install() cd $DESTDIR/usr && ln -s lib lib64 fi - for f in $(find $XBPS_TRIGGERSDIR -type f -perm 755); do - install -D -m 755 $f $DESTDIR/var/db/xbps/triggers/$(basename $f) + for f in info-files initramfs-tools register-shell; do + install -D -m 755 $XBPS_TRIGGERSDIR/$f \ + $DESTDIR/var/db/xbps/triggers/$(basename $f) done } diff --git a/triggers/register-shell b/triggers/register-shell new file mode 100755 index 0000000000..4873724430 --- /dev/null +++ b/triggers/register-shell @@ -0,0 +1,58 @@ +#!/bin/sh +# +# Registers or unregisters a shell in /etc/shells. +# +# Arguments: $1 = action [run/targets] +# $2 = target [post-install] +# $3 = pkgname +# $4 = version +# +trigger="register-shell" +shells_file="./var/db/xbps/metadata/$3/shells" + +case "$1" in +targets) + echo "post-install post-remove" + ;; +run) + [ "$2" != "post-install" -a "$2" != "post-remove" ] && exit 1 + [ ! -f ${shells_file} ] && exit 1 + + echo "Running $trigger trigger..." + + case "$2" in + post-install) + if [ ! -f ./etc/shells ]; then + cat ${shells_file} | while read line; do + echo $line >> ./etc/shells + echo "Registered $line into /etc/shells." + done + chmod 644 ./etc/shells + else + cat ${shells_file} | while read line; do + if ! grep -q $line ./etc/shells; then + echo $line >> ./etc/shells + echo "Registered $line into /etc/shells." + fi + done + fi + ;; + post-remove) + if [ -f ./etc/shells ]; then + cat ${shells_file} | while read line; do + if grep -q $line ./etc/shells; then + shell=$(echo $line | sed "s|\\/|\\\/|g") + sed -i -e "/$shell/d" ./etc/shells + echo "Unregistered $line from /etc/shells." + fi + done + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0