[27084] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r25937 - in trunk/athena/bin/syncupdate: . debian debian/source man src

daemon@ATHENA.MIT.EDU (Victor Vasiliev)
Sat Apr 20 16:21:16 2013

Date: Sat, 20 Apr 2013 16:21:07 -0400
From: Victor Vasiliev <vasilvv@MIT.EDU>
Message-Id: <201304202021.r3KKL7AX001451@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: vasilvv
Date: 2013-04-20 16:21:07 -0400 (Sat, 20 Apr 2013)
New Revision: 25937

Added:
   trunk/athena/bin/syncupdate/Makefile.am
   trunk/athena/bin/syncupdate/configure.ac
   trunk/athena/bin/syncupdate/debian/source/
   trunk/athena/bin/syncupdate/debian/source/format
   trunk/athena/bin/syncupdate/m4/
   trunk/athena/bin/syncupdate/man/
   trunk/athena/bin/syncupdate/man/Makefile.am
   trunk/athena/bin/syncupdate/man/syncupdate.1
   trunk/athena/bin/syncupdate/src/
   trunk/athena/bin/syncupdate/src/Makefile.am
   trunk/athena/bin/syncupdate/src/syncupdate.c
Removed:
   trunk/athena/bin/syncupdate/Makefile.in
   trunk/athena/bin/syncupdate/configure.in
   trunk/athena/bin/syncupdate/syncupdate.1
   trunk/athena/bin/syncupdate/syncupdate.c
Modified:
   trunk/athena/bin/syncupdate/debian/changelog
   trunk/athena/bin/syncupdate/debian/control
   trunk/athena/bin/syncupdate/debian/rules
Log:
In syncupdate:
  * Use automake
  * Bump upstream version
  * Switch to debhelper7
  * Switch to source format 3.0


Added: trunk/athena/bin/syncupdate/Makefile.am
===================================================================
--- trunk/athena/bin/syncupdate/Makefile.am	                        (rev 0)
+++ trunk/athena/bin/syncupdate/Makefile.am	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1,2 @@
+ACLOCAL_AMFLAGS = --install -I m4
+SUBDIRS = src man

Added: trunk/athena/bin/syncupdate/configure.ac
===================================================================
--- trunk/athena/bin/syncupdate/configure.ac	                        (rev 0)
+++ trunk/athena/bin/syncupdate/configure.ac	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1,29 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.65])
+AC_INIT([syncupdate], [10.1], [debathena@mit.edu])
+AM_INIT_AUTOMAKE([foreign -Wall])
+AM_MAINTAINER_MODE([enable])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SRCDIR([src/syncupdate.c])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+LT_INIT
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+AC_CHECK_FUNCS([strerror])
+
+AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
+AC_OUTPUT

Modified: trunk/athena/bin/syncupdate/debian/changelog
===================================================================
--- trunk/athena/bin/syncupdate/debian/changelog	2013-04-18 21:03:03 UTC (rev 25936)
+++ trunk/athena/bin/syncupdate/debian/changelog	2013-04-20 20:21:07 UTC (rev 25937)
@@ -1,10 +1,17 @@
-debathena-syncupdate (10.0.2) UNRELEASED; urgency=low
+debathena-syncupdate (10.1-0debathena1) unstable; urgency=low
 
