source: patches/mktemp-1.5-add_tempfile-3.patch@ a33dbaa

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since a33dbaa was 69cde8d, checked in by Jim Gifford <clfs@…>, 19 years ago

Added: All patches needed for the book.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[69cde8d]1Submitted By: Tushar Teredesai <tushar@linuxfromscratch.org>
2Date: 2005-07-25
3Initial Package Version: 1.5
4Upstream Status: Sent, no response yet.
5Origin: http://archive.linuxfromscratch.org/mail-archives/lfs-dev/2003-April/033602.html
6 http://archive.linuxfromscratch.org/mail-archives/lfs-dev/2003-June/035234.html
7 http://linuxfromscratch.org/pipermail/lfs-dev/2005-June/051908.html
8Description: Add tempfile wrapper script. Use "make install-tempfile" to install it.
9
10diff -Naur mktemp-1.5.orig/Makefile.in mktemp-1.5/Makefile.in
11--- mktemp-1.5.orig/Makefile.in 2003-03-23 18:09:56.000000000 -0700
12+++ mktemp-1.5/Makefile.in 2005-07-25 11:11:11.000000000 -0600
13@@ -113,6 +113,9 @@
14 install-man:
15 $(INSTALL) -m 0444 $(srcdir)/$(PROG).$(mantype) $(mandir)/man1/$(PROG).1
16
17+install-tempfile: $(srcdir)/tempfile
18+ $(INSTALL) -m 0555 $(srcdir)/tempfile $(bindir)/tempfile
19+
20 check:
21 @echo nothing to check
22
23diff -Naur mktemp-1.5.orig/tempfile mktemp-1.5/tempfile
24--- mktemp-1.5.orig/tempfile 1969-12-31 17:00:00.000000000 -0700
25+++ mktemp-1.5/tempfile 2005-07-25 11:13:41.000000000 -0600
26@@ -0,0 +1,85 @@
27+#!/bin/bash
28+# A tempfile wrapper for mktemp
29+# Note: If you can, avoid using tempfile and use mktemp instead.
30+# This wrapper is provided for compatibility since some scripts use
31+# tempfile. If possible, the best solution is to patch the scripts
32+# to use mktemp.
33+#
34+# Copyright (c) Tushar Teredesai <tush@yahoo.com>
35+#
36+# Permission to use, copy, modify, and distribute this software for any
37+# purpose with or without fee is hereby granted, provided that the above
38+# copyright notice and this permission notice appear in all copies.
39+#
40+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
41+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
42+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
43+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
44+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
45+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
46+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
47+#
48+
49+# Usage info
50+usage()
51+{
52+ echo "Usage: tempfile [OPTION]"
53+ echo
54+ echo "Create a temporary file in a safe manner."
55+ echo "This version is a wrapper that invokes mktemp."
56+ echo "NOTE: Do not use tempfile in your scripts."
57+ echo " Use mktemp instead."
58+ echo
59+ echo "[-d|--directory] DIR -> place temporary file in DIR"
60+ echo "[-p|--prefix] PREFIX -> ignored"
61+ echo "[-s|--suffix] SUFFIX -> ignored"
62+ echo "[-n|--name] NAME -> ignored"
63+ echo "[-m|--mode] MODE -> ignored"
64+ echo "--version -> output version information and exit"
65+}
66+
67+# parse all arguments
68+while [ $# != 0 ]
69+do
70+ case "$1" in
71+ # -d for tempfile is equivalent to -p for mktemp
72+ -d|--directory)
73+ dir="$2"
74+ shift 2
75+ ;;
76+ --directory=*)
77+ dir="${1#--directory=}"
78+ shift 1
79+ ;;
80+ -d*)
81+ dir="${1#-d}"
82+ shift 1
83+ ;;
84+ # The following switches are ignored.
85+ -p|--prefix|-s|--suffix|-n|--name|-m|--mode)
86+ shift 2
87+ ;;
88+ -p*|--prefix=*|-s*|--suffix=*|-n*|--name=*|-m*|--mode=*)
89+ shift 1
90+ ;;
91+ # --version for tempfile is equivalent to -V for mktemp
92+ --version)
93+ echo "tempfile 1.0 (`mktemp -V 2>/dev/null`)"
94+ exit 0
95+ ;;
96+ # Unknown switch
97+ *)
98+ usage
99+ exit 1
100+ ;;
101+ esac
102+done
103+
104+# Use the dir if $TMPDIR is not set.
105+if [ -z "$TMPDIR" -a ! -z "$dir" ]
106+then
107+ export TMPDIR="$dir"
108+fi
109+# Execute mktemp with proper arguments
110+# the -t behaviour of mktemp is the default for tempfile
111+exec mktemp -t
Note: See TracBrowser for help on using the repository browser.