Merge branch 'debian-unstable' of git.debian.org:/git/pkg-xorg/xsfbs into debian-unstable

This commit is contained in:
Julien Cristau 2008-06-01 13:57:25 +02:00
commit 2de4482226
3 changed files with 216 additions and 430 deletions

View File

@ -1,150 +0,0 @@
#!/usr/bin/make -f
# $Id$
# Automagical conversion of autoreconf results into quilt patches.
# Copyright 2006 Eugene Konev
#
# Licensed under the GNU General Public License, version 2. See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# The idea behind this is storing changes produced by autoreconf as a
# separate patch on quilt stack (on top of stack actually).
# The only usable target here is 'autoreconf`. Other targets are not
# supposed to be called directly. DO NOT invoke them, unless you know what
# you are doing.
# The autoreconf target will check if files with names in $(RECONF_CHECKFILES)
# were changed during patching (from upstream version or from previously
# autoreconfed version) and call actual autoreconfing if they were.
# The actual autoreconfing target (doautoreconf) WILL FAIL after
# calling autoreconf and pushing changes into quilt stack by design. It
# should never be invoked by automatic build process.
# The proposed use is adding autoreconf into clean's prerequisites before
# xsfclean like:
# - clean: xsfclean
# + clean: autoreconf xsfclean
# This will ensure it is called when you build package with dpkg-buildpackage.
# This dir will be used for producing diff of autoreconfed tree
RECONF_DIR := xsfautoreconf
# This files will be checked for changes
RECONF_CHECKFILES += configure.ac Makefile.am
# This files will not be hardlinked but copied
RECONF_NOLINKFILES += aclocal.m4
# This files/dirs will be pruned after autoreconf run
RECONF_PRUNEFILES += autom4te.cache config.h.in~ aclocal.m4~
# Internal target. Never invoke directly.
stampdir_target+=check.md5sum
$(STAMP_DIR)/check.md5sum:
dh_testdir
$(MAKE) -f debian/rules prepare
for F in $(RECONF_CHECKFILES); do \
find . -wholename ./$(STAMP_DIR) -prune -o -name $$F -print | \
LC_ALL=C sort | xargs --no-run-if-empty md5sum >>$@; \
done
# Internal target. Never invoke directly.
$(STAMP_DIR)/clean.md5sum:
dh_testdir
$(MAKE) -f debian/rules unpatch
rm -f $(STAMP_DIR)/check.md5sum
$(MAKE) -f debian/rules $(STAMP_DIR)/check.md5sum
mv $(STAMP_DIR)/check.md5sum $@
# Internal target. Never invoke directly.
debian/patches/patched.md5sum:
dh_testdir
[ -f $(STAMP_DIR)/clean.md5sum ] || \
$(MAKE) -f debian/rules $(STAMP_DIR)/clean.md5sum
$(MAKE) -f debian/rules patch
rm -f $(STAMP_DIR)/check.md5sum
$(MAKE) -f debian/rules $(STAMP_DIR)/check.md5sum
if ! diff $(STAMP_DIR)/clean.md5sum \
$(STAMP_DIR)/check.md5sum > /dev/null; then \
$(MAKE) -f debian/rules doautoreconf; \
else \
mv $(STAMP_DIR)/check.md5sum $@; \
fi
# Internal target. Never invoke directly.
,PHONY: doautoreconf
doautoreconf: patch
quilt push -a >>$(STAMP_DIR)/log/autoreconf 2>&1 || true
if quilt applied | grep ^autoreconf.diff$$ > /dev/null; then \
quilt pop -a >>$(STAMP_DIR)/log/autoreconf 2>&1; \
quilt rename -p autoreconf.diff autoreconf-old.diff \
>>$(STAMP_DIR)/log/autoreconf 2>&1; \
quilt delete autoreconf-old.diff >>$(STAMP_DIR)/log/autoreconf 2>&1; \
quilt push -a >>$(STAMP_DIR)/log/autoreconf 2>&1; \
fi
if [ -e $(RECONF_DIR) ]; then \
echo "ERROR: $(RECONF_DIR) already exists. Cleanup by hand"; \
exit 1; \
fi
mkdir -p $(RECONF_DIR)/before
find . -maxdepth 1 -mindepth 1 ! -wholename ./$(RECONF_DIR) \
-a ! -wholename ./debian -a ! -wholename ./patches \
-a ! -wholename ./.pc -a ! -wholename ./$(STAMP_DIR) | \
xargs -i{} cp -al {} $(RECONF_DIR)/before/
for F in $(RECONF_PRUNEFILES); do \
find $(RECONF_DIR)/before -name $$F -print | \
xargs --no-run-if-empty rm -r; \
done
cp -al $(RECONF_DIR)/before $(RECONF_DIR)/after
for F in $(RECONF_NOLINKFILES); do \
find . -wholename ./$(RECONF_DIR) -prune -o -wholename ./debian \
-prune -o -wholename ./$(STAMP_DIR) -prune -o -name $$F \
-print | \
xargs --no-run-if-empty -i{} cp --remove-destination {} \
$(RECONF_DIR)/after/{}; \
done
cd $(RECONF_DIR)/after && autoreconf -v --install && \
for F in $(RECONF_PRUNEFILES); do \
find . -name $$F -print | \
xargs --no-run-if-empty rm -r; \
done
cd $(RECONF_DIR) && diff -Nru before after > autoreconf.diff || true
quilt import $(RECONF_DIR)/autoreconf.diff \
>>$(STAMP_DIR)/log/autoreconf 2>&1
mv $(STAMP_DIR)/check.md5sum debian/patches/patched.md5sum
rm -r $(RECONF_DIR) && rm -f patches/autoreconf-old.diff
@echo
@echo "****************************************************************"
@echo " This target is made to fail INTENTIONALLY. It should NEVER "
@echo " be invoked during automatic builds. "
@echo
@echo " This target was invoked because you added/removed/changed "
@echo " patches which modify either configure.ac or Makefile.am and, "
@echo " thus, require autoreconf run. And all autoreconfing should "
@echo " happen before uploading. "
@echo
@echo " (See also debian/xsfbs/xsfbs-autoreconf.mk) "
@echo
@echo " If you see this message, autoreconfing actually SUCCEEDED, "
@echo " and your build should finish successfully, when rerun. "
@echo "****************************************************************"
@echo
exit 1;
.PHONY: autoreconf
autoreconf: debian/patches/patched.md5sum patch $(STAMP_DIR)/check.md5sum
if ! diff $(STAMP_DIR)/check.md5sum \
debian/patches/patched.md5sum > /dev/null; then \
$(MAKE) -f debian/rules doautoreconf; \
fi

