Major infrastructure changes, part 2.

* Moved helpers, common and triggers dirs into xbps-src, where
  they belong.
* Renamed the templates dir to srcpkgs, it was so redundant before.
* Make it possible to add subpkgs with no restriction in names, for
  example udev now has a subpkgs called "libgudev". Previously
  subpkgs were named "${sourcepkg}-${pkgname}".
* xbps-src: changed to look for template files in current directory.
  That means that most arguments from the targets have been removed.
* xbps-src: added a reinstall target, to remove + install.
* xbps-src: do not overwrite binpkgs by default, skip them.

And more that I forgot because it's a mega-commit that I've been
working for some days already...

--HG--
extra : convert_revision : 0f466878584d1e6895d2a234f07ea1b2d1e61b3e
This commit is contained in:
Juan RP
2009-11-22 08:31:44 +01:00
parent 3c58e3ad40
commit 85cc462e1d
1305 changed files with 719 additions and 654 deletions

View File

@@ -0,0 +1,20 @@
include ../vars.mk
TRIGGERS= gtk-icon-cache info-files mimedb register-shell
TRIGGERS+= xml-catalog gtk-immodules initramfs-tools openrc-service
TRIGGERS+= update-desktopdb gtk-pixbuf-loaders pango-modules x11-fonts
.PHONY: all
all:
.PHONY: clean
clean:
.PHONY: install
install:
install -d $(DESTDIR)$(SHAREDIR)/triggers
install -m 755 $(TRIGGERS) $(DESTDIR)$(SHAREDIR)/triggers
.PHONY: uninstall
uninstall:
-rm -rf $(DESTDIR)$(SHAREDIR)/triggers

View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# Updates GTK+ icon cache file with gtk-update-icon-cache(1).
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
iconcache_bin=usr/bin/gtk-update-icon-cache
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
if [ "$2" = "post-remove" -a "${PKGNAME}" = "gtk+" ]; then
for dir in ${gtk_iconcache_dirs}; do
if [ -f ${dir}/icon-theme.cache ]; then
rm -f ${dir}/icon-theme.cache
echo -n "Removed GTK+ icon theme "
echo "cache for ${dir}."
fi
done
break
fi
case "$2" in
post-*)
for dir in ${gtk_iconcache_dirs}; do
if [ -x ${iconcache_bin} ]; then
echo -n "Updating GTK+ icon cache for "
echo "${dir}..."
${iconcache_bin} -q -f -t ${dir}
fi
done
;;
esac
;;
*)
exit 1
;;
esac
exit 0

36
xbps-src/triggers/gtk-immodules Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/sh
#
# Updates GTK+ IM modules file with gtk-query-immodules-2.0(1).
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
immodules_bin=usr/bin/gtk-query-immodules-2.0
immodules_db=etc/gtk-2.0/gtk.immodules
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
if [ "$2" = "post-remove" -a "${PKGNAME}" = "gtk+" ]; then
[ -f ${immodules_db} ] rm -f ${immodules_db}
break
fi
case "$2" in
post-*)
if [ -x ${immodules_bin} ]; then
echo "Updating GTK's immodules database..."
${immodules_bin} > ${immodules_db}
fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,36 @@
#!/bin/sh
#
# Updates GTK+ gdk pixbuf modules file with gdk-pixbuf-query-loaders(1).
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
pixbuf_bin=usr/bin/gdk-pixbuf-query-loaders
pixbuf_loaders=etc/gtk-2.0/gdk-pixbuf.loaders
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
if [ "$2" = "post-remove" -a "${PKGNAME}" = "gtk+" ]; then
[ -f ${pixbuf_loaders} ] && rm -f ${pixbuf_loaders}
break
fi
case "$2" in
post-*)
if [ -x ${pixbuf_bin} ]; then
echo "Updating GTK's pixbuf modules file..."
${pixbuf_bin} > ${pixbuf_loaders}
fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0

