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

@ -115,7 +115,6 @@ xbps_write_metadata_pkg_real()
# Write the files.plist file.
TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
TMPFPLIST=$(mktemp -t fplist.XXXXXXXXXX) || exit 1
TMPINFOLIST=$(mktemp -t infolist.XXXXXXXXXX) || exit 1
#
# Find out if this package contains info files and compress
@ -245,18 +244,6 @@ xbps_write_metadata_pkg_real()
echo "</plist>" >> $TMPFPLIST
sed -i -e /^$/d $TMPFLIST
#
# Find out if this package contains info files and write
# a list will all them in a file.
#
if [ -d "${DESTDIR}/usr/share/info" ]; then
for f in $(find ${DESTDIR}/usr/share/info -type f); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
echo "$j" >> $TMPINFOLIST
done
fi
# Write the props.plist file.
local TMPFPROPS=$(mktemp -t fprops.XXXXXXXXXX) || exit 1
@ -345,19 +332,6 @@ _EOF
fi
mv -f $TMPFPLIST $metadir/files.plist
mv -f $TMPFPROPS $metadir/props.plist
if [ -s $TMPINFOLIST ]; then
mv -f $TMPINFOLIST $metadir/info-files
else
rm -f $TMPINFOLIST
fi
# Register the shells into /etc/shells if requested.
if [ -n "${register_shell}" ]; then
triggers="$triggers register-shell"
for f in ${register_shell}; do
echo $f >> $metadir/shells
done
fi
$XBPS_REGPKGDB_CMD sanitize-plist $metadir/files.plist
$XBPS_REGPKGDB_CMD sanitize-plist $metadir/props.plist

View file

@ -28,7 +28,8 @@ xbps_write_metadata_scripts_pkg()
local action="$1"
local metadir="${DESTDIR}/var/db/xbps/metadata/$pkgname"
local tmpf=$(mktemp -t xbps-install.XXXXXXXXXX) || exit 1
local targets found
local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d"
local targets found info_files
case "$action" in
install) ;;
@ -60,6 +61,32 @@ VERSION="\$3"
_EOF
#
# Handle GNU Info files.
#
if [ -d "${DESTDIR}/usr/share/info" ]; then
unset info_files
for f in $(find ${DESTDIR}/usr/share/info -type f); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
[ "$j" = "/usr/share/info/dir" ] && continue
if [ -z "$info_files" ]; then
info_files="$j"
else
info_files="$info_files $j"
fi
done
if [ -n "${info_files}" ]; then
for f in ${triggers}; do
[ "$f" = "info-files" ] && found=1
done
[ -z "$found" ] && triggers="$triggers info-files"
unset found
echo "export info_files=\"${info_files}\"" >> $tmpf
echo >> $tmpf
fi
fi
#
# Handle OpenRC services.
#
@ -68,6 +95,19 @@ _EOF
echo >> $tmpf
fi
#
# (Un)Register a shell in /etc/shells.
#
if [ -n "${register_shell}" ]; then
for f in ${triggers}; do
[ "$f" = "register-shell" ] && found=1
done
[ -z "$found" ] && triggers="$triggers register-shell"
unset found
echo "export register_shell=\"${register_shell}\"" >> $tmpf
echo >> $tmpf
fi
#
# Handle SGML/XML catalog entries via xmlcatmgr.
#

View file

@ -1,8 +1,8 @@
#
# This script registers all currently installed info files.
#
texinfo_files="info.info.gz info-stnd.info.gz texinfo.gz
texinfo-1.gz texinfo-2.gz texinfo-3.gz"
texinfo_files="info.info.gz info-stnd.info.gz texinfo.gz"
texinfo_files="${texinfo_files} texinfo-1.gz texinfo-2.gz texinfo-3.gz"
case "${ACTION}" in
pre)
@ -20,6 +20,9 @@ post)
continue
fi
echo -n "Registering info file: ${file#.}... "
if [ "${file#.}" = "/usr/share/info/dir" ]; then
continue
fi
install-info $file ./usr/share/info/dir 2> /dev/null
if [ $? -eq 0 ]; then
echo "done."

View file

@ -1,6 +1,6 @@
# Template file for 'xbps-base-files'
pkgname=xbps-base-files
version=0.18
version=0.19
build_style=custom-install
short_desc="xbps base system files"
maintainer="Juan RP <xtraeme@gmail.com>"

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