102
debian/xsfbs/xsfbs.mk vendored
View File

@ -21,10 +21,8 @@
# Pass $(DH_OPTIONS) into the environment for debhelper's benefit. # Pass $(DH_OPTIONS) into the environment for debhelper's benefit.
export DH_OPTIONS export DH_OPTIONS
# force quilt to not use ~/.quiltrc # force quilt to not use ~/.quiltrc and to use debian/patches
QUILT = quilt --quiltrc /dev/null QUILT = QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null
# force QUILT_PATCHES to the default in case it is exported in the environment
QUILT_PATCHES = patches/
# Set up parameters for the upstream build environment. # Set up parameters for the upstream build environment.
@ -121,19 +119,11 @@ $(STAMP_DIR)/stampdir:
# Set up the package build directory as quilt expects to find it. # Set up the package build directory as quilt expects to find it.
.PHONY: prepare .PHONY: prepare
stampdir_targets+=prepare stampdir_targets+=prepare
prepare: $(STAMP_DIR)/genscripts $(STAMP_DIR)/prepare $(STAMP_DIR)/patches $(STAMP_DIR)/log prepare: $(STAMP_DIR)/genscripts $(STAMP_DIR)/prepare $(STAMP_DIR)/log
$(STAMP_DIR)/prepare: $(STAMP_DIR)/stampdir $(STAMP_DIR)/prepare: $(STAMP_DIR)/stampdir
if [ ! -e $(STAMP_DIR)/patches ]; then \
mkdir $(STAMP_DIR)/patches; \
ln -s $(STAMP_DIR)/patches .pc; \
echo 2 >$(STAMP_DIR)/patches/.version; \
fi; \
if [ ! -e $(STAMP_DIR)/log ]; then \ if [ ! -e $(STAMP_DIR)/log ]; then \
mkdir $(STAMP_DIR)/log; \ mkdir $(STAMP_DIR)/log; \
fi; \ fi; \
if [ -e debian/patches ] && [ ! -e patches ]; then \
ln -s debian/patches patches; \
fi; \
>$@ >$@
# Apply all patches to the upstream source. # Apply all patches to the upstream source.
@ -162,10 +152,10 @@ $(STAMP_DIR)/patch: $(STAMP_DIR)/prepare
# Revert all patches to the upstream source. # Revert all patches to the upstream source.
.PHONY: unpatch .PHONY: unpatch
unpatch: unpatch: $(STAMP_DIR)/prepare
rm -f $(STAMP_DIR)/patch rm -f $(STAMP_DIR)/patch
@echo -n "Unapplying patches..."; \ @echo -n "Unapplying patches..."; \
if [ -e $(STAMP_DIR)/patches/applied-patches ]; then \ if $(QUILT) applied >/dev/null 2>/dev/null; then \
if $(QUILT) pop -a -v >$(STAMP_DIR)/log/unpatch 2>&1; then \ if $(QUILT) pop -a -v >$(STAMP_DIR)/log/unpatch 2>&1; then \
cat $(STAMP_DIR)/log/unpatch; \ cat $(STAMP_DIR)/log/unpatch; \
echo "successful."; \ echo "successful."; \
@ -192,11 +182,10 @@ cleanscripts:
.PHONY: xsfclean .PHONY: xsfclean
xsfclean: cleanscripts unpatch xsfclean: cleanscripts unpatch
dh_testdir dh_testdir
rm -f .pc patches rm -rf .pc
rm -rf $(STAMP_DIR) $(SOURCE_DIR) rm -rf $(STAMP_DIR) $(SOURCE_DIR)
rm -rf imports rm -rf imports
dh_clean debian/shlibs.local \ dh_clean debian/shlibs.local \
debian/MANIFEST.$(ARCH) debian/MANIFEST.$(ARCH).new \
debian/po/pothead debian/po/pothead
# Generate the debconf templates POT file header. # Generate the debconf templates POT file header.
@ -209,58 +198,6 @@ debian/po/pothead: debian/po/pothead.in
updatepo: debian/po/pothead updatepo: debian/po/pothead
debian/scripts/debconf-updatepo --pot-header=pothead --verbose debian/scripts/debconf-updatepo --pot-header=pothead --verbose
# Use the MANIFEST files to determine whether we're shipping everything we
# expect to ship, and not shipping anything we don't expect to ship.
.PHONY: check-manifest
stampdir_targets+=check-manifest
check-manifest: $(STAMP_DIR)/check-manifest
$(STAMP_DIR)/check-manifest: $(STAMP_DIR)/install
# Compare manifests.
(cd debian/tmp && find -type f | LC_ALL=C sort | cut -c3-) \
>debian/MANIFEST.$(ARCH).new
# Construct MANIFEST files from MANIFEST.$(ARCH).in and
# MANIFEST.$(ARCH).all or MANIFEST.all.
if expr "$(findstring -DBuildFonts=NO,$(IMAKE_DEFINES))" \
: "-DBuildFonts=NO" >/dev/null 2>&1; then \
LC_ALL=C sort -u debian/MANIFEST.$(ARCH).in >debian/MANIFEST.$(ARCH); \
else \
if [ -e debian/MANIFEST.$(ARCH).all ]; then \
LC_ALL=C sort -u debian/MANIFEST.$(ARCH).in debian/MANIFEST.$(ARCH).all >debian/MANIFEST.$(ARCH); \
else \
LC_ALL=C sort -u debian/MANIFEST.$(ARCH).in debian/MANIFEST.all >debian/MANIFEST.$(ARCH); \
fi; \
fi
# Confirm that the installed file list has not changed.
if [ -e debian/MANIFEST.$(ARCH) ]; then \
if ! cmp -s debian/MANIFEST.$(ARCH) debian/MANIFEST.$(ARCH).new; then \
diff -U 0 debian/MANIFEST.$(ARCH) debian/MANIFEST.$(ARCH).new || DIFFSTATUS=$$?; \
case $${DIFFSTATUS:-0} in \
0) ;; \
1) if [ -n "$$IGNORE_MANIFEST_CHANGES" ]; then \
echo 'MANIFEST check failed; ignoring problem because \$$IGNORE_MANIFEST_CHANGES set' >&2; \
echo 'Please ensure that the package maintainer has an up-to-date version of the' >&2; \
echo 'MANIFEST.$(ARCH).in file.' >&2; \
else \
echo 'MANIFEST check failed; please see debian/README' >&2; \
exit 1; \
fi; \
;; \
*) echo "diff reported unexpected exit status $$DIFFSTATUS when performing MANIFEST check" >&2; \
exit 1; \
;; \
esac; \
fi; \
fi
>$@
# Because we build (and install) different files depending on whether or not
# any architecture-independent packages are being created, the list of files we
# expect to see will differ; see the discussion of the "build" target above.
.PHONY: check-manifest-arch check-manifest-indep
check-manifest-arch: IMAKE_DEFINES+= -DBuildSpecsDocs=NO -DBuildFonts=NO -DInstallHardcopyDocs=NO
check-manifest-arch: check-manifest
check-manifest-indep: check-manifest
# Remove files from the upstream source tree that we don't need, or which have # Remove files from the upstream source tree that we don't need, or which have
# licensing problems. It must be run before creating the .orig.tar.gz. # licensing problems. It must be run before creating the .orig.tar.gz.
# #
@ -272,29 +209,6 @@ prune-upstream-tree:
dh_testdir dh_testdir
grep -rvh '^#' debian/prune/ | xargs --no-run-if-empty rm -rf grep -rvh '^#' debian/prune/ | xargs --no-run-if-empty rm -rf
# Change to what should be the correct directory, ensure it is, and if
# so, create the .orig.tar.gz file. Exclude the debian directory and its
# contents, and any .svn directories and their contents (so that we can safely
# build an .orig.tar.gz from SVN checkout, not just an export).
#
# Note: This rule is for Debian package maintainers' convenience, and is not
# needed for conventional build scenarios.
#
# This rule *IS* the recommended method for creating a new .orig.tar.gz file,
# for the rare situations when one is needed.
.PHONY: make-orig-tar-gz
make-orig-tar-gz: clean prune-upstream-tree
( cd .. \
&& if [ $(shell basename $(CURDIR)) != $(SOURCE_NAME)-$(NO_EPOCH_VER) ]; then \
echo "Our current working directory has the wrong name. Renaming..." >&2; \
mv $(CURDIR) $(SOURCE_NAME)-$(NO_EPOCH_VER); \
fi; \
tar --exclude=debian --exclude=debian/* \
--exclude=.svn --exclude=.svn/* \
-cf - $(SOURCE_NAME)-$(NO_EPOCH_VER) \
| gzip -9 >$(SOURCE_NAME)_$(NO_EPOCH_VER).orig.tar.gz; \
)
# Verify that there are no offsets or fuzz in the patches we apply. # Verify that there are no offsets or fuzz in the patches we apply.
# #
# Note: This rule is for Debian package maintainers' convenience, and is not # Note: This rule is for Debian package maintainers' convenience, and is not
@ -373,7 +287,7 @@ PACKAGE=$(shell awk '/^Package:/ { print $$2; exit }' < debian/control)
endif endif
.PHONY: serverabi .PHONY: serverabi
serverabi: serverabi: install
ifeq ($(SERVERMINVERS),) ifeq ($(SERVERMINVERS),)
@echo error: xserver-xorg-dev needs to be installed @echo error: xserver-xorg-dev needs to be installed
@exit 1 @exit 1
@ -383,6 +297,4 @@ else
echo "xinpdriver:Provides=$(INPDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars echo "xinpdriver:Provides=$(INPDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
endif endif
include debian/xsfbs/xsfbs-autoreconf.mk
# vim:set noet ai sts=8 sw=8 tw=0: # vim:set noet ai sts=8 sw=8 tw=0:

394
debian/xsfbs/xsfbs.sh vendored
View File

@ -59,13 +59,6 @@ fi
ARCHITECTURE="$(dpkg --print-installation-architecture)" ARCHITECTURE="$(dpkg --print-installation-architecture)"
LAPTOP=""
if [ -n "$(which laptop-detect)" ]; then
if laptop-detect >/dev/null; then
LAPTOP=true
fi
fi
if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
RECONFIGURE="true" RECONFIGURE="true"
else else
@ -245,19 +238,19 @@ analyze_path () {
# analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin # analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
# Thanks to Randolph Chung for this clever hack. # Thanks to Randolph Chung for this clever hack.
#local f g local f g
while [ -n "$1" ]; do while [ -n "$1" ]; do
reject_whitespace "$1" reject_whitespace "$1"
_g= g=
message "Analyzing $1:" message "Analyzing $1:"
for _f in $(echo "$1" | tr / \ ); do for f in $(echo "$1" | tr / \ ); do
if [ -e /$_g$_f ]; then if [ -e /$g$f ]; then
ls -dl /$_g$_f /$_g$_f.dpkg-* 2> /dev/null || true ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true
_g=$_g$_f/ g=$g$f/
else else
message "/$_g$_f: nonexistent; directory contents of /$_g:" message "/$g$f: nonexistent; directory contents of /$g:"
ls -l /$_g ls -l /$g
break break
fi fi
done done
@ -266,27 +259,27 @@ analyze_path () {
} }
find_culprits () { find_culprits () {
#local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \ local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
# msg msg
reject_whitespace "$1" reject_whitespace "$1"
message "Searching for overlapping packages..." message "Searching for overlapping packages..."
_dpkg_info_dir=/var/lib/dpkg/info dpkg_info_dir=/var/lib/dpkg/info
if [ -d $_dpkg_info_dir ]; then if [ -d $dpkg_info_dir ]; then
if [ "$(echo $_dpkg_info_dir/*.list)" != "$_dpkg_info_dir/*.list" ]; then if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then
_possible_culprits=$(ls -1 $_dpkg_info_dir/*.list | egrep -v \ possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \
"(xbase-clients|x11-common|xfs|xlibs)") "(xbase-clients|x11-common|xfs|xlibs)")
if [ -n "$_possible_culprits" ]; then if [ -n "$possible_culprits" ]; then
_smoking_guns=$(grep -l "$1" $_possible_culprits || true) smoking_guns=$(grep -l "$1" $possible_culprits || true)
if [ -n "$_smoking_guns" ]; then if [ -n "$smoking_guns" ]; then
_bad_packages=$(printf "\\n") bad_packages=$(printf "\\n")
for f in $_smoking_guns; do for f in $smoking_guns; do
# too bad you can't nest parameter expansion voodoo # too bad you can't nest parameter expansion voodoo
p=${f%*.list} # strip off the trailing ".list" p=${f%*.list} # strip off the trailing ".list"
_package=${p##*/} # strip off the directories package=${p##*/} # strip off the directories
_bad_packages=$(printf "%s\n%s" "$_bad_packages" "$_package") bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
done done
_msg=$(cat <<EOF msg=$(cat <<EOF
The following packages appear to have file overlaps with the X.Org packages; The following packages appear to have file overlaps with the X.Org packages;
these packages are either very old, or in violation of Debian Policy. Try these packages are either very old, or in violation of Debian Policy. Try
upgrading each of these packages to the latest available version if possible: upgrading each of these packages to the latest available version if possible:
@ -298,17 +291,17 @@ Tracking System. You may want to refer the package maintainer to section 12.8
of the Debian Policy manual. of the Debian Policy manual.
EOF EOF
) )
message "$_msg" message "$msg"
message "The overlapping packages are: $_bad_packages" message "The overlapping packages are: $bad_packages"
else else
message "no overlaps found." message "no overlaps found."
fi fi
fi fi
else else
message "cannot search; no matches for $_dpkg_info_dir/*.list." message "cannot search; no matches for $dpkg_info_dir/*.list."
fi fi
else else
message "cannot search; $_dpkg_info_dir does not exist." message "cannot search; $dpkg_info_dir does not exist."
fi fi
} }
@ -330,7 +323,7 @@ check_symlink () {
# #
# Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb(). # Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
#local symlink local symlink
# validate arguments # validate arguments
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
@ -339,9 +332,9 @@ check_symlink () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_symlink="$1" symlink="$1"
if [ "$(maplink "$_symlink")" = "$(readlink "$_symlink")" ]; then if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
return 0 return 0
else else
return 1 return 1
@ -356,7 +349,7 @@ check_symlinks_and_warn () {
# Call this function from a preinst script in the event $1 is "upgrade" or # Call this function from a preinst script in the event $1 is "upgrade" or
# "install". # "install".
#local errmsg symlink local errmsg symlink
# validate arguments # validate arguments
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
@ -366,25 +359,25 @@ check_symlinks_and_warn () {
fi fi
while [ -n "$1" ]; do while [ -n "$1" ]; do
_symlink="$1" symlink="$1"
if [ -L "$_symlink" ]; then if [ -L "$symlink" ]; then
if ! check_symlink "$_symlink"; then if ! check_symlink "$symlink"; then
observe "$_symlink symbolic link points to wrong location" \ observe "$symlink symbolic link points to wrong location" \
"$(readlink "$_symlink"); removing" "$(readlink "$symlink"); removing"
rm "$_symlink" rm "$symlink"
fi fi
elif [ -e "$_symlink" ]; then elif [ -e "$symlink" ]; then
_errmsg="$_symlink exists and is not a symbolic link; this package cannot" errmsg="$symlink exists and is not a symbolic link; this package cannot"
_errmsg="$_errmsg be installed until this" errmsg="$errmsg be installed until this"
if [ -f "$_symlink" ]; then if [ -f "$symlink" ]; then
_errmsg="$_errmsg file" errmsg="$errmsg file"
elif [ -d "$_symlink" ]; then elif [ -d "$symlink" ]; then
_errmsg="$_errmsg directory" errmsg="$errmsg directory"
else else
_errmsg="$_errmsg thing" errmsg="$errmsg thing"
fi fi
_errmsg="$_errmsg is removed" errmsg="$errmsg is removed"
die "$_errmsg" die "$errmsg"
fi fi
shift shift
done done
@ -397,7 +390,7 @@ check_symlinks_and_bomb () {
# #
# Call this function from a postinst script. # Call this function from a postinst script.
#local problem symlink local problem symlink
# validate arguments # validate arguments
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
@ -407,24 +400,24 @@ check_symlinks_and_bomb () {
fi fi
while [ -n "$1" ]; do while [ -n "$1" ]; do
_problem= problem=
_symlink="$1" symlink="$1"
if [ -L "$_symlink" ]; then if [ -L "$symlink" ]; then
if ! check_symlink "$_symlink"; then if ! check_symlink "$symlink"; then
_problem=yes problem=yes
warn "$_symlink symbolic link points to wrong location" \ warn "$symlink symbolic link points to wrong location" \
"$(readlink "$_symlink")" "$(readlink "$symlink")"
fi fi
elif [ -e "$_symlink" ]; then elif [ -e "$symlink" ]; then
_problem=yes problem=yes
warn "$_symlink is not a symbolic link" warn "$symlink is not a symbolic link"
else else
_problem=yes problem=yes
warn "$_symlink symbolic link does not exist" warn "$symlink symbolic link does not exist"
fi fi
if [ -n "$_problem" ]; then if [ -n "$problem" ]; then
analyze_path "$_symlink" "$(readlink "$_symlink")" analyze_path "$symlink" "$(readlink "$symlink")"
find_culprits "$_symlink" find_culprits "$symlink"
die "bad symbolic links on system" die "bad symbolic links on system"
fi fi
shift shift
@ -434,9 +427,9 @@ check_symlinks_and_bomb () {
font_update () { font_update () {
# run $UPDATECMDS in $FONTDIRS # run $UPDATECMDS in $FONTDIRS
#local dir cmd shortcmd x_font_dir_prefix local dir cmd shortcmd x_font_dir_prefix
_x_font_dir_prefix="/usr/share/fonts/X11" x_font_dir_prefix="/usr/share/fonts/X11"
if [ -z "$UPDATECMDS" ]; then if [ -z "$UPDATECMDS" ]; then
usage_error "font_update() called but \$UPDATECMDS not set" usage_error "font_update() called but \$UPDATECMDS not set"
@ -448,32 +441,32 @@ font_update () {
reject_unlikely_path_chars "$UPDATECMDS" reject_unlikely_path_chars "$UPDATECMDS"
reject_unlikely_path_chars "$FONTDIRS" reject_unlikely_path_chars "$FONTDIRS"
for _dir in $FONTDIRS; do for dir in $FONTDIRS; do
if [ -d "$_x_font_dir_prefix/$_dir" ]; then if [ -d "$x_font_dir_prefix/$dir" ]; then
for _cmd in $UPDATECMDS; do for cmd in $UPDATECMDS; do
if which "$_cmd" > /dev/null 2>&1; then if which "$cmd" > /dev/null 2>&1; then
_shortcmd=${_cmd##*/} shortcmd=${cmd##*/}
observe "running $_shortcmd in $_dir font directory" observe "running $shortcmd in $dir font directory"
_cmd_opts= cmd_opts=
if [ "$_shortcmd" = "update-fonts-alias" ]; then if [ "$shortcmd" = "update-fonts-alias" ]; then
_cmd_opts=--x11r7-layout cmd_opts=--x11r7-layout
fi fi
if [ "$_shortcmd" = "update-fonts-dir" ]; then if [ "$shortcmd" = "update-fonts-dir" ]; then
_cmd_opts=--x11r7-layout cmd_opts=--x11r7-layout
fi fi
if [ "$_shortcmd" = "update-fonts-scale" ]; then if [ "$shortcmd" = "update-fonts-scale" ]; then
_cmd_opts=--x11r7-layout cmd_opts=--x11r7-layout
fi fi
$_cmd $_cmd_opts $_dir || warn "$_cmd $_cmd_opts $_dir" \ $cmd $cmd_opts $dir || warn "$cmd $cmd_opts $dir" \
"failed; font directory data may not" \ "failed; font directory data may not" \
"be up to date" "be up to date"
else else
warn "$_cmd not found; not updating corresponding $_dir font" \ warn "$cmd not found; not updating corresponding $dir font" \
"directory data" "directory data"
fi fi
done done
else else
warn "$_dir is not a directory; not updating font directory data" warn "$dir is not a directory; not updating font directory data"
fi fi
done done
} }
@ -492,7 +485,7 @@ remove_conffile_prepare () {
# version (or installed over a version removed-but-not-purged) prior to the # version (or installed over a version removed-but-not-purged) prior to the
# one in which the conffile was obsoleted. # one in which the conffile was obsoleted.
#local conffile current_checksum local conffile current_checksum
# validate arguments # validate arguments
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
@ -501,19 +494,19 @@ remove_conffile_prepare () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_conffile="$1" conffile="$1"
shift shift
# does the _conffile even exist? # does the conffile even exist?
if [ -e "$_conffile" ]; then if [ -e "$conffile" ]; then
# calculate its checksum # calculate its checksum
_current_checksum=$(md5sum < "$_conffile" | sed 's/[[:space:]].*//') current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//')
# compare it to each supplied checksum # compare it to each supplied checksum
while [ -n "$1" ]; do while [ -n "$1" ]; do
if [ "$_current_checksum" = "$1" ]; then if [ "$current_checksum" = "$1" ]; then
# we found a match; move the confffile and stop looking # we found a match; move the confffile and stop looking
observe "preparing obsolete conffile $_conffile for removal" observe "preparing obsolete conffile $conffile for removal"
mv "$_conffile" "$_conffile.$THIS_PACKAGE-tmp" mv "$conffile" "$conffile.$THIS_PACKAGE-tmp"
break break
fi fi
shift shift
@ -521,6 +514,37 @@ remove_conffile_prepare () {
fi fi
} }
remove_conffile_lookup () {
# syntax: remove_conffile_lookup package filename
#
# Lookup the md5sum of a conffile in dpkg's database, and prepare for removal
# if it matches the actual file's md5sum.
#
# Call this function when you would call remove_conffile_prepare but only
# want to check against dpkg's status database instead of known checksums.
local package conffile old_md5sum
# validate arguments
if [ $# -ne 2 ]; then
usage_error "remove_conffile_lookup() called with wrong number of" \
"arguments; expected 1, got $#"
exit $SHELL_LIB_USAGE_ERROR
fi
package="$1"
conffile="$2"
if ! [ -e "$conffile" ]; then
return
fi
old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$package" | \
awk '{ if (match($0, "^ '"$conffile"' ")) print $2}')"
if [ -n "$old_md5sum" ]; then
remove_conffile_prepare "$conffile" "$old_md5sum"
fi
}
remove_conffile_commit () { remove_conffile_commit () {
# syntax: remove_conffile_commit filename # syntax: remove_conffile_commit filename
# #
@ -529,7 +553,7 @@ remove_conffile_commit () {
# Call this function from a postinst script after having used # Call this function from a postinst script after having used
# remove_conffile_prepare() in the preinst. # remove_conffile_prepare() in the preinst.
#local conffile local conffile
# validate arguments # validate arguments
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
@ -538,12 +562,12 @@ remove_conffile_commit () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_conffile="$1" conffile="$1"
# if the temporary file created by remove_conffile_prepare() exists, remove it # if the temporary file created by remove_conffile_prepare() exists, remove it
if [ -e "$_conffile.$THIS_PACKAGE-tmp" ]; then if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
observe "committing removal of obsolete conffile $_conffile" observe "committing removal of obsolete conffile $conffile"
rm "$_conffile.$THIS_PACKAGE-tmp" rm "$conffile.$THIS_PACKAGE-tmp"
fi fi
} }
@ -556,7 +580,7 @@ remove_conffile_rollback () {
# or "abort-install" is after having used remove_conffile_prepare() in the # or "abort-install" is after having used remove_conffile_prepare() in the
# preinst. # preinst.
#local conffile local conffile
# validate arguments # validate arguments
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
@ -565,13 +589,13 @@ remove_conffile_rollback () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_conffile="$1" conffile="$1"
# if the temporary file created by remove_conffile_prepare() exists, move it # if the temporary file created by remove_conffile_prepare() exists, move it
# back # back
if [ -e "$_conffile.$THIS_PACKAGE-tmp" ]; then if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
observe "rolling back removal of obsolete conffile $_conffile" observe "rolling back removal of obsolete conffile $conffile"
mv "$_conffile.$THIS_PACKAGE-tmp" "$_conffile" mv "$conffile.$THIS_PACKAGE-tmp" "$conffile"
fi fi
} }
@ -591,7 +615,7 @@ replace_conffile_with_symlink_prepare () {
# version (or installed over a version removed-but-not-purged) prior to the # version (or installed over a version removed-but-not-purged) prior to the
# one in which the conffile was obsoleted. # one in which the conffile was obsoleted.
#local conffile current_checksum local conffile current_checksum
# validate arguments # validate arguments
if [ $# -lt 3 ]; then if [ $# -lt 3 ]; then
@ -600,16 +624,16 @@ replace_conffile_with_symlink_prepare () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_oldconffile="$1" oldconffile="$1"
shift shift
_newconffile="$1" newconffile="$1"
shift shift
remove_conffile_prepare "$_oldconffile" "$@" remove_conffile_prepare "$_oldconffile" "$@"
# If $_oldconffile still exists, then md5sums didn't match. # If $oldconffile still exists, then md5sums didn't match.
# Copy it to new one. # Copy it to new one.
if [ -f "$_oldconffile" ]; then if [ -f "$oldconffile" ]; then
cp "$_oldconffile" "$_newconffile" cp "$oldconffile" "$newconffile"
fi fi
} }
@ -623,7 +647,7 @@ replace_conffile_with_symlink_commit () {
# Call this function from a postinst script after having used # Call this function from a postinst script after having used
# replace_conffile_with_symlink_prepare() in the preinst. # replace_conffile_with_symlink_prepare() in the preinst.
#local conffile local conffile
# validate arguments # validate arguments
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
@ -632,9 +656,9 @@ replace_conffile_with_symlink_commit () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_conffile="$1" conffile="$1"
remove_conffile_commit "$_conffile" remove_conffile_commit "$conffile"
} }
replace_conffile_with_symlink_rollback () { replace_conffile_with_symlink_rollback () {
@ -650,7 +674,7 @@ replace_conffile_with_symlink_rollback () {
# You should have used replace_conffile_with_symlink_prepare() in the # You should have used replace_conffile_with_symlink_prepare() in the
# preinst. # preinst.
#local conffile local conffile
# validate arguments # validate arguments
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
@ -659,12 +683,12 @@ replace_conffile_with_symlink_rollback () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
_oldconffile="$1" oldconffile="$1"
_newconffile="$2" newconffile="$2"
remove_conffile_rollback "$_oldconffile" remove_conffile_rollback "$_oldconffile"
if [ -f "$_newconffile" ]; then if [ -f "$newconffile" ]; then
rm "$_newconffile" rm "$newconffile"
fi fi
} }
@ -679,7 +703,7 @@ run () {
# those cases the return value of the debconf command *must* be checked # those cases the return value of the debconf command *must* be checked
# before the string returned by debconf is used for anything. # before the string returned by debconf is used for anything.
#local retval local retval
# validate arguments # validate arguments
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
@ -688,10 +712,10 @@ run () {
exit $SHELL_LIB_USAGE_ERROR exit $SHELL_LIB_USAGE_ERROR
fi fi
"$@" || _retval=$? "$@" || retval=$?
if [ ${_retval:-0} -ne 0 ]; then if [ ${retval:-0} -ne 0 ]; then
observe "command \"$*\" exited with status $_retval" observe "command \"$*\" exited with status $retval"
fi fi
} }
@ -704,15 +728,15 @@ register_x_lib_dir_with_ld_so () {
# Call this function from the postinst script of a package that places a # Call this function from the postinst script of a package that places a
# shared library in /usr/X11R6/lib, before invoking ldconfig. # shared library in /usr/X11R6/lib, before invoking ldconfig.
#local dir ldsoconf local dir ldsoconf
_dir="/usr/X11R6/lib" dir="/usr/X11R6/lib"
_ldsoconf="/etc/ld.so.conf" ldsoconf="/etc/ld.so.conf"
# is the line not already present? # is the line not already present?
if ! fgrep -qsx "$_dir" "$_ldsoconf"; then if ! fgrep -qsx "$dir" "$ldsoconf"; then
observe "adding $_dir directory to $_ldsoconf" observe "adding $dir directory to $ldsoconf"
echo "$_dir" >> "$_ldsoconf" echo "$dir" >> "$ldsoconf"
fi fi
} }
@ -726,36 +750,36 @@ deregister_x_lib_dir_with_ld_so () {
# library in /usr/X11R6/lib, in the event "$1" is "remove", and before # library in /usr/X11R6/lib, in the event "$1" is "remove", and before
# invoking ldconfig. # invoking ldconfig.
#local dir ldsoconf fgrep_status cmp_status local dir ldsoconf fgrep_status cmp_status
_dir="/usr/X11R6/lib" dir="/usr/X11R6/lib"
_ldsoconf="/etc/ld.so.conf" ldsoconf="/etc/ld.so.conf"
# is the line present? # is the line present?
if fgrep -qsx "$_dir" "$_ldsoconf"; then if fgrep -qsx "$dir" "$ldsoconf"; then
# are there any shared objects in the directory? # are there any shared objects in the directory?
if [ "$(echo "$_dir"/lib*.so.*.*)" = "$_dir/lib*.so.*.*" ]; then if [ "$(echo "$dir"/lib*.so.*.*)" = "$dir/lib*.so.*.*" ]; then
# glob expansion produced nothing, so no shared libraries are present # glob expansion produced nothing, so no shared libraries are present
observe "removing $_dir directory from $_ldsoconf" observe "removing $dir directory from $ldsoconf"
# rewrite the file (very carefully) # rewrite the file (very carefully)
set +e set +e
fgrep -svx "$_dir" "$_ldsoconf" > "$_ldsoconf.dpkg-tmp" fgrep -svx "$dir" "$ldsoconf" > "$ldsoconf.dpkg-tmp"
_fgrep_status=$? fgrep_status=$?
set -e set -e
case $_fgrep_status in case $fgrep_status in
0|1) ;; # we don't actually care if any lines matched or not 0|1) ;; # we don't actually care if any lines matched or not
*) die "error reading \"$_ldsoconf\"; fgrep exited with status" \ *) die "error reading \"$ldsoconf\"; fgrep exited with status" \
"$_fgrep_status" ;; "$fgrep_status" ;;
esac esac
set +e set +e
cmp -s "$_ldsoconf.dpkg-tmp" "$_ldsoconf" cmp -s "$ldsoconf.dpkg-tmp" "$ldsoconf"
_cmp_status=$? cmp_status=$?
set -e set -e
case $_cmp_status in case $cmp_status in
0) rm "$_ldsoconf.dpkg-tmp" ;; # files are identical 0) rm "$ldsoconf.dpkg-tmp" ;; # files are identical
1) mv "$_ldsoconf.dpkg-tmp" "$_ldsoconf" ;; # files differ 1) mv "$ldsoconf.dpkg-tmp" "$ldsoconf" ;; # files differ
*) die "error comparing \"$_ldsoconf.dpkg-tmp\" to \"$_ldsoconf\";" \ *) die "error comparing \"$ldsoconf.dpkg-tmp\" to \"$ldsoconf\";" \
"cmp exited with status $_cmp_status" ;; "cmp exited with status $cmp_status" ;;
esac esac
fi fi
fi fi
@ -787,17 +811,17 @@ make_symlink_sane () {
# We could just use the positional parameters as-is, but that makes things # We could just use the positional parameters as-is, but that makes things
# harder to follow. # harder to follow.
#local symlink target local symlink target
_symlink="$1" symlink="$1"
_target="$2" target="$2"
if [ -L "$_symlink" ] && [ "$(readlink "$_symlink")" = "$_target" ]; then if [ -L "$symlink" ] && [ "$(readlink "$symlink")" = "$target" ]; then
observe "link from $_symlink to $_target already exists" observe "link from $symlink to $target already exists"
else else
observe "creating symbolic link from $_symlink to $_target" observe "creating symbolic link from $symlink to $target"
mkdir -p "${_target%/*}" "${_symlink%/*}" mkdir -p "${target%/*}" "${symlink%/*}"
ln -s -b -S ".dpkg-old" "$_target" "$_symlink" ln -s -b -S ".dpkg-old" "$target" "$symlink"
fi fi
} }
@ -833,73 +857,73 @@ migrate_dir_to_symlink () {
# We could just use the positional parameters as-is, but that makes things # We could just use the positional parameters as-is, but that makes things
# harder to follow. # harder to follow.
local _new _old local new old
_old="$1" old="$1"
_new="$2" new="$2"
# Is old location a symlink? # Is old location a symlink?
if [ -L "$_old" ]; then if [ -L "$old" ]; then
# Does it already point to new location? # Does it already point to new location?
if [ "$(readlink "$_old")" = "$_new" ]; then if [ "$(readlink "$old")" = "$new" ]; then
# Nothing to do; migration has already been done. # Nothing to do; migration has already been done.
observe "migration of $_old to $_new already done" observe "migration of $old to $new already done"
return 0 return 0
else else
# Back it up. # Back it up.
warn "backing up symbolic link $_old as $_old.dpkg-old" warn "backing up symbolic link $old as $old.dpkg-old"
mv -b "$_old" "$_old.dpkg-old" mv -b "$old" "$old.dpkg-old"
fi fi
fi fi
# Does old location exist, but is not a directory? # Does old location exist, but is not a directory?
if [ -e "$_old" ] && ! [ -d "$_old" ]; then if [ -e "$old" ] && ! [ -d "$old" ]; then
# Back it up. # Back it up.
warn "backing up non-directory $_old as $_old.dpkg-old" warn "backing up non-directory $old as $old.dpkg-old"
mv -b "$_old" "$_old.dpkg-old" mv -b "$old" "$old.dpkg-old"
fi fi
observe "migrating $_old to $_new" observe "migrating $old to $new"
# Is new location a symlink? # Is new location a symlink?
if [ -L "$_new" ]; then if [ -L "$new" ]; then
# Does it point the wrong way, i.e., back to where we're migrating from? # Does it point the wrong way, i.e., back to where we're migrating from?
if [ "$(readlink "$_new")" = "$_old" ]; then if [ "$(readlink "$new")" = "$old" ]; then
# Get rid of it. # Get rid of it.
observe "removing symbolic link $_new which points to $_old" observe "removing symbolic link $new which points to $old"
rm "$_new" rm "$new"
else else
# Back it up. # Back it up.
warn "backing up symbolic link $_new as $_new.dpkg-old" warn "backing up symbolic link $new as $new.dpkg-old"
mv -b "$_new" "$_new.dpkg-old" mv -b "$new" "$new.dpkg-old"
fi fi
fi fi
# Does new location exist, but is not a directory? # Does new location exist, but is not a directory?
if [ -e "$_new" ] && ! [ -d "$_new" ]; then if [ -e "$new" ] && ! [ -d "$new" ]; then
warn "backing up non-directory $_new as $_new.dpkg-old" warn "backing up non-directory $new as $new.dpkg-old"
mv -b "$_new" "$_new.dpkg-old" mv -b "$new" "$new.dpkg-old"
fi fi
# Create new directory if it does not yet exist. # Create new directory if it does not yet exist.
if ! [ -e "$_new" ]; then if ! [ -e "$new" ]; then
observe "creating $_new" observe "creating $new"
mkdir -p "$_new" mkdir -p "$new"
fi fi
# Copy files in old location to new location. Back up any filenames that # Copy files in old location to new location. Back up any filenames that
# already exist in the new location with the extension ".dpkg-old". # already exist in the new location with the extension ".dpkg-old".
observe "copying files from $_old to $_new" observe "copying files from $old to $new"
if ! (cd "$_old" && cp -a -b -S ".dpkg-old" . "$_new"); then if ! (cd "$old" && cp -a -b -S ".dpkg-old" . "$new"); then
die "error(s) encountered while copying files from $_old to $_new" die "error(s) encountered while copying files from $old to $new"
fi fi
# Remove files at old location. # Remove files at old location.
observe "removing $_old" observe "removing $old"
rm -r "$_old" rm -r "$old"
# Create symlink from old location to new location. # Create symlink from old location to new location.
make_symlink_sane "$_old" "$_new" make_symlink_sane "$old" "$new"
} }
# vim:set ai et sw=2 ts=2 tw=80: # vim:set ai et sw=2 ts=2 tw=80: