Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37788265
en ru br
Репозитории ALT
S:0.21-alt2
5.1: 0.17-alt9
4.1: 0.17-alt3
4.0: 0.14.6-alt2
3.0: 0.14.4-alt1
www.altlinux.org/Changes

Другие репозитории
Upstream:0.17

Группа :: Система/Основа
Пакет: gettext

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: gettext-alt-tmp-autopoint.patch
Скачать


--- gettext/gettext-tools/misc/autopoint.in
+++ gettext/gettext-tools/misc/autopoint.in
@@ -32,33 +32,29 @@ datarootdir="@datarootdir@"
 : ${gettext_datadir="@datadir@/gettext"}
 : ${AUTOM4TE=autom4te}
 
+tmp=
+cur_dir=
+work_dir=
+cleanup()
+{
+	local rc=$1
+	[ -z "$tmp" ] || rm -rf -- "$tmp"
+	[ -z "$cur_dir" -o -z "$work_dir" ] || rm -rf -- "$cur_dir/$work_dir"
+	exit $rc
+}
+
+trap 'cleanup $?' EXIT
+trap '(exit 143); exit 143' HUP PIPE INT QUIT TERM
+
 # func_tmpdir
 # creates a temporary directory.
 # Sets variable
 # - tmp             pathname of freshly created temporary directory
 func_tmpdir ()
 {
-  # Use the environment variable TMPDIR, falling back to /tmp. This allows
-  # users to specify a different temporary directory, for example, if their
-  # /tmp is filled up or too small.
-  : ${TMPDIR=/tmp}
-  {
-    # Use the mktemp program if available. If not available, hide the error
-    # message.
-    tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
-    test -n "$tmp" && test -d "$tmp"
-  } ||
+  tmp="$(mktemp -dt autopoint.XXXXXXXXXX)" ||
   {
-    # Use a simple mkdir command. It is guaranteed to fail if the directory
-    # already exists.  $RANDOM is bash specific and expands to empty in shells
-    # other than bash, ksh and zsh.  Its use does not increase security;
-    # rather, it minimizes the probability of failure in a very cluttered /tmp
-    # directory.
-    tmp=$TMPDIR/gt$$-$RANDOM
-    (umask 077 && mkdir "$tmp")
-  } ||
-  {
-    echo "$0: cannot create a temporary directory in $TMPDIR" >&2
+    echo "$0: cannot create a temporary directory in ${TMPDIR:-/tmp}" >&2
     { (exit 1); exit 1; }
   }
 }
@@ -466,21 +462,14 @@ fi
 # Set up a temporary checkout directory.
 # Set variables
 # - work_dir        directory containing the temporary checkout
-work_dir=tmpwrk$$
-mkdir "$work_dir" || {
-  if test -d "$work_dir"; then
-    func_fatal_error "directory $work_dir already exists"
-  else
-    func_fatal_error "cannot create directory $work_dir"
-  fi
-}
+cur_dir=`pwd` || exit
+work_dir="$(mktemp -d tmpwrk.XXXXXXXXXX)" || exit
 
 # We support dirxz archive format only.
 
 xz -d -c < "$gettext_datadir/archive.dir.tar.xz" \
       | (cd "$work_dir" && tar xf - "gettext-$ver")
     if test `find "$work_dir" -type f -print | wc -l` = 0; then
-      rm -rf "$work_dir"
       func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
     fi
     mv "$work_dir/gettext-$ver" "$work_dir/archive"
@@ -589,10 +578,8 @@ if test -z "$force"; then
     fi
   done
   if test -n "$mismatch"; then
-    rm -rf "$work_dir"
     func_fatal_error "Some files have been locally modified. Not overwriting them because --force has not been specified. For your convenience, you find the local modifications in the file '$mismatchfile'."
   fi
-  rm -rf "$tmp"
 fi
 
 # func_mkdir_for to
@@ -605,7 +592,8 @@ func_mkdir_for ()
     func_mkdir_for "$base"
     # Recompute base. It was clobbered by the recursive call.
     base=`echo "$1" | sed -e 's,/[^/]*$,,'`
-    test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; }
+    test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; } ||
+      func_fatal_error "cannot create directory $base"
   fi
 }
 
@@ -674,5 +662,4 @@ for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/arch
 done
 
 # That's it.
-rm -rf "$work_dir"
 exit 0
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin