Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 825208 Details for
Bug 1031243
glibc: [RFE] build-locale-archive should have a --prefix option.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Script to shrink locale-archive safely on a running system
shrink_locale_archive.sh (text/plain), 3.74 KB, created by
Andrew J. Schorr
on 2013-11-17 17:02:43 UTC
(
hide
)
Description:
Script to shrink locale-archive safely on a running system
Filename:
MIME Type:
Creator:
Andrew J. Schorr
Created:
2013-11-17 17:02:43 UTC
Size:
3.74 KB
patch
obsolete
>#!/bin/bash ># RcsId: $Id: shrink_locale_archive.sh,v 1.3 2013/11/17 16:55:07 schorr Exp $ > >set -o pipefail >erc=0 > >fn=/usr/lib/locale/locale-archive > ># N.B. $fn is slightly sparse. > >usage () { > echo "Usage: `basename $0` <locale name to retain, e.g. en_US.utf8> > > Shrinks monster file $fn by removing all locales > other than the argument. >" 1>&2 > exit 1 >} > >while getopts h flag ; do > case $flag in > *) usage ;; > esac >done >shift `expr $OPTIND - 1` > >[ $# -ne 1 ] && usage >keep="$1" > >localedef --list-archive | gawk -v "keep=$keep" ' >$0 == keep { > found++ >} > >END { > if (found == 1) > printf "Good, I found the %s locale\n", keep > else { > printf "Error: I cannot find the locale %s in the archive.\n", keep > exit 1 > } >}' || exit 1 > >doit () { > echo " $@" > eval "$@" || { > echo "Error: command [$@] failed with rc $?" 1>&2 > exit 1 > } >} > >tmpdir=`mktemp -dt shrinkla.XXXXXXXXXX` || { > echo "mktemp failed" > exit 1 >} >trap "rm -rf $tmpdir" 0 >trap "exit 2" 1 2 3 6 13 15 > ># note: localedef takes a --prefix arg to set the directory where this ># stuff lives. Unfortunately, build-locale-archive does not implement ># a --prefix option. ># See https://bugzilla.redhat.com/show_bug.cgi?id=1031243 > ># If both had --prefix, we could build a completely new version off to ># the side and then install the new archive atomically. Sigh. > ># Note: in Fedora 19, the original file was 102M, and after shrinking, ># it was 1.6M > ># returns 2 values: free space for non-root and free space for root >fs_free_space () { > stat -f -c "%a %f %S" "$1" | awk '{printf "%.0f %.0f\n", $1*$3, $2*$3}' >} > >file_size () { > stat -c "%b %B" "$1" | awk '{printf "%.0f\n", $1*$2}' >} > >doit "ls -l $fn" > >fsize=`file_size $fn` >echo "Actual disk space used by $fn is $fsize" > >check_space () { > local dir="$1" > set `fs_free_space $dir` > > if [ "$1" -gt "$fsize" ]; then > echo "Good, $dir free space $1 is big enough" > elif [ "$2" -gt "$fsize" ]; then > echo -n "OK, space is a little tight in $dir, but root can use $2, >which is big enough. Shall I proceed? [Y] " > read resp > case "$resp" in > [nN]*) echo "Aborting"; exit 1 ;; > *) echo "OK, I will proceed." ;; > esac > else > echo "Error: there is not enough space in $dir to contain a copy." > echo "Free space available to root is $2 bytes." > exit 1 > fi >} > >check_space $tmpdir >check_space `dirname $fn` > >nfn=${tmpdir}$fn >doit "mkdir -p `dirname $nfn`" ># note that $fn is sparse, but cp handles this automatically >doit "cp -p $fn $nfn" >pfxarg="--prefix $tmpdir" > ># N.B. from the source code, it appears that localedef --delete-from-archive ># just zeroes out a hashtable entry in the mapped archive file. >doit "localedef --list-archive | gawk -v keep=$keep '\$0 != keep' | xargs localedef --delete-from-archive $pfxarg" > ># there is a a race condition here where the file is missing. I guess ># a program that starts at this time and tries to map it will fail. >doit "mv $nfn ${nfn}.tmpl" >doit "rm -f ${fn}.tmpl" >doit "ln -s ${nfn}.tmpl ${fn}.tmpl" ># note that running processes may have the file mapped, so when we reomve ># the file here, we do not release the disk space. But they should continue ># to run fine with their private copies of the file. >doit "rm -f $fn" > ># Builds a new archive from ${fn}.tmpl and then truncates ${fn}.tmpl ># In a better world, this would build the new archive in a temporary file ># and then install it atomically with rename. And it should let the user ># specify a different location for the tmpl file so there would be no need to ># use a symbolic link to trick it. >doit "build-locale-archive" > >doit "rm -f ${fn}.tmpl" >doit "touch ${fn}.tmpl" > >echo "You may need to reboot to reclaim the space being >held open by processes that have mapped the old (huge) version." > >exit $erc
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1031243
: 825208