[27146] in Source-Commits
/svn/athena r25974 - in trunk/athena/bin/athrun: . debian
daemon@ATHENA.MIT.EDU (Alexander Chernyakhovsky)
Sat May 11 17:39:05 2013
Date: Sat, 11 May 2013 17:38:58 -0400
From: Alexander Chernyakhovsky <achernya@MIT.EDU>
Message-Id: <201305112138.r4BLcw2i029906@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: achernya
Date: 2013-05-11 17:38:58 -0400 (Sat, 11 May 2013)
New Revision: 25974
Added:
trunk/athena/bin/athrun/attachandrun
trunk/athena/bin/athrun/attachandrun.1
trunk/athena/bin/athrun/debian/debathena-athrun.bash-completion
trunk/athena/bin/athrun/debian/debathena-athrun.install
trunk/athena/bin/athrun/debian/debathena-athrun.manpages
trunk/athena/bin/athrun/gathrun
trunk/athena/bin/athrun/gathrun.1
trunk/athena/bin/athrun/setup.py
Removed:
trunk/athena/bin/athrun/debian/bash-completion
trunk/athena/bin/athrun/debian/install
trunk/athena/bin/athrun/debian/manpages
Modified:
trunk/athena/bin/athrun/debian/changelog
trunk/athena/bin/athrun/debian/control
trunk/athena/bin/athrun/debian/copyright
Log:
In athrun:
* Merge debathena-gathrun and debathena-attachandrun into the debathena-athrun source package.
* Rewrite debathena-attachandrun in Python.
- Fix a segementation fault in attachandrun that could be triggered by
running with just "-c" and a locker.
- Stop trying to run the file as a shell script if execv() fails.
* Switch to DEP-5-style copyright file.
Added: trunk/athena/bin/athrun/attachandrun
===================================================================
--- trunk/athena/bin/athrun/attachandrun (rev 0)
+++ trunk/athena/bin/athrun/attachandrun 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+
+import errno
+import os
+import subprocess
+import sys
+
+progname = 'attachandrun'
+
+def extract(args):
+ if len(args) < 1:
+ raise Exception('Missing arguments')
+ return (args[0], args[1:])
+
+def usage():
+ print >>sys.stderr, 'Usage: %s [--check|-c] locker program program_name [args...]' % (progname,)
+ sys.exit(1)
+
+def invoke(args):
+ try:
+ process = subprocess.Popen(args,
+ stdout=subprocess.PIPE)
+ result, _ = process.communicate()
+ if process.returncode != 0:
+ raise Exception("Non-zero return code from '%s'" % (args[0],))
+ return result.strip()
+ except subprocess.CalledProcessError as e:
+ print >>sys.stderr, "Unable to invoke '%s'." % (args[0],)
+ sys.exit(1)
+
+def attach(locker):
+ try:
+ return invoke(['attach', '-p', locker])
+ except Exception as e:
+ raise Exception("Could not find locker '%s'" % (locker,))
+
+def athdir(path):
+ try:
+ return invoke(['athdir', '-t', 'bin', '-p', path])
+ except Exception as e:
+ raise Exception("Could not find binary directory in '%s'" % (path,))
+
+def execute(path, args):
+ try:
+ os.execv(path, args)
+ except OSError as e:
+ return e.errno
+
+def main():
+ # First, figure out our name, in the strange case it isn't
+ # 'attachandrun'. After we process each argument, consume it.
+ global progname
+ potential, argv = extract(sys.argv)
+ progname = os.path.basename(potential)
+
+ if len(argv) < 1:
+ raise Exception('Missing arguments')
+
+ check = False
+ if argv[0] == '--check' or argv[0] == '-c':
+ check = True
+ _, argv = extract(argv)
+ locker, argv = extract(argv)
+ program, argv = extract(argv)
+
+ # Use attach and athdir to figure out where the program we want to
+ # execute lives
+ locker_path = attach(locker)
+ program_location = os.path.join(athdir(locker_path), program)
+
+ # If we're in check (aka dry-run), see if we can execute this
+ # program
+ if check:
+ if os.access(program_location, os.X_OK):
+ sys.exit(0)
+ sys.exit(1)
+
+ # Actually execute the program,
+ error = execute(program_location, argv)
+ print >>sys.stderr, "%s: %s" % (progname, os.strerror(error))
+
+if __name__ == '__main__':
+ try:
+ main()
+ except Exception as e:
+ print >>sys.stderr, "%s: %s" % (progname, e)
+ usage()
Property changes on: trunk/athena/bin/athrun/attachandrun
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/athena/bin/athrun/attachandrun.1
===================================================================
--- trunk/athena/bin/athrun/attachandrun.1 (rev 0)
+++ trunk/athena/bin/athrun/attachandrun.1 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1,50 @@
+.\" $Id: attachandrun.1,v 1.2 2006-06-26 05:22:20 ghudson Exp $
+.\"
+.\" Copyright 1997 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 ATTACHANDRUN 1
+.SH NAME
+attachandrun \- attach a filesystem and run a program from it
+
+.SH SYNOPSIS
+attachandrun [--check] locker program argv0 [argv1 ...]
+
+.SH DESCRIPTION
+\fIattachandrun\fR combines the operations of attaching a locker,
+locating its binary directory, and executing a program out of that
+directory. Running a program via \fIattachandrun\fR should be
+indistinguishable from running it out of its locker by hand. A typical
+``attach and run'' script would look like:
+
+.nf
+ #!/bin/sh
+ exec /bin/athena/attachandrun moira blanche "$0" "$@"
+.fi
+
+If you specify the \fI--check\fR option, \fIattachandrun\fR will check
+for the existence of the binary but not actually run it. (In this
+case, you don't need to specify any argv elements.) It will exit with
+status 0 if the binary exists, or 1 if it does not. Note that a
+successful exit status does not necessarily mean that attempting to
+run the binary will succeed: it indicates only that the file exists.
+
+.SH "SEE ALSO"
+attach(1), athdir(1)
+
+.SH AUTHORS
+Craig Fields, MIT Information Systems
+Dan Winship, MIT Information Systems
+.PP
+Copyright 1998 Massachusetts Institute of Technology
Modified: trunk/athena/bin/athrun/debian/changelog
===================================================================
--- trunk/athena/bin/athrun/debian/changelog 2013-05-10 16:06:19 UTC (rev 25973)
+++ trunk/athena/bin/athrun/debian/changelog 2013-05-11 21:38:58 UTC (rev 25974)
@@ -1,3 +1,14 @@
+debathena-athrun (10.2-0debathena1) unstable; urgency=low
+
+ * Merge debathena-gathrun and debathena-attachandrun into the debathena-athrun source package.
+ * Rewrite debathena-attachandrun in Python.
+ - Fix a segementation fault in attachandrun that could be triggered by
+ running with just "-c" and a locker.
+ - Stop trying to run the file as a shell script if execv() fails.
+ * Switch to DEP-5-style copyright file.
+
+ -- Alexander Chernyakhovsky <achernya@mit.edu> Sat, 11 May 2013 17:03:28 -0400
+
debathena-athrun (10.1-0debathena1) unstable; urgency=low
[ Jonathan Reed ]
Modified: trunk/athena/bin/athrun/debian/control
===================================================================
--- trunk/athena/bin/athrun/debian/control 2013-05-10 16:06:19 UTC (rev 25973)
+++ trunk/athena/bin/athrun/debian/control 2013-05-11 21:38:58 UTC (rev 25974)
@@ -8,7 +8,23 @@
Package: debathena-athrun
Architecture: all
Provides: athrun
-Depends: ${shlibs:Depends}, ${misc:Depends}, debathena-attachandrun
+Depends: ${misc:Depends}, debathena-attachandrun
Description: An Athena utility for users to run a program from a locker
The athrun utility allows a user to robustly run a program from a
specified Athena locker.
+
+Package: debathena-gathrun
+Architecture: all
+Depends: ${misc:Depends}, debathena-attachandrun, zenity, debathena-machtype
+Description: An Athena utility to run GUI programs out of lockers from a menu
+ The gathrun utility allows a user to run a program from a specified
+ locker. If the program does not exist, a dialog box is displayed
+ saying so (using gdialog).
+
+Package: debathena-attachandrun
+Architecture: any
+Provides: attachandrun
+Depends: ${misc:Depends}, ${python:Depends}, debathena-attach, python
+Description: An Athena utility for scripts to run a program from a locker
+ The attachandrun utility allows a script to robustly run a program from
+ a specified locker.
Modified: trunk/athena/bin/athrun/debian/copyright
===================================================================
--- trunk/athena/bin/athrun/debian/copyright 2013-05-10 16:06:19 UTC (rev 25973)
+++ trunk/athena/bin/athrun/debian/copyright 2013-05-11 21:38:58 UTC (rev 25974)
@@ -1,23 +1,31 @@
-This package was debianized as part of the Debathena Project
-<http://debathena.mit.edu/> of the MIT Student Information Processing
-Board.
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-The Athena source code was obtained from the Athena SVN repository at
-<svn://debathena.mit.edu/athena/trunk>, and is licensed as follows:
-
- Copyright © 1996 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.
-
-The Debian packaging is Copyright © 2007-2008 Tim Abbott and Anders
-Kaseorg, and has the same license as the original software.
+Files: *
+Copyright: (c) 1996-2013 Massachusetts Institute of Technology
+License: BSD-3-clause
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of the Massachusetts Institute of Technology
+ nor the names of its contributors may be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MASSACHUSETTS
+ INSTITUTE OF TECHNOLOGY BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
Copied: trunk/athena/bin/athrun/debian/debathena-athrun.bash-completion (from rev 25973, trunk/athena/bin/athrun/debian/bash-completion)
===================================================================
--- trunk/athena/bin/athrun/debian/debathena-athrun.bash-completion (rev 0)
+++ trunk/athena/bin/athrun/debian/debathena-athrun.bash-completion 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1 @@
+bash_completion athrun
Copied: trunk/athena/bin/athrun/debian/debathena-athrun.install (from rev 25973, trunk/athena/bin/athrun/debian/install)
===================================================================
--- trunk/athena/bin/athrun/debian/debathena-athrun.install (rev 0)
+++ trunk/athena/bin/athrun/debian/debathena-athrun.install 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1 @@
+athrun usr/bin/
Copied: trunk/athena/bin/athrun/debian/debathena-athrun.manpages (from rev 25973, trunk/athena/bin/athrun/debian/manpages)
===================================================================
--- trunk/athena/bin/athrun/debian/debathena-athrun.manpages (rev 0)
+++ trunk/athena/bin/athrun/debian/debathena-athrun.manpages 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1 @@
+athrun.1
Added: trunk/athena/bin/athrun/gathrun
===================================================================
--- trunk/athena/bin/athrun/gathrun (rev 0)
+++ trunk/athena/bin/athrun/gathrun 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1,42 @@
+#!/bin/sh
+# $Id: gathrun.sh,v 1.3 2004-03-06 17:18:57 ghudson Exp $
+
+# gathrun - Run a program, or put up an error dialog saying that it
+# doesn't exist.
+
+splash=no
+if [ "$1" = "--splash" ]; then
+ shift
+ splash=yes
+fi
+
+# Set sane values
+export ATHENA_SYS=${ATHENA_SYS:-$(machtype -S)}
+export ATHENA_SYS_COMPAT=${ATHENA_SYS_COMPAT:-$(machtype -C)}
+
+case $# in
+0)
+ echo "Usage: gathrun locker [program [args ...]]" >&2
+ exit 1
+ ;;
+1)
+ locker=$1
+ program=$1
+ shift
+ ;;
+*)
+ locker=$1
+ program=$2
+ shift 2
+ ;;
+esac
+
+if attachandrun --check "$locker" "$program" "$@"; then
+ if [ "$splash" = "yes" ]; then
+ yes | zenity --progress --text="Launching $program, please wait.\n(This may take a few moments)" --pulsate --no-cancel --timeout 7 &
+ fi
+ exec /bin/athena/attachandrun "$locker" "$program" "$program" "$@"
+else
+ zenity --info \
+ --text="$program is not available in the $locker locker on this platform."
+fi
Property changes on: trunk/athena/bin/athrun/gathrun
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/athena/bin/athrun/gathrun.1
===================================================================
--- trunk/athena/bin/athrun/gathrun.1 (rev 0)
+++ trunk/athena/bin/athrun/gathrun.1 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1,35 @@
+.\" $Id: gathrun.1,v 1.2 2004-01-22 17:53:16 ghudson Exp $
+.\"
+.\" Copyright 2000 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 GATHRUN 1 "5 May 2001"
+.SH NAME
+gathrun \- Run a program from an Athena locker
+.SH SYNOPSIS
+.B gathrun \fIlockername\fP [\fIprogname\fP [\fIargs\fP...]]
+.SH DESCRIPTION
+.B gathrun
+runs a program from a specific Athena locker. If
+.I progname
+is not specified, it is assumed to be the same as the locker name. If
+the program does not exist in the specified locker, a dialog box is
+displayed saying so; this makes
+.B gathrun
+useful for running GUI programs from a menu system.
+.SH "SEE ALSO"
+.BR attachandrun (1)
+.SH AUTHOR
+Greg Hudson, MIT Information Systems
+.br
+Copyright 2001 by the Massachusetts Institute of Technology.
Added: trunk/athena/bin/athrun/setup.py
===================================================================
--- trunk/athena/bin/athrun/setup.py (rev 0)
+++ trunk/athena/bin/athrun/setup.py 2013-05-11 21:38:58 UTC (rev 25974)
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+from distutils.core import setup
+
+setup(name='attachandrun',
+ version='10.2',
+ description='Athena utility for scripts to run a program from a locker',
+ author='Alexander Chernyakhovsky',
+ scripts=['attachandrun']
+ )