Linux HOWTOs

About | Home | Search


HOWTO: coreutils
Description: Replacement for GNU fileutils, sh-utils, and textutils
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GNU coreutils 5.94
# ==================
# coreutils first appeared in Slackware 9.1, prior to that there were
# individual "fileutils", "sh-utils", and "textutils" packages.  Slackware
# 9.1's "coreutils" package includes version 5.0, Slackware 10.0, 10.1, and
# 10.2's include version 5.2.1

# Considering that this process can be dangerous if anything goes wrong
# (you're replacing cp, echo, ls, rm, and many other _critical_ utilities),
# if you don't feel comfortable doing this, you may just want to grab the
# latest coreutils package from here:
# ftp://ftp.slackware.com/pub/slackware/slackware-current/slackware/a/
# and then run 'upgradepkg ./coreutils-x.x.x-i486-x.tgz' to update it instead.
# This of course will only work if you run Slackware and already have an older
# Slackware coreutils package installed.

# If you have trouble getting it from ftp.gnu.org, try ibiblio

# Prerequisites:
# autoconf and automake (if you apply the patch below)
# gawk
# grep
# perl
# libiconv
# gettext

cd
test -f installed/coreutils-5.94.tar.bz2 &&
 mv installed/coreutils-5.94.tar.bz2 .
test ! -f coreutils-5.94.tar.bz2 &&
 wget http://ftp.gnu.org/gnu/coreutils/coreutils-5.94.tar.bz2

# Verify the tarball w/ md5sum:
echo "11985c8345371546da8ff13f7efae359  coreutils-5.94.tar.bz2" | md5sum -c

# Verify the tarball w/ sha1sum:
echo "c39add02995304e1cf3dfc8543702f22155fba50  coreutils-5.94.tar.bz2" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys D333CBA1 > /dev/null 2>&1 || gpg --recv-keys D333CBA1 ) &&
 wget -nc http://ftp.gnu.org/gnu/coreutils/coreutils-5.94.tar.bz2.sig &&
  gpg --verify coreutils-5.94.tar.bz2.sig && rm coreutils-5.94.tar.bz2.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "coreutils-*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "fileutils-*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "sh-utils-*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "textutils-*" -exec rm -r {} \;
tar xjvf ~/coreutils-5.94.tar.bz2
cd coreutils-5.94
test $UID = 0 && chown -R root:root .
chmod -R u+w .

# Patch it to skip building or installing hostname (which is in the tcpip and
# util-linux packages), kill (util-linux and procps), su (shadow), and uptime
# (procps).  If you don't mind overwriting them with the version included with
# coreutils, don't apply the patch, just make sure you don't have one in /bin
# and a different one in /usr/bin after everything is installed.  If you
# don't have cvs installed, run 'autoconf -f ; automake -f -i' instead of
# autoreconf.
wget -nc http://englanders.cc/pub/linux/patches/coreutils-5.92.patch &&
 patch -p1 < coreutils-5.92.patch
autoreconf -f -i

./configure --prefix=/usr --sysconfdir=/etc --disable-nls
make
make -k check >& log
grep FAIL log

# Become root to clean up old files and to install it
su

# Because we can't actually use removepkg to remove the old one (because
# removepkg itself uses the utils in this package), remove files from old
# versions of coreutils, fileutils, sh-utils, and textutils manually:
rm -f /etc/DIR_COLORS
find /usr/doc -maxdepth 1 -type d -name "coreutils-*" -exec rm -r {} \;
find /usr/doc -maxdepth 1 -type d -name "fileutils-*" -exec rm -r {} \;
find /usr/doc -maxdepth 1 -type d -name "sh-utils-*" -exec rm -r {} \;
find /usr/doc -maxdepth 1 -type d -name "textutils-*" -exec rm -r {} \;
( cd /usr/info ; rm -f coreutils.info.gz fileutils.info.gz sh-utils.info.gz \
  textutils.info.gz )
