[Pkg-mediawiki-devel] Bug#409434: Making mediawiki FHS compliant
(was: Upgrade)
Frank Küster
frank at kuesterei.ch
Thu Feb 22 11:17:41 CET 2007
Steve Langasek <vorlon at debian.org> wrote:
> On Wed, Feb 21, 2007 at 12:54:38PM +0100, Frank Küster wrote:
>> To me that looks a bit more complicated than one would like, but still
>> quite manageable, and acceptable for fixing a RC bug in etch.
>
>> What do you think?
>
> It's at least an order of magnitude more complicated (=error-prone) than the
> solution Romain has implemented,
That's correct, not solving the FHS violation is simpler than doing it.
> and it still doesn't address the FHS
> requirement for the actual configuration to be stored under /etc, so I don't
> see the point.
Then we misunderstood each other. I'm always talking about moving the
actual configuration (LocalSettings.php and AdminSettings.php) to
/etc/mediawiki1.7.
The old package does not ship any of these files. They are created by a
menu-driven php script, and the local admin is instructed to put the
created files into /var/lib/mediawiki1.7.
The new package would instruct the local admin to put them in
/etc/mediawiki1.7, it would ship symlinks in /var/lib/mediawiki1.7/ so
that they are found, and add a one-line patch to the templates for each
of these files to get the internal path information right.
So far, so simple. The only complicated bit is the transition, it would
look like I've written (but not tested) below.
Regards, Frank
******* preinst *******
etcdir=/etc/mediawiki1.7
vardir=/var/lib/mediawiki1.7
movext=".moved-by-preinst"
for file in LocalSettings.php AdminSettings.php; do
etcfile=$etcdir/$file
# there might already be a symlink in $vardir, but to a non-default location
if [ -L $vardir/$file ]; then
# register that $etcdir is a good default
touch $etcfile.etcdefault
linkdest="`readlink $vardir/file`"
if [ ! "$etcfile" = "$linkdest" ]; then
if [ -e "$linkdest" ]; then
mv $linkdest $etcfile
chmod --reference $linkdest $etcfile
chown --reference $linkdest $etcfile
cat > $linkdest <<EOF
This file has been moved to
$etcfile
by mediawiki1.7's maintainer scripts
EOF
fi
# still a symlink from old install? No longer needed
if [ -L $etcfile ]; then rm $etcfile; fi
# can we move the file from $vardir to its new location at once?
if [ -e $etcfile ]; then
destfile=$etcdir/$file$movext
else
destfile=$etcdir/$file
fi
if [ -f $vardir/$file ]; then
# ordinary file, move to $etcdir
mv $vardir/$file $destfile
# else
# Nothing, I assume dpkg will change the symlink dest itself
fi
done
******* preinst *******
******* config *******
movext=".moved-by-preinst"
for file in LocalSettings.php AdminSettings.php; do
if [ -e $etcdir/$file$movext* ]; then
if [ -f $etcdir/$file.etcdefault ]; then
db_set mediawiki/FHSmove$file $etcdir
fi
db_input low mediawiki/FHSmove$file || true
fi
done
db_go || true
******* config *******
******* postinst *******
etcdir=/etc/mediawiki1.7
vardir=/var/lib/mediawiki1.7
movext=".moved-by-preinst"
for file in LocalSettings.php AdminSettings.php; do
etcfile=$etcdir/$file
if [ -e "$etcfile$movext" ]; then
db_get mediawiki/FHSmove$file || true
which="$RET" # can be /etc/mediawiki1.7 or /var/lib/mediawiki1.7
if [ "$which" = "/var/lib/mediawiki1.7" ]; then
test ! -e $etcfile || mv $etcfile $etcfile/$file.moved-by-postiinst
mv $etcfile.movext $etcfile
sed -i 's at pattern_depends_on_PHP_patch@pattern_depends_on_PHP_patch@' $etcfile
else
mv $etcfile.movext $etcfile.moved-from-var-directory
fi
rm $etcfile.etcdefault 2>/dev/null || true
fi
done
******* postinst *******
******* templates *******
Template: mediawiki/FHSmoveLocalSettings.php
Type: select
Choices: /etc/mediawiki1.7, /var/lib/mediawiki1.7
Default: /var/lib/mediawiki1.7
Description_: Which of two mediawiki1.7 configuration files should be used?
In older versions, mediawiki1.7 kept the configuration file
LocalSettings.php in its data directory, /var/lib/mediawiki1.7, but now
it will be searched for in /etc/mediawiki1.7. The system has detected
that you already have this file in /etc, too.
.
From which location should the new configuration file be taken?
.
If your installation of Mediawiki worked as intended in the past, it is
safe to take the default.
[repeat the same for AminSettings.php]
******* templates *******
--
Dr. Frank Küster
Single Molecule Spectroscopy, Protein Folding @ Inst. f. Biochemie, Univ. Zürich
Debian Developer (teTeX/TeXLive)
More information about the Pkg-mediawiki-devel
mailing list