Improve the info-files and register-shell triggers.

This avoids the need of having to create a new file in pkg metadata
dir with a few lines and puts all them in the INSTALL/REMOVE
scripts.

--HG--
extra : convert_revision : 2dc1d3f6ddcc6aec7dadf14df475c32959df0aba
This commit is contained in:
Juan RP
2009-07-30 12:34:31 +02:00
parent 8a31007139
commit 76c23bbd96
6 changed files with 71 additions and 54 deletions

View File

@@ -6,8 +6,6 @@
# $2 = target [post-install/pre-remove]
# $3 = pkgname
#
xbps_metadir=var/db/xbps/metadata
finfometa=$xbps_metadir/$3/info-files
installinfo=usr/bin/install-info
infodir=usr/share/info
@@ -16,28 +14,27 @@ targets)
echo "post-install pre-remove"
;;
run)
[ ! -x $installinfo ] && exit 0
[ ! -x "$installinfo" ] && exit 0
if [ ! -r $finfometa ]; then
echo "$trigger: can't find info-files in metadata directory!"
if [ -z "$info_files" ]; then
echo "Trigger info-files: empty info_files."
exit 1
fi
cat $finfometa | while read line; do
[ ! -f ./$line ] && continue
[ "$line" = "/usr/share/info/dir" ] && continue
for f in ${info_files}; do
[ "$f" = "/usr/share/info/dir" ] && continue
case "$2" in
post-install)
echo -n "Registering info file: $line... "
echo -n "Registering info file: $f... "
;;
pre-remove)
echo -n "Unregistering info file: $line... "
echo -n "Unregistering info file: $f... "
infoargs="--delete"
;;
esac
$installinfo $infoargs ./$line $infodir/dir 2>/dev/null
$installinfo $infoargs ./$f $infodir/dir 2>/dev/null
if [ $? -eq 0 ]; then
echo "done."
else

View File

@@ -7,7 +7,6 @@
# $3 = pkgname
# $4 = version
#
shells_file=var/db/xbps/metadata/$3/shells
case "$1" in
targets)
@@ -15,21 +14,25 @@ targets)
;;
run)
[ "$2" != "post-install" -a "$2" != "post-remove" ] && exit 1
[ ! -f ${shells_file} ] && exit 1
if [ -z "$register_shell" ]; then
echo "Trigger register-shell: empty \$register_shell!"
exit 1
fi
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."
for f in ${register_shell}; do
echo $f >> etc/shells
echo "Registered $f 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 -n "Registered $line into "
for f in ${register_shell}; do
if ! grep -q $f etc/shells; then
echo $f >> etc/shells
echo -n "Registered $f into "
echo "/etc/shells."
fi
done
@@ -37,11 +40,11 @@ run)
;;
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")
for f in ${register_shell}; do
if grep -q $f etc/shells; then
shell=$(echo $f|sed "s|\\/|\\\/|g")
sed -i -e "/$shell/d" etc/shells
echo -n "Unregistered $line from "
echo -n "Unregistered $f from "
echo "/etc/shells."
fi
done