Permalink
Browse files

initial commit for a new layout.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@969 71c3de6d-444a-0410-be80-ed276b4c234a
  • Loading branch information...
kohsuke
kohsuke committed Nov 5, 2006
0 parents commit 8a0dc230f44e84e5a7f7920cf9a31f09a54999ac
Showing 594 changed files with 48,337 additions and 0 deletions.
@@ -0,0 +1,32 @@
+#!/bin/sh
+if [ "$HUDSON_HOME" = "" ]; then
+ echo HUDSON_HOME is not set
+ exit 1
+fi
+
+
+# search the installation directory
+
+PRG=$0
+progname=`basename $0`
+saveddir=`pwd`
+
+cd "`dirname $PRG`"
+
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '.*/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname $PRG`/$link"
+ fi
+done
+
+BINDIR=`dirname "$PRG"`/..
+
+# make it fully qualified
+cd "$saveddir"
+BINDIR="`cd "$BINDIR" && pwd`"
+
+exec java -jar "$BINDIR/lib/hudson.jar" "$@"
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Usage: slave <workdir> <envvar1> <value1> <envvar2> <value2> ... -- <command> <arg> ...
+#
+# This wrapper is used to launch a process remotely with some environment variables
+# set.
+
+# if there's any environment entries read them
+if [ -f $HOME/.hudson_slave_profile ];
+then
+ . $HOME/.hudson_slave_profile
+fi
+
+# set the current directory
+cd "$1"
+shift
+
+# fill in environment variables
+while [ $# -gt 1 -a "$1" != "--" ];
+do
+ eval $1="$2"
+ export $1
+ shift 2
+done
+
+if [ "$1" != "--" ];
+then
+ echo Error: no command given
+ exit -1
+fi
+
+shift
+
+# execute. use eval so that variables can be expanded now
+# this allows users to specify $HOME or $DISPLAY or anything else,
+# and it works as expected.
+#
+# but since eval mess up with whitespace ('eval ls "a b"' means the same as 'eval ls a b')
+# we need to re-escape arguments (we need to say 'eval ls \"a b\"' to achieve the desired effect)
+list=""
+for a in "$@"
+do
+ list="$list \"$a\""
+done
+eval "$list"
+ret=$?
+# these additional hooks seem to prevent "select: bad filer number" error
+# on some systems, so use this as a precaution. We can afford to waste
+# one second, can't we?
+sleep 1
+echo
+exit $ret
@@ -0,0 +1,88 @@
+header {
+ package hudson.scheduler;
+}
+
+class CrontabParser extends Parser("BaseParser");
+options {
+ defaultErrorHandler=false;
+}
+
+startRule [CronTab table]
+throws ANTLRException
+{
+ long m,h,d,mnth,dow;
+}
+ : m=expr[0] WS h=expr[1] WS d=expr[2] WS mnth=expr[3] WS dow=expr[4] EOF
+ {
+ table.bits[0]=m;
+ table.bits[1]=h;
+ table.bits[2]=d;
+ table.bits[3]=mnth;
+ table.dayOfWeek=(int)dow;
+ }
+ ;
+
+expr [int field]
+returns [long bits=0]
+throws ANTLRException
+{
+ long lhs,rhs=0;
+}
+ : lhs=term[field] ("," rhs=expr[field])?
+ {
+ bits = lhs|rhs;
+ }
+ ;
+
+term [int field]
+returns [long bits=0]
+throws ANTLRException
+{
+ int d=1,s,e,t;
+}
+ : (token "-")=> s=token "-" e=token ( "/" d=token )?
+ {
+ bits = doRange(s,e,d,field);
+ }
+ | t=token
+ {
+ rangeCheck(t,field);
+ bits = 1L<<t;
+ }
+ | "*" ("/" d=token )?
+ {
+ bits = doRange(d,field);
+ }
+ ;
+
+token
+returns [int value=0]
+ : t:TOKEN
+ {
+ value = Integer.parseInt(t.getText());
+ }
+ ;
+
+class CrontabLexer extends Lexer;
+options {
+ defaultErrorHandler=false;
+}
+
+TOKEN
+options {
+ paraphrase="a number";
+}
+ : ('0'..'9')+
+ ;
+
+WS
+options {
+ paraphrase="space";
+}
+ : (' '|'\t')+
+ ;
+
+MINUS: '-';
+STAR: '*';
+DIV: '/';
+OR: ',';
@@ -0,0 +1,16 @@
+package hudson;
+
+import java.io.FilterOutputStream;
+import java.io.OutputStream;
+
+/**
+ * @author Kohsuke Kawaguchi
+ */
+public class CloseProofOutputStream extends FilterOutputStream {
+ public CloseProofOutputStream(OutputStream out) {
+ super(out);
+ }
+
+ public void close() {
+ }
+}
@@ -0,0 +1,29 @@
+package hudson;
+
+import org.apache.tools.ant.taskdefs.Execute;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+/**
+ * @author Kohsuke Kawaguchi
+ */
+public class EnvVars {
+ /**
+ * Environmental variables that we've inherited.
+ */
+ public static final Map<String,String> masterEnvVars;
+
+ static {
+ Vector<String> envs = Execute.getProcEnvironment();
+ Map<String,String> m = new HashMap<String,String>();
+ for (String e : envs) {
+ int idx = e.indexOf('=');
+ m.put(e.substring(0, idx), e.substring(idx + 1));
+ }
+ masterEnvVars = Collections.unmodifiableMap(m);
+ }
+
+}
@@ -0,0 +1,16 @@
+package hudson;
+
+/**
+ * Marker interface that designates extensible components
+ * in Hudson that can be implemented by {@link Plugin}s.
+ *
+ * <p>
+ * Interfaces/classes that implement this interface can be extended by plugins.
+ * See respective interfaces/classes for more about how to register custom
+ * implementations to Hudson.
+ *
+ * @author Kohsuke Kawaguchi
+ * @see Plugin
+ */
+public interface ExtensionPoint {
+}
@@ -0,0 +1,15 @@
+package hudson;
+
+import java.util.Calendar;
+
+/**
+ * Provides a RSS feed view of the data.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public interface FeedAdapter<E> {
+ String getEntryTitle(E entry);
+ String getEntryUrl(E entry);
+ String getEntryID(E entry);
+ Calendar getEntryTimestamp(E entry);
+}
@@ -0,0 +1,143 @@
+package hudson;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * {@link File} like path-manipulation object.
+ *
+ * <p>
+ * In general, because programs could be executed remotely,
+ * we need two path strings to identify the same directory.
+ * One from a point of view of the master (local), the other
+ * from a point of view of the slave (remote).
+ *
+ * <p>
+ * This class allows path manipulation to be done
+ * and allow the local/remote versions to be obtained
+ * after the computation.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public final class FilePath {
+ private final File local;
+ private final String remote;
+
+ public FilePath(File local, String remote) {
+ this.local = local;
+ this.remote = remote;
+ }
+
+ /**
+ * Useful when there's no remote path.
+ */
+ public FilePath(File local) {
+ this(local,local.getPath());
+ }
+
+ public FilePath(FilePath base, String rel) {
+ this.local = new File(base.local,rel);
+ if(base.isUnix()) {
+ this.remote = base.remote+'/'+rel;
+ } else {
+ this.remote = base.remote+'\\'+rel;
+ }
+ }
+
+ /**
+ * Checks if the remote path is Unix.
+ */
+ private boolean isUnix() {
+ // Windows can handle '/' as a path separator but Unix can't,
+ // so err on Unix side
+ return remote.indexOf("\\")==-1;
+ }
+
+ public File getLocal() {
+ return local;
+ }
+
+ public String getRemote() {
+ return remote;
+ }
+
+ /**
+ * Creates this directory.
+ */
+ public void mkdirs() throws IOException {
+ if(!local.mkdirs() && !local.exists())
+ throw new IOException("Failed to mkdirs: "+local);
+ }
+
+ /**
+ * Deletes all the contents of this directory, but not the directory itself
+ */
+ public void deleteContents() throws IOException {
+ // TODO: consider doing this remotely if possible
+ Util.deleteContentsRecursive(getLocal());
+ }
+
+ /**
+ * Gets just the file name portion.
+ *
+ * This method assumes that the file name is the same between local and remote.
+ */
+ public String getName() {
+ return local.getName();
+ }
+
+ /**
+ * The same as {@code new FilePath(this,rel)} but more OO.
+ */
+ public FilePath child(String rel) {
+ return new FilePath(this,rel);
+ }
+
+ /**
+ * Gets the parent file.
+ */
+ public FilePath getParent() {
+ int len = remote.length()-1;
+ while(len>=0) {
+ char ch = remote.charAt(len);
+ if(ch=='\\' || ch=='/')
+ break;
+ len--;
+ }
+
+ return new FilePath( local.getParentFile(), remote.substring(0,len) );
+ }
+
+ /**
+ * Creates a temporary file.
+ */
+ public FilePath createTempFile(String prefix, String suffix) throws IOException {
+ File f = File.createTempFile(prefix, suffix, getLocal());
+ return new FilePath(this,f.getName());
+ }
+
+ /**
+ * Deletes this file.
+ */
+ public boolean delete() {
+ return local.delete();
+ }
+
+ public boolean exists() {
+ return local.exists();
+ }
+
+ /**
+ * Always use {@link #getLocal()} or {@link #getRemote()}
+ */
+ @Deprecated
+ public String toString() {
+ // to make writing JSPs easily, return local
+ return local.toString();
+ }
+
+ /**
+ * {@link FilePath} constant that can be used if the directory is not importatn.
+ */
+ public static final FilePath RANDOM = new FilePath(new File("."));
+}
Oops, something went wrong.

0 comments on commit 8a0dc23

Please sign in to comment.