slackware-current/testing/source/pkgtools/doinst.sh
Patrick J Volkerding 7e5ee73de9 Tue Jun 19 22:35:25 UTC 2018
a/acl-2.2.53-x86_64-1.txz:  Upgraded.
a/attr-2.4.48-x86_64-1.txz:  Upgraded.
n/gnupg-1.4.23-x86_64-1.txz:  Upgraded.
  Sanitize the diagnostic output of the original file name in verbose mode.
  By using a made up file name in the message it was possible to fake status
  messages. Using this technique it was for example possible to fake the
  verification status of a signed mail.
  For more information, see:
    https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-12020
  (* Security fix *)
x/libXaw3d-1.6.3-x86_64-1.txz:  Upgraded.
x/libinput-1.11.1-x86_64-1.txz:  Upgraded.
x/xf86-input-mouse-1.9.3-x86_64-1.txz:  Upgraded.
testing/packages/pkgtools-15.0-noarch-20.txz:  Rebuilt.
  This update is a bit scarier than usual, so we're going to test it here
  first and then move it into the main tree in a couple of days if there
  are no serious bug reports. It's well-tested here, and works with the
  slackpkg that's in -current now, but I don't know about slackpkg+ so that's
  another reason to let it cool down here first. The purpose of this update
  is to migrate the package database and directories from /var/log to
  /var/lib/pkgtools. /var/log was never a good place for this data, as it is
  considered by many to be a directory that could be wiped to free up some
  space. Originally the package database was in /var/adm, but the FSSTND
  (later FHS) group decided that directory should be a symlink to /var/log,
  and I went along with that since it was years ago and I was a n00b and didn't
  know any better. /var/lib/pkgtools will be a better and safer location.
  The removed_packages and removed_scripts directories are really just logs
  that aren't actually used for anything - those will remain under /var/log,
  but moved into /var/log/pkgtools. Everything under /var/log will be
  considered potentially non-permanent by the pkgtools - if any directories or
  symlinks disappear from there, the pkgtools will automatically recreate them
  as needed. In fact, the migration process will create symlinks from all the
  old directory locations to the new ones, so anything that expects the old
  locations (including slackpkg, for now) should continue to work. Once this
  moves into the main tree, the plan is to fix other packages to use the new
  installer script directory (/var/lib/pkgtools/setup) and change the installer
  and slackpkg to use the new native locations for everything. When slackpkg
  is changed over to use the new native locations, I'll also make sure to float
  that in testing/ for a few days before moving it to the main tree to avoid
  more unintentional disruption to slackpkg+ users.
  Be aware that the package database migration is a one-way operation, but even
  so if you later downgrade to an older version of the pkgtools it will still
  work through the compatibility symlinks.
2018-06-20 09:00:31 +02:00

69 lines
2.7 KiB
Bash

#!/bin/bash
# Migrate the package database and related directories from the long-time
# (stupid) directory /var/log to /var/lib/pkgtools.
#
# The removed_* directories will remain under /var/log (but moved to
# /var/log/pkgtools) as they contain log files of previous operations,
# not anything that's actively used for package management. Also, the
# removed_* directories can become quite large compared with the database.
#
# First, if it's just a case of missing symlinks, make them. Don't make them
# if the directories exist in /var/log - we'll do a proper migration in that
# case.
for directory in packages scripts setup ; do
if [ ! -L var/log/$directory -a ! -d var/log/$directory ]; then
if [ -d var/lib/pkgtools/$directory ]; then
# Make the symlink:
( cd var/log ; ln -sf ../lib/pkgtools/$directory . )
fi
fi
done
for directory in removed_packages removed_scripts ; do
if [ ! -L var/log/$directory -a ! -d var/log/$directory ]; then
mkdir -p var/log/pkgtools/$directory
( cd var/log ; ln -sf pkgtools/$directory . )
fi
if [ ! -L var/lib/pkgtools/$directory -a ! -d var/lib/pkgtools/$directory ]; then
mkdir -p var/lib/pkgtools
( cd var/lib/pkgtools ; ln -sf ../../log/pkgtools/$directory . )
fi
done
# If at this point /var/log/packages is not a symlink, we need to do the
# migration. We should already have a lock on being the only install script
# that's currently running, but also get a lock on ldconfig to freeze any
# other package operations that are happening now until after the migration
# is complete.
if [ ! -L var/log/packages ]; then
if [ ! -d run/lock/pkgtools ]; then
mkdir -p run/lock/pkgtools
fi
( flock 9 || exit 11
# Don't migrate if tar is running, as there may still be package operations
# going on in another process:
while pidof tar 1> /dev/null 2> /dev/null ; do
sleep 15
done
# Just to be a bit safer from race conditions:
sleep 5
# First, move the removed_* directories into a pkgtools subdirectory:
mkdir -p var/log/pkgtools
for directory in removed_packages removed_scripts ; do
if [ ! -d var/log/pkgtools/$directory ]; then
mkdir -p var/log/pkgtools/$directory
# Move anything found in the old location, then remove it:
mv var/log/$directory/* var/log/pkgtools/$directory 2> /dev/null
rm -rf var/log/$directory
# Make a symlink:
( cd var/log ; ln -sf pkgtools/$directory . )
fi
done
for directory in packages scripts setup ; do
mkdir -p var/lib/pkgtools/$directory
mv var/log/$directory/* var/lib/pkgtools/$directory 2> /dev/null
rm -rf var/log/$directory
( cd var/log
ln -sf ../lib/pkgtools/$directory .
)
done
) 9> run/lock/pkgtools/ldconfig.lock
fi