+  [ Jonathan Reed ]
   * Bump debian/compat to 6
   * Switch from control.in to control (Trac: #561)
   * Bump Standards-Version to 3.9.3
   * Bump compat level to 7
 
+  [ Victor Vasiliev ]
+  * Use automake
+  * Bump upstream version
+  * Switch to debhelper7
+  * Switch to source format 3.0
+
  -- Jonathan Reed <jdreed@mit.edu>  Wed, 03 Apr 2013 13:59:57 -0400
 
 debathena-syncupdate (10.0.1) unstable; urgency=low

Modified: trunk/athena/bin/syncupdate/debian/control
===================================================================
--- trunk/athena/bin/syncupdate/debian/control	2013-04-18 21:03:03 UTC (rev 25936)
+++ trunk/athena/bin/syncupdate/debian/control	2013-04-20 20:21:07 UTC (rev 25937)
@@ -2,7 +2,7 @@
 Section: debathena/utils
 Priority: extra
 Maintainer: Debathena Project <debathena@mit.edu>
-Build-Depends: cdbs, debhelper, dh-buildinfo, autoconf
+Build-Depends: debhelper (>= 7.0.50~), dh-autoreconf
 Standards-Version: 3.9.3
 
 Package: debathena-syncupdate

Modified: trunk/athena/bin/syncupdate/debian/rules
===================================================================
--- trunk/athena/bin/syncupdate/debian/rules	2013-04-18 21:03:03 UTC (rev 25936)
+++ trunk/athena/bin/syncupdate/debian/rules	2013-04-20 20:21:07 UTC (rev 25937)
@@ -1,10 +1,8 @@
 #!/usr/bin/make -f
 
-DEB_AUTO_UPDATE_AUTOCONF = 2.50
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/autotools.mk
+%:
+	dh $@ --with autoreconf
 
-DEB_CONFIGURE_EXTRA_FLAGS += lbindir=/bin
+override_dh_auto_configure:
+	dh_auto_configure -- --bindir=/bin
 
-clean::
-	rm -f configure

Added: trunk/athena/bin/syncupdate/debian/source/format
===================================================================
--- trunk/athena/bin/syncupdate/debian/source/format	                        (rev 0)
+++ trunk/athena/bin/syncupdate/debian/source/format	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1 @@
+3.0 (quilt)

Added: trunk/athena/bin/syncupdate/man/Makefile.am
===================================================================
--- trunk/athena/bin/syncupdate/man/Makefile.am	                        (rev 0)
+++ trunk/athena/bin/syncupdate/man/Makefile.am	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1 @@
+dist_man1_MANS = syncupdate.1

Copied: trunk/athena/bin/syncupdate/man/syncupdate.1 (from rev 25936, trunk/athena/bin/syncupdate/syncupdate.1)
===================================================================
--- trunk/athena/bin/syncupdate/man/syncupdate.1	                        (rev 0)
+++ trunk/athena/bin/syncupdate/man/syncupdate.1	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1,80 @@
+.\" $Id: syncupdate.1,v 1.1 2000-01-01 05:38:55 ghudson Exp $
+.\"
+.\" Copyright 1999 by the Massachusetts Institute of Technology.
+.\"
+.\" Permission to use, copy, modify, and distribute this
+.\" software and its documentation for any purpose and without
+.\" fee is hereby granted, provided that the above copyright
+.\" notice appear in all copies and that both that copyright
+.\" notice and this permission notice appear in supporting
+.\" documentation, and that the name of M.I.T. not be used in
+.\" advertising or publicity pertaining to distribution of the
+.\" software without specific, written prior permission.
+.\" M.I.T. makes no representations about the suitability of
+.\" this software for any purpose.  It is provided "as is"
+.\" without express or implied warranty.
+.\"
+.TH SYNCUPDATE 1 "28 December 1999"
+.SH NAME
+syncupdate \- update files with synchronously written data
+.SH SYNOPSIS
+.B syncupdate
+[
+.B \-c
+.I tempfile
+]
+.I source
+.I dest
+.fi
+.SH DESCRIPTION
+.B syncupdate
+copies or renames
+.I source
+to
+.IR dest ,
+making sure that the information in
+.I source
+has been synchronously written out to disk before performing the final
+rename.
+.PP
+If the
+.B \-c
+flag is given,
+.B syncupdate
+will copy the contents of
+.I source
+to
+.IR tempfile ,
+push the contents of
+.I tempfile
+to disk using
+.BR fsync (2),
+and then rename
+.I tempfile
+to
+.IR dest .
+.I tempfile
+will be removed prior to the copy.
+.B syncupdate
+will preserve the mode of
+.I source
+when generating
+.IR tempfile ,
+but not the ownership information.
+.PP
+If the
+.B \-c
+flag is not given,
+.B syncupdate
+will open
+.IR source ,
+use
+.BR fsync (2)
+to push its contents to disk, and then rename
+.I source
+to
+.IR dest .
+.SH AUTHOR
+Greg Hudson, MIT Information Systems
+.br
+Copyright 1999 by the Massachusetts Institute of Technology

Added: trunk/athena/bin/syncupdate/src/Makefile.am
===================================================================
--- trunk/athena/bin/syncupdate/src/Makefile.am	                        (rev 0)
+++ trunk/athena/bin/syncupdate/src/Makefile.am	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1,2 @@
+bin_PROGRAMS = syncupdate
+syncupdate_SOURCES = syncupdate.c

Copied: trunk/athena/bin/syncupdate/src/syncupdate.c (from rev 25936, trunk/athena/bin/syncupdate/syncupdate.c)
===================================================================
--- trunk/athena/bin/syncupdate/src/syncupdate.c	                        (rev 0)
+++ trunk/athena/bin/syncupdate/src/syncupdate.c	2013-04-20 20:21:07 UTC (rev 25937)
@@ -0,0 +1,211 @@
+/* Copyright 1999 by the Massachusetts Institute of Technology.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of M.I.T. not be used in
+ * advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ */
+
+static const char rcsid[] = "$Id: syncupdate.c,v 1.4 2001-10-23 21:59:02 amb Exp $";
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#ifdef linux
+#include <libgen.h>
+#endif
+
+#ifndef S_IAMB
+#define S_IAMB 0x1FF	/* Access bits part of struct stat st_mode field */
+#endif
+
+static void copy(const char *source, const char *tempfile);
+static void open_and_sync(const char *filename);
+static void usage(void);
+#ifdef linux
+static void open_dir_and_sync(const char *filename);
+#endif
+
+int main(int argc, char **argv)
+{
+  int c;
+  char *tempfile = NULL, *source, *dest;
+
+  while ((c = getopt(argc, argv, "c:")) != EOF)
+    {
+      switch (c)
+	{
+	case 'c':
+	  tempfile = optarg;
+	  break;
+	case '?':
+	  usage();
+	}
+    }
+  argc -= optind;
+  argv += optind;
+  if (argc != 2)
+    usage();
+  source = argv[0];
+  dest = argv[1];
+
+  /* Set up for the move. */
+  if (tempfile)
+    {
+      copy(source, tempfile);
+      source = tempfile;
+    }
+  else
+    open_and_sync(source);
+
+  if (rename(source, dest) == -1)
+    {
+      fprintf(stderr, "syncupdate: can't rename %s to %s: %s\n",
+	      source, dest, strerror(errno));
+      exit(1);
+    }
+
+#ifdef linux
+  open_dir_and_sync(dirname(dest));
+#endif
+
+  exit(0);
+}
+
+static void copy(const char *source, const char *tempfile)
+{
+  int sfd, tfd, count, pos, n;
+  struct stat statbuf;
+  unsigned char buf[8192];
+
+  /* Open the source file and get its status information. */
+  sfd = open(source, O_RDONLY, 0);
+  if (sfd == -1)
+    {	
+      fprintf(stderr, "syncupdate: can't read %s: %s\n", source,
+	      strerror(errno));
+      exit(1);
+    }
+  if (fstat(sfd, &statbuf) == -1)
+    {
+      fprintf(stderr, "syncupdate: can't stat %s: %s\n", source,
+	      strerror(errno));
+      exit(1);
+    }
+
+  /* Remove, open, and set mode on the temp file. */
+  if (unlink(tempfile) == -1 && errno != ENOENT)
+    {
+      fprintf(stderr, "syncupdate: can't remove %s: %s\n", tempfile,
+	      strerror(errno));
+      exit(1);
+    }
+  tfd = open(tempfile, O_RDWR | O_CREAT | O_EXCL, 0);
+  if (tfd == -1)
+    {
+      fprintf(stderr, "syncupdate: can't create %s: %s\n", tempfile,
+	      strerror(errno));
+      exit(1);
+    }
+  if (fchmod(tfd, statbuf.st_mode & S_IAMB) == -1)
+    {
+      fprintf(stderr, "syncupdate: can't fchmod %s: %s\n", tempfile,
+	      strerror(errno));
+      unlink(tempfile);
+      exit(1);
+    }
+
+  /* Now copy and fsync. */
+  while ((count = read(sfd, buf, sizeof(buf))) > 0)
+    {
+      for (pos = 0; pos < count; pos += n)
+	{
+	  n = write(tfd, buf + pos, count - pos);
+	  if (n == -1)
+	    {
+	      fprintf(stderr, "syncupdate: can't write to %s: %s\n", tempfile,
+		      strerror(errno));
+	      unlink(tempfile);
+	      exit(1);
+	    }
+	}
+    }
+  if (count == -1)
+    {
+      fprintf(stderr, "syncupdate: can't read from %s: %s\n", source,
+	      strerror(errno));
+    }
+
+  if (fsync(tfd) == -1)
+    {
+      fprintf(stderr, "syncupdate: can't fsync %s: %s\n", tempfile,
+	      strerror(errno));
+      unlink(tempfile);
+      exit(1);
+    }
+
+  close(sfd);
+  close(tfd);
+}
+
+static void open_and_sync(const char *filename)
+{
+  int fd;
+
+  fd = open(filename, O_RDWR, 0);
+  if (fd == -1)
+    {
+      fprintf(stderr, "syncupdate: can't open %s: %s\n", filename,
+	      strerror(errno));
+      exit(1);
+    }
+
+  if (fsync(fd) == -1)
+    {
+      fprintf(stderr, "syncupdate: can't fsync %s: %s\n", filename,
+	      strerror(errno));
+      exit(1);
+    }
+
+  close(fd);
+}
+
+#ifdef linux
+/* Despite the implication of the man page that fsync() will only work on
+   RDWR file descriptors, it also works on directories open RDONLY.
+   Since linux fsync() doesn't flush directory entries, force the issue. */
+static void open_dir_and_sync(const char *filename)
+{
+  int fd;
+
+  fd = open(filename, O_RDONLY, 0);
+  if (fd == -1)
+    {
+      fprintf(stderr, "syncupdate: can't open %s: %s\n", filename,
+	      strerror(errno));
+      exit(1);
+    }
+
+  fsync(fd);
+  close(fd);
+}
+#endif
+
+static void usage(void)
+{
+  fprintf(stderr, "Usage: syncupdate [-c tempfile] source dest\n");
+  exit(1);
+}


home help back first fref pref prev next nref lref last post