50
xbps-src/triggers/info-files Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/sh
#
# Registers or unregisters info files for a package.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/pre-remove]
# $3 = pkgname
#
installinfo=usr/bin/install-info
infodir=usr/share/info
case "$1" in
targets)
echo "post-install pre-remove"
;;
run)
[ ! -x "$installinfo" ] && exit 0
if [ -z "$info_files" ]; then
echo "Trigger info-files: empty info_files."
exit 1
fi
for f in ${info_files}; do
[ "$f" = "/usr/share/info/dir" ] && continue
case "$2" in
post-install)
echo -n "Registering info file: $f... "
;;
pre-remove)
echo -n "Unregistering info file: $f... "
infoargs="--delete"
;;
esac
$installinfo $infoargs ./$f $infodir/dir 2>/dev/null
if [ $? -eq 0 ]; then
echo "done."
else
echo "failed!"
fi
done
;;
*)
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,68 @@
#!/bin/sh -e
#
# Runs update-initramfs(8) to create/update an initramfs for specified
# version (if the pkg that is triggering it) or for the currently
# installed kernel otherwise.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
ACTION="$1"
TARGET="$2"
PKGNAME="$3"
VERSION="$4"
update_initramfs=usr/sbin/update-initramfs
case "$ACTION" in
targets)
echo "post-install post-remove"
;;
run)
[ ! -x ${update_initramfs} ] && exit 0
initramfs_args="update-initramfs"
if [ "$PKGNAME" = "kernel" ]; then
if [ "$TARGET" = "post-remove" ]; then
exit 0
fi
if [ ! -f var/lib/initramfs-tools/${VERSION} ]; then
# Create new initramfs
initramfs_args="-c -t -k ${VERSION}"
else
# Update existing initramfs
initramfs_args="-u -t -k ${VERSION}"
fi
else
# Update initramfs for all kernels
initramfs_args="-u -t -k all"
fi
if [ ! -e /proc/filesystems ]; then
mount -t proc proc /proc
proc_mounted=1
fi
if [ ! -e /sys/kernel/vmcoreinfo ]; then
mount -t sysfs sysfs /sys
sys_mounted=1
fi
${update_initramfs} ${initramfs_args}
if [ -n "$proc_mounted" ]; then
umount /proc
fi
if [ -n "$sys_mounted" ]; then
umount /sys
fi
;;
*)
exit 1
;;
esac
exit 0

31
xbps-src/triggers/mimedb Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
#
# Updates the shared-mime-info db file with update-mime-database(1).
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
mimedb_bin=usr/bin/update-mime-database
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
case "$2" in
post-*)
if [ -x ${mimedb_bin} ]; then
echo "Updating shared-mime-info database..."
${mimedb_bin} usr/share/mime > /dev/null
fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,79 @@
#!/bin/sh
#
# Registers or unregisters OpenRC services into the specified
# runlevel.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/pre-remove]
# $3 = pkgname
# $4 = version
# $5 = update [yes/no]
#
ACTION="$1"
TARGET="$2"
PKGNAME="$3"
VERSION="$4"
UPDATE="$5"
initdir=etc/init.d
metadatadir=var/db/xbps/metadata/${PKGNAME}
case "$ACTION" in
targets)
echo "post-install pre-remove"
;;
run)
[ ! -x sbin/rc-update ] && exit 0
[ ! -x sbin/rc-service ] && exit 0
[ -z "$openrc_services" ] && exit 1
if [ "$TARGET" = "pre-remove" ]; then
rcupdate_args="del"
elif [ "$TARGET" = "post-install" ]; then
rcupdate_args="add"
else
exit 1
fi
[ ! -f etc/fstab ] && touch etc/fstab
set -- ${openrc_services}
while [ $# -gt 0 ]; do
srv_restart=$metadatadir/.$1_srv_restart
if [ "$TARGET" = "post-install" ]; then
if [ -f $srv_restart ]; then
# Restart service if it was running previously.
$initdir/$1 start
rm -f $srv_restart
else
# Register service.
if sbin/rc-service -e ${1}; then
sbin/rc-update add ${1} ${2}
fi
fi
else
# While removing always stop the service if running.
$initdir/$1 -q status
if [ $? -eq 0 ]; then
$initdir/$1 stop
fi
#
# While upgrading a package, don't remove the service.
#
if [ "$UPDATE" = "yes" ]; then
touch -f $srv_restart
else
# Unregister the service.
sbin/rc-update del ${1} ${2}
fi
fi
unset srv_restart
shift; shift;
done
;;
*)
exit 1
;;
esac
exit 0