( cd /usr/man/man1 ; rm -f basename.1.gz cat.1.gz chgrp.1.gz chmod.1.gz \
  chown.1.gz chroot.1.gz cksum.1.gz comm.1.gz cp.1.gz csplit.1.gz cut.1.gz \
  date.1.gz dd.1.gz df.1.gz dir.1.gz dircolors.1.gz dirname.1.gz du.1.gz \
  echo.1.gz env.1.gz expand.1.gz expr.1.gz factor.1.gz false.1.gz fmt.1.gz \
  fold.1.gz ginstall.1.gz groups.1.gz head.1.gz hostid.1.gz id.1.gz \
  install.1.gz join.1.gz link.1.gz ln.1.gz logname.1.gz ls.1.gz md5sum.1.gz \
  mkdir.1.gz mkfifo.1.gz mknod.1.gz mv.1.gz nice.1.gz nl.1.gz nohup.1.gz \
  od.1.gz paste.1.gz pathchk.1.gz pinky.1.gz pr.1.gz printenv.1.gz \
  printf.1.gz ptx.1.gz pwd.1.gz readlink.1.gz rm.1.gz rmdir.1.gz seq.1.gz \
  sha1sum.1.gz shred.1.gz sleep.1.gz sort.1.gz split.1.gz stat.1.gz \
  stty.1.gz sum.1.gz sync.1.gz tac.1.gz tail.1.gz tee.1.gz test.1.gz \
  touch.1.gz tr.1.gz true.1.gz tsort.1.gz tty.1.gz uname.1.gz unexpand.1.gz \
  uniq.1.gz unlink.1.gz users.1.gz vdir.1.gz wc.1.gz who.1.gz whoami.1.gz \
  yes.1.gz )
find /usr/share/locale -type f -name coreutils.mo -exec rm {} \;
find /usr/share/locale -type f -name fileutils.mo -exec rm {} \;
find /usr/share/locale -type f -name sh-utils.mo -exec rm {} \;
find /usr/share/locale -type f -name textutils.mo -exec rm {} \;

# Move the old package files, if there are any, to make them appear as if
# they were removed by removepkg:
for dir in packages scripts; do
  find /var/adm/${dir} -type f -name "coreutils-*" \
   -exec mv -f {} /var/adm/removed_${dir}/ \;
  find /var/adm/${dir} -type f -name "fileutils-*" \
   -exec mv -f {} /var/adm/removed_${dir}/ \;
  find /var/adm/${dir} -type f -name "fileutls-*" \
   -exec mv -f {} /var/adm/removed_${dir}/ \;
  find /var/adm/${dir} -type f -name "sh?utils*" \
   -exec mv -f {} /var/adm/removed_${dir}/ \;
  find /var/adm/${dir} -type f -name "textutils-*" \
   -exec mv -f {} /var/adm/removed_${dir}/ \;
done

make install
chmod -R u+w .

# Move some of the installed binaries to match where Slackware puts them
# and create a symlink back to the original location:
for file in cat chgrp chmod chown cp cut date dd df dircolors du echo \
 false head ln ls mkdir mkfifo mknod mv pwd rm rmdir shred sleep stty sync \
 touch true uname ; do src/mv -f /usr/bin/$file /bin/ ; src/ln -sf \
 /bin/$file /usr/bin/$file ; done
test ! -L /usr/sbin/chroot &&
 ( rm /usr/sbin/chroot ; ln -sf /usr/bin/chroot /usr/sbin/chroot )
test ! -L /usr/bin/ginstall &&
 ( rm /usr/bin/ginstall ; ln -sf /usr/bin/install /usr/bin/ginstall )
test ! -L /usr/man/man1/ginstall.1 &&
 ( rm -f /usr/man/man1/ginstall.1
   ln -sf /usr/man/man1/install.1 /usr/man/man1/ginstall.1 )

# Create a /etc/profile.d/coreutils.sh that'll set ls with some common
# options.  Slackware's patched ls/dircolors takes care of this, the "real"
# versions don't.  If you have a really old version of Slackware that doesn't
# have /etc/profile.d/, add the alias line to /etc/profile (or ~/.bash_login
# or ~/.profile) instead.
rm -f /etc/profile.d/fileutils.sh
echo '#!/bin/sh' > /etc/profile.d/coreutils.sh
echo "alias ls='ls --color=auto -F -b -T 0'" >> /etc/profile.d/coreutils.sh
chmod +x /etc/profile.d/coreutils.sh

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/coreutils-* installed/fileutils-* installed/sh-utils-* \
 installed/textutils-*
mv coreutils-5.94.tar.bz2 installed/

# Keep an eye out for scripts that use the many utils in this package.  If
# you find a script that is hard coded to use the path of a coreutils utility
# that isn't used any more, either update the script(s) to point to the new
# path, replace that part of the script with a call to which (`which ls` will
# cause the script to find where ls is and output it), or create a symlink
# from the binary to where the script thinks it is.

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>