Linux HOWTOs

About | Home | Search


HOWTO: mktemp
Description: Creates temp files with a unique filename
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


# mktemp 1.6
# ==========
# Slackware uses the mktemp from debianutils.  This mktemp is from the same
# author as the debianutils one, but is packaged seperately.  See the
# debianutils howto for more info.

# Prerequisites:
# groff
# grep

cd
test -f installed/mktemp-1.6.tar.gz && mv installed/mktemp-1.6.tar.gz .
test ! -f mktemp-1.6.tar.gz &&
 wget ftp://ftp.mktemp.org/pub/mktemp/mktemp-1.6.tar.gz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "3e66f91f8a39c7dc0a67b158aeb9c2ac  mktemp-1.6.tar.gz" | md5sum -c

# Verify tarball w/ sha1sum:
echo "562ee9f2b7033a90196409961c2137917c125838  mktemp-1.6.tar.gz" | \
 md5sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 7EE470C4 > /dev/null 2>&1 || gpg --recv-keys 7EE470C4 ) &&
 wget -nc ftp://ftp.mktemp.org/pub/mktemp/mktemp-1.6.tar.gz.sig &&
  gpg --verify mktemp-1.6.tar.gz.sig && rm mktemp-1.6.tar.gz.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "mktemp*" -exec rm -r {} \;
tar xzvf ~/mktemp-1.6.tar.gz
cd mktemp-1.6
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr
make

# Become root to install it
su

rm -f /usr/man/man1/mktemp.1.gz /usr/man/cat1/mktemp.1.bz2
make install

# Remove lines from the Slackware 'bin' package file that reference files
# from the old mktemp that you replaced above:
PKGFILE=`find /var/adm/packages -type f -name "bin-*" | head -1`
test -z "$PKGFILE" &&
 test -r /var/adm/packages/bin &&
  PKGFILE="/var/adm/packages/bin"
test -r "$PKGFILE" &&
 cat $PKGFILE |
  egrep -v "^usr/bin/mktemp$" |
  egrep -v "^usr/man/man1/mktemp.1.gz$" > $PKGFILE.new
test -s $PKGFILE.new &&
 ( mkdir -p -m 0700 ~/backup/packages
   mv -f $PKGFILE ~/backup/packages/`basename $PKGFILE`.`date +%Y%m%d`
   mv -f $PKGFILE.new $PKGFILE )
test -e $PKGFILE.new && rm $PKGFILE.new
unset PKGFILE

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/mktemp-*.tar.*
mv mktemp-1.6.tar.gz installed/

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>