39
xbps-src/triggers/pango-modules Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/sh
#
# Updates the list of pango modules with pango-querymodules(1).
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
pango_bin=usr/bin/pango-querymodules
pango_modules=etc/pango/pango.modules
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
if [ "$2" = "post-remove" -a "${PKGNAME}" = "pango" ]; then
if [ -f ${pango_modules} ]; then
echo "Removing pango modules file..."
rm -f ${pango_modules}
fi
break
fi
case "$2" in
post-*)
if [ -x ${pango_bin} ]; then
echo "Updating pango modules file..."
${pango_bin} > ${pango_modules}
fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,60 @@
#!/bin/sh
#
# Registers or unregisters a shell in /etc/shells.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install]
# $3 = pkgname
# $4 = version
#
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
[ "$2" != "post-install" -a "$2" != "post-remove" ] && 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
for f in ${register_shell}; do
echo $f >> etc/shells
echo "Registered $f into /etc/shells."
done
chmod 644 etc/shells
else
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
fi
;;
post-remove)
if [ -f etc/shells ]; then
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 $f from "
echo "/etc/shells."
fi
done
fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,38 @@
#!/bin/sh
#
# Updates the MIME database that connects with applications, through
# the update-desktop-database(1) utility.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/post-remove]
# $3 = pkgname
# $4 = version
#
desktopdb_bin=usr/bin/update-desktop-database
desktopdb_dir=usr/share/applications
desktopdb_cache=${desktopdb_dir}/mimeinfo.cache
case "$1" in
targets)
echo "post-install post-remove"
;;
run)
if [ "$2" = "post-remove" -a "${PKGNAME}" = "desktop-file-utils" ]; then
[ -f ${desktopdb_cache} ] && rm -f ${desktopdb_cache}
break
fi
case "$2" in
post-*)
if [ -x ${desktopdb_bin} ]; then
echo "Updating MIME database..."
${desktopdb_bin} ${desktopdb_dir}
fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0

58
xbps-src/triggers/x11-fonts Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/sh
#
# This trigger rebuilds the fonts.dir and fonts.scale files
# for packages that install X11 fonts, and update fontconfig's
# cache for those fonts.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/pre-remove]
# $3 = pkgname
#
mkfontdir=usr/bin/mkfontdir
mkfontscale=usr/bin/mkfontscale
fccache=usr/bin/fc-cache
case "$1" in
targets)
echo "post-install pre-remove"
;;
run)
if [ ! -x ${mkfontdir} -a ! -x ${mkfontscale} ]; then
exit 0
fi
[ -z "${font_dirs}" ] && exit 0
case "$2" in
post-install)
for dir in ${font_dirs}; do
echo "Building ${dir}/fonts.dir..."
${mkfontdir} .${dir} || exit $?
echo "Building ${dir}/fonts.scale..."
${mkfontscale} .${dir} || exit $?
echo "Updating fontconfig's cache..."
${fccache} .${dir} 2>/dev/null
done
;;
pre-remove)
for dir in ${font_dirs}; do
if [ -f .${dir}/fonts.dir ]; then
rm -f .${dir}/fonts.dir
fi
if [ -f .${dir}/fonts.scale ]; then
rm -f .${dir}/fonts.scale
fi
if [ -f .${dir}/encodings.dir ]; then
rm -f .${dir}/encodings.dir
fi
done
;;
esac
;;
*)
exit 1
;;
esac
exit 0

87
xbps-src/triggers/xml-catalog Executable file
View File

@@ -0,0 +1,87 @@
#!/bin/sh
#
# Registers or unregisters SGML/XML catalog entries, through
# the xmlcatmgr application.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/pre-remove]
# $3 = pkgname
# $4 = version
#
sgml_catalog=usr/share/sgml/catalog
xml_catalog=usr/share/xml/catalog
register_entries()
{
if [ -n "${sgml_entries}" ]; then
echo -n "Registering SGML catalog entries... "
set -- ${sgml_entries}
while [ $# -gt 0 ]; do
xmlcatmgr -sc ${sgml_catalog} add "$1" "$2" "$3"
shift; shift; shift;
done
echo "done."
fi
if [ -n "${xml_entries}" ]; then
echo -n "Registering XML catalog entries... "
set -- ${xml_entries}
while [ $# -gt 0 ]; do
xmlcatmgr -c ${xml_catalog} add "$1" "$2" "$3"
shift; shift; shift;
done
echo "done."
fi
}
unregister_entries()
{
if [ -n "${sgml_entries}" ]; then
echo -n "Unregistering SGML catalog entries... "
set -- ${sgml_entries}
while [ $# -gt 0 ]; do
xmlcatmgr -sc ${sgml_catalog} remove "$1" "$2" \
2>/dev/null
shift; shift; shift
done
echo "done."
fi
if [ -n "${xml_entries}" ]; then
echo -n "Unregistering XML catalog entries... "
set -- ${xml_entries}
while [ $# -gt 0 ]; do
xmlcatmgr -c ${xml_catalog} remove "$1" "$2" \
2>/dev/null
shift; shift; shift
done
echo "done."
fi
}
case "$1" in
targets)
echo "post-install pre-remove"
;;
run)
[ ! -x $xmlcatmgr ] && exit 0
[ -n "${sgml_entries}" -a ! -f "${sgml_catalog}" ] && exit 0
[ -n "${xml_entries}" -a ! -f "${xml_catalog}" ] && exit 0
case "$2" in
post-install)
register_entries
;;
pre-remove)
unregister_entries
;;
*)
exit 1
;;
esac
;;
*)
exit 1
;;
esac
exit 0