cleanup scripts rehashed

There's much reason for reuse instead of duplication
among the different stage2-based subprofiles.

In particular, the rather monolithic driver cleanup script
of the ancient is better done in several clear pieces with
the final depmod run.

Scripts dropping apt/rpm databases will dump pkglist first.

A script purging /boot/* will honour live-install if present.

Minor inno^Wfixups all over the map too.
This commit is contained in:
Michael Shigorin 2012-03-30 23:48:00 +03:00
parent ea5ae29ada
commit 1b885b3d24
17 changed files with 72 additions and 32 deletions

View File

@ -2,6 +2,7 @@
# FIXME: there should be less brutal i18n tuning
cd /usr/share/locale
rm -r *@*
for i in */; do
case "$i" in
be*|en*|ru*|uk*) continue;;

View File

@ -0,0 +1,5 @@
#!/bin/sh
# remove all docs
rpmquery -ad |grep ^/ |xargs -r rm -f --
rm -rf /usr/share/{doc,man,info,license,gfxboot}

View File

@ -1,3 +1,15 @@
#!/bin/sh
# remove rpm, apt databases and cache
find /var/lib/rpm /var/lib/apt /var/cache/apt -type f -delete
# dump what's here by this point
echo "** live packages before rpmdb purge:"
rpmquery -a --qf='%{NAME} %{VERSION}-%{RELEASE}\n'
# remove apt database and cache
find /var/lib/apt /var/cache/apt -type f -delete
# not going to need them without rpmdb, it's not even rescue anymore
rpm -e --nodeps apt libapt rpm librpmbuild librpm 2>/dev/null ||:
# finally, drop rpmdb
find /var/lib/rpm -type f -delete
:

View File

@ -1,4 +1,4 @@
#!/bin/sh -x
#!/bin/sh
# create a barebone bootable freedos floppy
# TODO: some sub-framework to populate it as well

View File

@ -27,6 +27,4 @@ rpmquery -a cpp\* gcc\* perl-base file ipv6calc \
rpmquery -a bind-utils libbind \
| xargs -r rpmi -e --
# outstanding binaries
rm -f /sbin/{sln,tc}
rm -f /usr/bin/openssl
:

View File

@ -107,17 +107,3 @@ rm -rf /lib/modules/*/kernel/net/tipc
rm -rf /lib/modules/*/kernel/net/{wimax,wireless,mac80211}
rm -rf /lib/modules/*/kernel/net/x25
rm -rf /lib/modules/*/kernel/sound
# blacklisted kernel modules
sed -n 's/^blacklist[[:space:]]\+\([^[:space:]]\+\).*/\1/p' /etc/modprobe.d/* |
while read i; do
find /lib/modules/ -type f -name "$i.ko" -delete
done
# regenerate module dependencies
for i in /lib*/modules/*; do
/sbin/depmod -a -F /boot/System.map-${i##*/} ${i##*/}
done
# kernel images
rm -rf /boot/*

View File

@ -12,11 +12,14 @@ rm -f /usr/lib*/gconv/BIG5*
rm -f /usr/lib*/gconv/EBCDIC*
# en_* variations
rm -rf /usr/{lib*,share}/locale/en_[^U]*
rm -rf /usr/{lib,share}/locale/en_[^U]*
# mods
rm -rf /usr/{lib,share}/locale/*@*
# non-utf8 locales
find /usr/lib*/locale -mindepth 1 -maxdepth 1 -type d \! -name '*.utf8' -print0 |
find /usr/lib/locale -mindepth 1 -maxdepth 1 -type d \! -name '*.utf8' -print0 |
xargs -r0 rm -rf --
# dangling symlinks
find /usr/lib*/locale \! -readable -delete
find /usr/lib/locale \! -readable -delete

View File

@ -1,3 +1,12 @@
#!/bin/sh
# dump what's here by this point
echo "** install2 packages before rpmdb purge:"
rpmquery -a --qf='%{NAME} %{VERSION}-%{RELEASE}\n'
# not going to need them without rpmdb, it's not even rescue anymore
apt-get remove -f -y apt libapt
# remove rpm, apt databases and cache
find /var/lib/rpm /var/lib/apt /var/cache/apt -type f -delete
:

View File

@ -1,4 +1,4 @@
#!/bin/sh -x
#!/bin/sh
# * reset password for root
# * add user `altlinux' (without password)

View File

@ -1,6 +0,0 @@
#!/bin/sh
# we don't really need the kernel in live root,
# it's been booted already (unless it's a live-install)
rpm -q live-install || rm -f /boot/*
:

View File

@ -1,4 +1,4 @@
#!/bin/sh -x
#!/bin/sh
# postprocess isolinux configuration
# when the image sizes are finally known

View File

@ -14,7 +14,7 @@ cd /usr/share/X11/locale && rm -rf ja* ko* th* vi* zh*
cd /usr/share/X11/xkb/symbols && rm -rf jp kr th vn cn
# locales
cd /usr/lib*/locale && rm -rf ja_* ko_* th_* zh_*
cd /usr/lib/locale && rm -rf ja_* ko_* th_* zh_*
# gconv
cd /usr/lib*/gconv && rm -f JIS* T*

View File

@ -0,0 +1,6 @@
#!/bin/sh
# outstanding binaries
rm -f /sbin/{sash,sln,tc}
rm -f /usr/bin/{openssl,ipv6log*}
rm -f /bin/ipv6calc

View File

@ -0,0 +1,5 @@
#!/bin/sh
# no sense in xorg-dri-* without kernel-modules-drm*
stat /lib/modules/*/kernel/drivers/gpu/drm >&/dev/null \
|| rm -rf /usr/lib*/X11/modules/dri/

View File

@ -0,0 +1,7 @@
#!/bin/sh
# blacklisted kernel modules
sed -n 's/^blacklist[[:space:]]\+\([^[:space:]]\+\).*/\1/p' /etc/modprobe.d/* |
while read i; do
find /lib/modules/ -type f -name "$i.ko" -delete
done

View File

@ -0,0 +1,8 @@
#!/bin/sh
# regenerate module dependencies after pruning kernel modules
# (this script must run after anything touching /lib/modules)
cd /lib/modules
for i in *.*; do
depmod -a -F /boot/System.map-$i $i
done

View File

@ -0,0 +1,6 @@
#!/bin/sh
# no need for the kernel in live root
# (unless it's a live-install):
# it's been booted already
[ -x /usr/sbin/live-install ] || rm -f /boot/*