[med-svn] [galaxy] 01/01: Packaging attempt by Biolinux migrated from Debian Med SVN

Andreas Tille tille at debian.org
Sat Dec 30 16:32:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch biolinux
in repository galaxy.

commit d6207bf970bba198135b50260be32799e25aba09
Author: Andreas Tille <tille at debian.org>
Date:   Sat Dec 30 17:32:12 2017 +0100

    Packaging attempt by Biolinux migrated from Debian Med SVN
---
 debian/README.apache2-setup                        | 251 +++++++++++++++++++++
 debian/README.postgres-setup                       | 150 ++++++++++++
 debian/README.source                               |  30 +++
 debian/README.split-ini                            |  29 +++
 .../etc/apache2/conf-available/galaxy.conf         |  38 ++++
 .../etc/apache2/conf-available/pwauth.conf         |   4 +
 .../etc/galaxy-server/galaxy.htaccess              |  38 ++++
 .../usr/share/galaxy-server/logout/.htaccess       |  13 ++
 .../usr/share/galaxy-server/logout/.htpasswd       |   2 +
 .../usr/share/galaxy-server/logout/logout.html     |  18 ++
 .../usr/share/galaxy-server/proxy/.htaccess        |   1 +
 .../usr/share/galaxy-server/static/logout1.html    |  33 +++
 debian/changelog                                   | 245 ++++++++++++++++++++
 debian/cleanup_everything.sh                       | 105 +++++++++
 debian/compat                                      |   1 +
 debian/config_override/README                      |   2 +
 debian/config_override/tool_data_table_conf.xml    | 129 +++++++++++
 debian/config_override/welcome.html                |  35 +++
 debian/control                                     |  67 ++++++
 debian/copy_sample_config.sh                       |  69 ++++++
 debian/copyright                                   | 195 ++++++++++++++++
 debian/galaxy-server-apache-proxy.docs             |   1 +
 debian/galaxy-server-apache-proxy.install          |   2 +
 debian/galaxy-server-apache-proxy.postinst         |  59 +++++
 debian/galaxy-server-apache-proxy.postrm           |  35 +++
 debian/galaxy-server-pg-database.docs              |   1 +
 debian/galaxy-server-pg-database.install           |   1 +
 debian/galaxy-server-pg-database.postinst          | 169 ++++++++++++++
 debian/galaxy-server-pg-database.postrm            |  20 ++
 debian/galaxy-server-test.install                  |   5 +
 debian/galaxy-server.docs                          |   2 +
 debian/galaxy-server.install                       |  43 ++++
 debian/galaxy-server.postinst                      |  78 +++++++
 debian/galaxy-server.postrm                        |  20 ++
 debian/galaxy-server.preinst                       |  19 ++
 debian/galaxy-server.prerm                         |  13 ++
 debian/galaxy.conf                                 |  28 +++
 debian/galaxy.desktop                              |  10 +
 debian/galaxy_icon.png                             | Bin 0 -> 3786 bytes
 debian/get-orig-source.sh                          |  77 +++++++
 debian/goto_galaxy.sh                              |  56 +++++
 debian/make_transfer_dirs.sh                       |  35 +++
 debian/patches/add_favicon_to_masthead             |  20 ++
 debian/patches/commit_1298d3f                      |  68 ++++++
 debian/patches/drop_tmp_table_before_upgrade       |  25 ++
 debian/patches/fix_build_universe_config           |  11 +
 debian/patches/fix_unit_test                       |  25 ++
 .../patches/fix_workflow_misconfiguration_report   |  16 ++
 debian/patches/force_use_of_bash_interpreter       |  32 +++
 debian/patches/keep_shed_tools_in_this_directory   |  16 ++
 debian/patches/relax_password_length_restriction   |  55 +++++
 debian/patches/series                              |  11 +
 debian/patches/shed_tools_data_path                |  11 +
 debian/patches/tell_user_how_to_add_administrator  |  12 +
 debian/patches/use_system_python_libs              |  71 ++++++
 debian/remove_obsolete_eggs.sh                     |  11 +
 debian/rules                                       |  95 ++++++++
 debian/run.sh                                      |  55 +++++
 debian/sbin/galaxy-add-administrator               | 190 ++++++++++++++++
 debian/source/format                               |   1 +
 debian/source/include-binaries                     |   1 +
 debian/universe_wsgi.d/10_debian_defaults.ini      |  54 +++++
 debian/universe_wsgi.d/31_apache-proxy.ini         |  17 ++
 debian/universe_wsgi.d/32_pg-database.ini          |   8 +
 galaxy_16.10.orig.tar.xz.delta                     | Bin 167946 -> 0 bytes
 galaxy_16.10.orig.tar.xz.id                        |   1 -
 66 files changed, 2934 insertions(+), 1 deletion(-)

diff --git a/debian/README.apache2-setup b/debian/README.apache2-setup
new file mode 100644
index 0000000..818a95f
--- /dev/null
+++ b/debian/README.apache2-setup
@@ -0,0 +1,251 @@
+Configuring Galaxy to use Apache2 on Bio-Linux
+==============================================
+
+The page -
+http://wiki.galaxyproject.org/Admin/Config/Apache%20Proxy
+outlines why one would want to use Apache as a proxy to Galaxy and how to go
+about setting it up.  This document gives specific instructions for Bio-Linux,
+where the location of the galaxy server and the Apache2 configuration files are
+not in the locations assumed by the official Wiki.
+
+This document also explains how Apache2 proxying and PAM authentication are set up
+by the galaxy-server-apache-proxy package. "PAM authentication" just means that
+each user logs in with their regular system user name and password, rather than
+making an account on Galaxy against their e-mail address.  A consequence of this
+is that users will also be able to transfer their files securely into Galaxy
+without using the web upload form.
+
+So if you just want the standard set-up, go ahead and install the
+galaxy-server-apache-proxy package which activates both these
+features at once.  But if you want to understand what that is doing, or to
+enable proxying while still using internal authentication in Galaxy, or if you
+have reconfigured your Apache server in a way that conflicts with the default
+settings then you can ignore the package and set things up manually as described
+here.
+
+#! Text like this in the document indicates what would be a footnote if this were
+#! a printed doc.
+
+Security warning!!
+==================
+
+The galaxy-server-apache-proxy package does not (yet) activate HTTPS on the
+Apache server, so anyone logging into Galaxy from outside the local server
+will end up sending their password in the clear over the network.  For a
+closed local network this may be acceptable, but you should consider better
+security.  See the section on "Secure Connections" below.
+
+Prerequisites
+=============
+
+You should have Apache2 installed and running from the regular apache2 package,
+so that your configuration fragments can be added to /etc/apache2/conf.d.  This
+is the default on Bio-Linux.  Visit http://localhost in a web browser to check
+if Apache is running and you can see the standard test page displayed.
+
+In addition, assuming you want PAM authentication, install the following packages:
+
+ libapache2-mod-authnz-external
+ libapache2-mod-authz-unixgroup
+ pwauth
+
+Configuring the Apache Proxy
+============================
+
+We're going to set things up so Galaxy appears at http://your.machinename/galaxy.
+If you want to use a different path, modify the instructions accordingly.
+
+First for Apache.  Enable the modules.
+
+ $ sudo -i    ## Will give you a root shell, represented here by a hash (#)
+ # a2enmod proxy proxy_http rewrite
+
+Put the following lines into a file named /etc/apache2/conf.d/galaxy:  
+
+#!  Note: These are essentially equivalent to the ones listed in the Wiki page
+#!  but for those to work on BL they would need to be placed within the <VirtualHost>
+#!  tags in /etc/apache2/sites-enabled/default whereas this variant can be put
+#!  into conf.d without editing any existing files.  Order of rules is very important.
+#!  Also the use of the proxy directory allows us to avoid costly auth calls for every
+#!  static file requested.
+
+Alias /galaxy /usr/share/galaxy-server
+<Directory /usr/share/galaxy-server>
+Options -Indexes
+RewriteEngine on
+RewriteBase /galaxy
+RewriteRule ^(logout\..*) logout/$1 [L]
+RewriteRule ^logout/ - [L]
+RewriteRule ^static/style/(.*) static/june_2007_style/blue/$1 [L]
+RewriteRule ^static/scripts/packed/ - [L]
+RewriteRule ^static/scripts/(.*) static/scripts/packed/$1 [L]
+RewriteRule ^(static|test-data)/ - [L]
+RewriteRule ^(favicon.ico|robots.txt) static/$1 [L]
+RewriteRule (.*) proxy/$1
+</Directory>
+<Directory /usr/share/galaxy-server/logout>
+Options -Indexes
+AllowOverride AuthConfig FileInfo
+</Directory>
+<Directory /usr/share/galaxy-server/proxy>
+Options -Indexes
+AllowOverride AuthConfig FileInfo
+RewriteEngine on
+RewriteBase /galaxy/proxy
+RewriteRule (.*) http://localhost:8080/$1 [P,E=RU:%{REMOTE_USER}]
+</Directory>
+
+Ensure the logout and proxy directories exists:
+
+ # mkdir -p /usr/share/galaxy-server/{proxy,logout}
+
+And tell Apache to restart and activate this new config like so:
+
+ # service apache2 restart
+
+If you have a firewall installed, which is also default on Bio-Linux, you can
+use the firewall settings to control which machines can connect to your web
+server on port 80.  If you only want to connect from the local machine (or via
+a proxied connection as outlined below) you can disallow all external connections
+on port 80 (default on BL) and just connect to the server via the loopback
+interface - ie: typing http://localhost/galaxy in a browser on the machine.
+
+You will also still be able to access Galaxy directly at http://localhost:8080 on
+the local machine and this will bypass Apache completely, but of course PAM
+authentication won't work if you do this.
+
+It is also possible to control which hosts can connect through Apache "allow" and "deny"
+directives, but I'm assuming if you want to do that you can work it out for yourself.
+
+Configuring PAM Authentication in Apache
+========================================
+
+We're going to make a system group called "galaxy" and only members of this group
+will be able to log in.  You don't have to do this - you could allow any user to
+access Galaxy or you could use an existing group like "ssh" to say that anyone with
+remote shell login access can also access galaxy.
+
+ # groupadd galaxy
+ # usermod -aG galaxy user1
+ # usermod -aG galaxy user2
+
+(Where user1 and user2 are existing accounts on the system)
+
+Enable the three relevant Apache modules:
+
+ # a2enmod authnz_external authz_unixgroup headers
+
+Add the following lines to /etc/apache2/conf.d/pwauth:
+
+AddExternalAuth pwauth /usr/sbin/pwauth
+SetExternalAuthMethod pwauth pipe
+
+Add the following lines to /usr/share/galaxy-server/proxy/.htaccess:
+
+#!  Note the "Require group" line means only users in the galaxy group get access.
+
+AuthBasicProvider external
+AuthExternal pwauth
+AuthType Basic
+AuthName Galaxy_Server
+AuthzUnixgroup on
+Require group galaxy
+RequestHeader set REMOTE_USER %{RU}e env=RU
+RequestHeader unset Authorization env=RU
+
+And restart Apache once more:
+
+ # service apache2 restart
+
+#! Note: The Wiki page gives a slightly more complicated way of dealing with the REMOTE_USER
+#! variable which doesn't actually work for the setup described here.  Looking on Google there
+#! are various discussions of the issue but no explanations of the underlying problem, so I
+#! had to experiment.  The final RewriteRule in conf.d/galaxy above passes REMOTE_USER to the Proxy
+#! module before it disappears from scope, and the RequestHeader line in .htaccess then adds
+#! it to the proxied request.  Passing the variable in the RewriteRule has no effect without
+#! the RequestHeader directive so there is no reason not to have it there even if you are not
+#! using Apache for authentication.
+#! Also, the Authorization header has the password embedded in it, so I scrub this out before
+#! proxying.  Galaxy doesn't need this info and the less that login passwords are passed around
+#! the better.
+
+Finally, tell Galaxy to defer user authentication to Apache.  Make a file
+/etc/galaxy-server/universe_wsgi.ini.d/31_apache-proxy.ini and add the following:
+
+[app:main]
+use_remote_user = True
+remote_user_maildomain = localhost
+
+filter-with = proxy-prefix
+[filter:proxy-prefix]
+use = egg:PasteDeploy#prefix
+prefix = /galaxy
+
+Note that the last four lines should not be necessary as they are already the
+defaults on Bio-Linux but if for some reason you want to change the prefix from
+/galaxy you can do so here.
+
+And restart Galaxy:
+
+ # service galaxy restart
+
+#### TODO - I need to document my implementation of the logout hack.
+
+Enabling Efficient File Transfers
+=================================
+
+The Galaxy start-up script on Bio-Linux has a feature that it will scan for users in
+the galaxy group and for each user it will make a directory called eg. "user1 at localhost" under
+/var/lib/galaxy-server/transfer and set appropriate permissions so that users can place files
+there for upload with the Upload File feature of Galaxy.
+
+To enable this feature set the ftp_upload_dir option in universe_wsgi.ini.d/31_apache-proxy.ini
+to /var/lib/galaxy-server/transfer, and also set ftp_upload_site to the name of your server.
+
+Users likely want to make a symlink to their transfer area in their home directory - eg:
+
+ $ ln -s /var/lib/galaxy-server/transfer/$USER at localhost ~/galaxy_transfer
+
+#!  Note1 - galaxy-server-apache-proxy package will enable file transfers as described here, but
+#!  will not add symlinks to user home dirs.  Each user has to do that themselves.
+
+#!  Note2 - users with a personal umask of 007 or 077 will need to ensure that the files they
+#!  put in their transfer directory are world-readable (o+r) so the Galaxy server can see them.
+#!  This will not make the files visible to other users as users cannot see into other transfer
+#!  directories at all.
+
+It is also possible to have things the other way round, replacing the user1 at localhost directory with
+a symlink to some folder in the user's home dir.  The user will need to "chmod a+x ~" and the
+sysadmin will need to put the link in place.  This could be useful if your /home
+and /var partitions are on different disks and you want to avoid moving files around.
+
+Secure Connections
+==================
+
+If you are using Galaxy on the local machine, connecting via "http://localhost/galaxy" there
+is no problem with network security as no passwords go over the wire.  On a local ethernet
+segment it is arguably paranoid to worry about password sniffing, but on a WAN or any
+sort of wireless connection youa really want to encrypt traffic.
+
+Option 1: Use FreeNX or X2Go or SSH with X11 forwarding to run a web browser on the Bio-Linux
+machine displayed on your own PC.  This is secure but can be slow, makes file transfers and
+printing complicated, and rather defeats the object of doing your analysis in the web browser.
+
+Option 2: Get SSH to do secure port forwarding.  If your PC is Linux or MacOS, on the command
+line:
+    ssh -L8090:127.0.0.1:80 myserver.neasden.ac.uk
+
+Then so long as the SSH connection is active, you can point a web browser at
+"http://localhost:8090/galaxy" to get to Galaxy on the server, with the connection
+encrypted by SSH.  There is no need to open port 80 on the server firewall.  On Windows use
+PuTTY, and under the Tunnels option and add a local port forwarding rule.
+
+Option 3: Install and configure the libapache2-mod-gnutls package to switch Apache to serving
+secure HTTP requests.  Setting up mod-gnutls is beyond the scope of this doc but is explained
+in detail elsewhere.
+
+More Help
+=========
+
+Please ask any questions specifically relating to Galaxy on Bio-Linux on the community
+mailing list bio-linux at nebc.nerc.ac.uk.
diff --git a/debian/README.postgres-setup b/debian/README.postgres-setup
new file mode 100644
index 0000000..e53f86f
--- /dev/null
+++ b/debian/README.postgres-setup
@@ -0,0 +1,150 @@
+Setting up Galaxy to use PostgreSQL on Bio-Linux
+================================================
+
+The Galaxy system keeps operational data within a SQL database, which by default
+is the simple SQLite system.  For any serious use of Galaxy, you will want to
+use a dedicated database server.  See
+http://wiki.galaxyproject.org/Admin/Config/Performance/ProductionServer
+for more details.
+
+Bio-Linux already comes with both PostgreSQL and MySQL.  Furthermore, a
+convenience package called galaxy-server-pg-database can help you set PostgreSQL
+up to work with Galaxy.  In the simplest case:
+
+  $ sudo apt-get install galaxy-server-pg-database
+
+will give you a secure and ready-to-use set-up, and you are done.
+
+This document is therefore useful if you want to:
+
+a. Understand what is actually set up by installing galaxy-server-pg-database.
+b. Manually set up the database when the above fails.
+c. Install an alternative database configuration.
+d. Implement effective back-ups and migrate data when PostgreSQL is upgraded.
+
+This document does not deal with:
+
+a. Migration of existing data from SQLite to PostgreSQL.  The Galaxy Wiki states
+   that "free conversion tools are available on the web, [but] this process is
+   non-trivial".
+b. The fundementals of relational databases or PostgreSQL database
+   administration.  A starting point is here:
+   http://www.postgresql.org/docs/9.2/static/index.html
+   (see especially chapter 18).
+
+Checking the PostgreSQL set-up on Bio-Linux
+===========================================
+
+#!  NB: You will not find any information about PostgreSQL "clusters" in the
+#!  regular PostgreSQL documentation because they are a specific feature of Debian
+#!  (inherited by Ubuntu and thus Bio-Linux) - see
+#!  http://nebc.nerc.ac.uk/tools/bio-linux/other-bl-docs/sql-databases-on-bio-linux
+#!  and /usr/share/doc/postgresql-common/README.Debian.gz.
+
+Run the command "pg_lsclusters".  You should see output something like this:
+
+Version Cluster  Port Status Owner    Data directory                 Log file
+8.4     main     5433 online postgres /var/lib/postgresql/8.4/main   /var/log...
+9.1     main     5432 online postgres /var/lib/postgresql/9.1/main   /var/log...
+
+On a newly-installed system you should see just one line, but on a system that
+has been upgraded from a previous release of Bio-Linux you may well see two
+lines as above.  Here, two instances of PosgreSQL are running, and the default
+instance is whichever one runs on port 5432.  Hopefully the newest instance is
+also the default!  If you see two instances like this and want to clean up the
+redundant one you can either stop it like so:
+
+  $ sudo /etc/init.d/postgresql stop
+  $ sudo nano /etc/postgresql/8.4/main/start.conf 
+     ### change setting from auto to "manual" or "disabled"
+  $ sudo /etc/init.d/postgresql start
+
+or permanently delete it:
+
+  $ sudo pg_dropcluster --stop 8.4 main
+
+Each cluster being a separate running instance of PostgreSQL may have many
+databases.  To check what databases were hosted in the 8.4 cluster, prior to
+shutting it down, I could have done:
+
+  $ sudo -u postgres psql -l -p 5433
+
+Note that running "sudo -u postgres psql" is the recommended standard way to
+administer PostgreSQL databases on Bio-Linux.  You should not need to set a
+password for either the postgres system user or the postgres database role in
+order to perform standard administration.
+
+What the galaxy-server-pg-database package does
+===============================================
+
+The automated set-up will aim to create a role and database for Galaxy within
+the default PostgreSQL cluster - ie.  whichever cluster is named "main" and
+running on port 5432.  If there is no such cluster it will fail.  Also, if there
+are multiple running clusters named "main" the script will scan for an existing
+Galaxy database in any older "main" clusters.  If it finds one in an older
+cluster but not in the default one, it will assume that you probably want to
+upgrade your old database and will bail out with an error.  In this case, you
+will need to do the upgrade by running pg_upgradecluster (see the docs linked
+above), or you can just stop the old cluster before installing the package - the
+script will then ignore it and proceed to create the new database.
+
+Once these checks are passed, the script will do the following:
+
+sudo -Hi -u postgres createuser -w Debian-galaxy -DRS
+sudo -Hi -u postgres createdb -w Debian-galaxy -E UTF8 -O Debian-galaxy
+
+/etc/galaxy-server/universe_wsgi.d/32_pg-database.ini will tell Galaxy to access
+the new database and options recommended for PostgreSQL will be activated:
+
+database_connection = postgresql:///Debian-galaxy
+
+database_engine_option_server_side_cursors = True
+database_engine_option_strategy = threadlocal
+
+What the galaxy-server-pg-database package doesn't do
+=====================================================
+
+As mentioned above, the package does not automate migration of the database when
+PostgreSQL is upgraded, as this will generally be done for the whole server at
+once, and there may be other databases installed.
+
+The package does not modify the pg_hba.conf or any other configuration files
+related to the PostgreSQL server.  No password is set for the Debian-galaxy user
+in PostgreSQL as it is assumed that peer authentication is enabled (this is the
+default) so this is not needed.
+
+The package does not directly populate the new database.  This is done by
+restarting Galaxy, which will see that the database is empty and will
+automatically repopulate it.  Updated versions of Galaxy will (or at least should)
+also look after adding their own modifications to the Galaxy schema.
+
+The package doesn't add any cron jobs to clean out stale data (I may look at
+adding this).
+
+The package does not purge the database when it is removed, even if the package is
+purged.  Also you currently need to purge the package to remove the files in /etc
+though this might change at some point.
+
+Things you might want to set up manually
+========================================
+
+If you're reading this you are likely having issues with the database setup, in
+which case the best option is probably to remove the galaxy-server-pg-database
+package and sort things out yourself.  There is no reason not to do this - the
+package is just a convenience.
+
+You can use any name you like for the database user and the database, but you
+will need to ensure that Galaxy can connect and modify all tables within the
+database.  The Galaxy server runs in the account Debian-galaxy so having a
+matching user name in PostgreSQL allows simple user-based authentication to
+work.
+
+If you want to keep your database on a different remote server then you may need
+to use password authentication and embed the password into universe_wsgi.ini.
+In this case it is strongly recommended to choose a long, randomly generated
+password token and to limit database connections on the server by host IP.
+
+Here's one way to get a nicely randomised password token:
+
+  $ head -c 21 /dev/urandom| base64
+
diff --git a/debian/README.source b/debian/README.source
new file mode 100644
index 0000000..6130816
--- /dev/null
+++ b/debian/README.source
@@ -0,0 +1,30 @@
+Had a crack at packaging on 23/03/2012, having done all the dependencies.
+
+I've tried to move files to the right Debian-esque locations.  The Galaxy server
+expects a single directory heirarchy so I put that in /usr/lib/galaxy-server
+and made symlinks out from there.
+
+Major issue in terms of making a reasonable Debian package is the number of eggs
+needed by the server.  These should all really be Debian dependencies but I don't
+know if the Debian versions of Python packages will satisfy Galaxy or not.
+
+If using the eggs, fetching needs to be done before build stage as fetching
+remote files during the build is a definite no-no.
+
+Strategy is therefore:
+
+1) Make a package which includes amd64 eggs in the .orig.tar.gz and therefore is
+broken but at least we can build it quickly.
+2) Look to wean Galaxy off the Eggs one by one, replacing them with Debian
+package dependencies.
+3) When this is done, the package can be moved from amd64-only to build on
+any architecture.
+
+(2) is in progress with the use_system_python_libs patch.
+
+I've also added two convenience packages that modify the Galaxy installation by
+setting it to work on PostgreSQL and Apache2 respectively.  The idea is that
+anyone wanting these options can just install the packages and it will just work,
+but since the packages rely on a few assumptions and some cunning scripting they
+will not suit everyone.
+
diff --git a/debian/README.split-ini b/debian/README.split-ini
new file mode 100644
index 0000000..94b7a69
--- /dev/null
+++ b/debian/README.split-ini
@@ -0,0 +1,29 @@
+Galaxy ships with a script called scripts/build_universe_config.py that can
+construct universe_wsgi.ini from config fragment files.  As I'm dropping in
+modular configuration bits I need to use this, so it has been incorporated into the
+Galaxy start-up script.
+
+Bio-Linux packaging provides a /etc/galaxy-server/universe_wsgi.d directory containing:
+
+00_upstream.ini - A copy of universe_wsgi.ini from upstream.
+
+10_debian_defaults.ini - Settings overridden in the basic DEB package.
+
+31_apache-proxy.ini - Added by galaxy-server-apache-proxy if you install that.
+
+32_pg-database.ini - Added by galaxy-server-pg-database if you install that.
+
+35_tools_bl.ini - Added by galaxy-tools-bl if you install that.
+
+Users are advised not to edit any of these but to make new files with
+a higher priority and modify the contents.  Eg. to change the Apache settings:
+
+ $ cd /etc/galaxy-server/universe-wsgi.d
+ $ sudo cp 31_apache-proxy.ini 50_local.ini
+ $ sudo nano 50_local.ini
+
+The scripts/build_universe_config.py script will be used to create a
+config file under /tmp each time Galaxy is started, and there will be no
+universe_wsgi.ini in the package.  If you do supply tour own universe-wsgi.ini
+file then it will be used in preference to the dynamic one, but there should
+be no reason to do this.
diff --git a/debian/apache-proxy-files/etc/apache2/conf-available/galaxy.conf b/debian/apache-proxy-files/etc/apache2/conf-available/galaxy.conf
new file mode 100644
index 0000000..16b2ea0
--- /dev/null
+++ b/debian/apache-proxy-files/etc/apache2/conf-available/galaxy.conf
@@ -0,0 +1,38 @@
+#  Note: These rules are essentially equivalent to the ones listed in the Wiki page
+#  but for those to work on BL they would need to be placed within the <VirtualHost>
+#  tags in /etc/apache2/sites-enabled/default whereas this variant can be put
+#  into conf.d without editing any existing files.  Order of rules is very important.
+
+#  The proxy directory holds the .htaccess file which activates pwauth authentication.
+#  If I put the .htaccess file in the top-level directory then pwauth ends up being run
+#  for every static file and it is slow, slow, slow.
+
+Alias /galaxy /usr/share/galaxy-server
+<Directory /usr/share/galaxy-server>
+Options -Indexes
+RewriteEngine on
+RewriteBase /galaxy
+RewriteRule ^(logout\..*) logout/$1 [L]
+RewriteRule ^(logout1\..*) static/$1 [L]
+RewriteRule ^logout/ - [L]
+RewriteRule ^static/style/(.*) static/june_2007_style/blue/$1 [L]
+RewriteRule ^static/scripts/packed/ - [L]
+RewriteRule ^static/scripts/(.*) static/scripts/packed/$1 [L]
+RewriteRule ^(static|test-data)/ - [L]
+RewriteRule ^(favicon.ico|robots.txt) static/$1 [L]
+RewriteRule (.*) proxy/$1
+</Directory>
+
+<Directory /usr/share/galaxy-server/logout>
+Options -Indexes
+AllowOverride AuthConfig FileInfo
+</Directory>
+
+<Directory /usr/share/galaxy-server/proxy>
+Options -Indexes
+DirectoryIndex ''
+AllowOverride AuthConfig FileInfo
+RewriteEngine on
+RewriteBase /galaxy/proxy
+RewriteRule (.*) http://localhost:8080/$1 [P,E=RU:%{REMOTE_USER}]
+</Directory>
diff --git a/debian/apache-proxy-files/etc/apache2/conf-available/pwauth.conf b/debian/apache-proxy-files/etc/apache2/conf-available/pwauth.conf
new file mode 100644
index 0000000..0c4251b
--- /dev/null
+++ b/debian/apache-proxy-files/etc/apache2/conf-available/pwauth.conf
@@ -0,0 +1,4 @@
+#Added by the galaxy-server-apache-proxy package to enable users
+#to log into galaxy with their regular passwords.
+AddExternalAuth pwauth /usr/sbin/pwauth
+SetExternalAuthMethod pwauth pipe
diff --git a/debian/apache-proxy-files/etc/galaxy-server/galaxy.htaccess b/debian/apache-proxy-files/etc/galaxy-server/galaxy.htaccess
new file mode 100644
index 0000000..47dca1d
--- /dev/null
+++ b/debian/apache-proxy-files/etc/galaxy-server/galaxy.htaccess
@@ -0,0 +1,38 @@
+# This file is seen by Apache2 via the symlink
+# /usr/share/galaxy-server/.htaccess
+
+# Security settings for Galaxy proxied via Apache.  Note the actual proxy config
+# is under /etc/apache2/conf.d/galaxy.  If for some reason you wanted Apache proxy
+# with internal Galaxy authentication then you could remove this file and Apache
+# would no longer insist on authentication.
+AuthBasicProvider external
+AuthExternal pwauth
+AuthType Basic
+AuthName Galaxy_Server
+
+#I'd like to do this, but it upsets Firefox. Use ErrorDocument instead.
+# AuthName "Galaxy Server: \
+# Log in with regular username and password. \
+# Users need to be in the galaxy system group."
+
+ErrorDocument 401 "<html>\
+<title>401 Authorization Required</title>\
+<h1>Log-in to Galaxy failed</h1>\
+<p>You should have been prompted to log into the Galaxy server. \
+You need to give your regular system username and password. \
+Please reload this page to try again.</p>\
+<p>If this fails, check that you are a member of the galaxy system group, by \
+running <code>groups</code> on the command line.</p>\
+<p>To add a user, eg. user1, to this group, you may use the command:</p>\
+<ul><li><code>sudo usermod -aG galaxy user1</code></ul></li>\
+</html>"
+
+# You may want to comment this line out or to
+# change the group required, but users still need to
+# be in the galaxy group for SFTP uploads to work properly.
+Require unix-group galaxy
+
+# This is needed to tell Galaxy about the remote user, but after the
+# initial login Galaxy uses the galaxysession cookie to identify the session.
+RequestHeader set REMOTE_USER %{RU}e env=RU
+RequestHeader unset Authorization env=RU
diff --git a/debian/apache-proxy-files/usr/share/galaxy-server/logout/.htaccess b/debian/apache-proxy-files/usr/share/galaxy-server/logout/.htaccess
new file mode 100644
index 0000000..1f9db81
--- /dev/null
+++ b/debian/apache-proxy-files/usr/share/galaxy-server/logout/.htaccess
@@ -0,0 +1,13 @@
+# HaCk based on http://stackoverflow.com/questions/4163122/http-basic-authentication-log-out
+# Authname must match the one in ../proxy/.htaccess
+
+AuthType Basic
+AuthName Galaxy_Server
+
+AuthUserFile /usr/share/galaxy-server/logout/.htpasswd
+Require user logout
+
+# This assumes that the session cookie is "galaxysession" and it also assumes that
+# something will be loaded from the server, and not just pulled from the cache.  The
+# javascript in logout1.html tries to make sure this happens.
+Header set Set-Cookie "galaxysession=00000000; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"
diff --git a/debian/apache-proxy-files/usr/share/galaxy-server/logout/.htpasswd b/debian/apache-proxy-files/usr/share/galaxy-server/logout/.htpasswd
new file mode 100644
index 0000000..9dfa81d
--- /dev/null
+++ b/debian/apache-proxy-files/usr/share/galaxy-server/logout/.htpasswd
@@ -0,0 +1,2 @@
+#Password is logout, in case you wondered.
+logout:$apr1$0eB1iURY$kwqa0c8tXksbjPQLYqr6s.
diff --git a/debian/apache-proxy-files/usr/share/galaxy-server/logout/logout.html b/debian/apache-proxy-files/usr/share/galaxy-server/logout/logout.html
new file mode 100644
index 0000000..4b244e0
--- /dev/null
+++ b/debian/apache-proxy-files/usr/share/galaxy-server/logout/logout.html
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <link rel="stylesheet" href="static/style/base.css" type="text/css" />
+    <title>Logged out</title>
+</head>
+<body>
+    <div class="document">
+    <div class="donemessagelarge">
+        <strong>You logged out.</strong>
+	<hr>
+	But if you really want to be sure, close down the browser too.
+    </div>
+    <br/>
+</body>
+</html>
diff --git a/debian/apache-proxy-files/usr/share/galaxy-server/proxy/.htaccess b/debian/apache-proxy-files/usr/share/galaxy-server/proxy/.htaccess
new file mode 120000
index 0000000..f913e8f
--- /dev/null
+++ b/debian/apache-proxy-files/usr/share/galaxy-server/proxy/.htaccess
@@ -0,0 +1 @@
+/etc/galaxy-server/galaxy.htaccess
\ No newline at end of file
diff --git a/debian/apache-proxy-files/usr/share/galaxy-server/static/logout1.html b/debian/apache-proxy-files/usr/share/galaxy-server/static/logout1.html
new file mode 100644
index 0000000..40b852b
--- /dev/null
+++ b/debian/apache-proxy-files/usr/share/galaxy-server/static/logout1.html
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <!-- This should be served as galaxy/logout1.html, not /galaxy/static/logout1.html -->
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <link rel="stylesheet" href="static/style/base.css" type="text/css" />
+    <title>Logging out</title>
+
+<script type="text/javascript">
+  
+	var r=new XMLHttpRequest();
+	//Force the request to not cache.
+	var target='logout.html?' + new Date().getTime();
+
+	r.onreadystatechange=function(){
+		if(r.readyState==4)window.location.replace(target)
+	};
+	r.open('get',target,true,'logout','logout');
+	r.send();
+</script>
+
+</head>
+<body>
+    <div class="document">
+    <div class="donemessagelarge">
+        <strong>Logging out...</strong>
+	<hr>
+	This should take at most a couple of seconds.
+    </div>
+    <br/>
+</body>
+</html>
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..d49388f
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,245 @@
+galaxy (1.bl.py27.20140730-0biolinux4) trusty; urgency=medium
+
+  * Added default-jre as a build dep, to fix repacking of javascript
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Tue, 19 Aug 2014 17:16:56 +0100
+
+galaxy (1.bl.py27.20140730-0biolinux2) trusty; urgency=medium
+
+  * Update to 20140730 in the hope this supports the new data manager
+    tools system.
+    - http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4071198/pdf/btu119.pdf
+  * Drop the upstream patch as this is now integrated.
+  * Fix apache-proxy to work with new Apache a2enconf system
+  * Use new syntax for AuthzUnixgroup in .htaccess
+  * Add DirectoryIndex '' to galaxy.conf
+  * Remove link to silly noodle image no longer included
+  * Move tool-data out to /var/lib/galaxy-server and fix in preinst too
+    to allow new data manager shed tools to work
+  * Made shed_tools and tool-data world readable to aid debugging, as
+    there is no reason to hide them
+  * Re-re-fix the logout hack so we always defeat the Galaxy session cookie
+  * Link to documentation on environmentalomics.org
+  * Tweak the cleanup script to be more friendly (TODO: make it run weekly)
+  * Fudge PYTHONPATH in run.sh to enable bx-python, needed by genomic interval
+    tools
+  * Force repack of all .js files on build
+  * Patch mako templates to ensure favicon appears in browser title bar
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Wed, 06 Aug 2014 14:26:55 +0100
+
+galaxy (1.bl.py27.20140210-0biolinux8.2) trusty; urgency=medium
+
+  * Stop debian/galaxy-server-pg-database.postinst from complaining about new
+    pg_lsclusters output.
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 27 Jun 2014 16:56:31 +0100
+
+galaxy (1.bl.py27.20140210-0biolinux8.1) trusty; urgency=low
+
+  * Rebuild for Trusty
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Tue, 10 Jun 2014 14:12:27 +0100
+
+galaxy (1.bl.py27.20140210-0biolinux8) precise; urgency=low
+
+  * Fix silly error in make_transfer_dirs.sh
+  * Add new cleanup_everything.sh script
+  * Added patch https://bitbucket.org/galaxy/galaxy-central/commits/1298d3f
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Thu, 29 May 2014 17:27:47 +0100
+
+galaxy (1.bl.py27.20140210-0biolinux6) precise; urgency=low
+
+  * Fixed basic_auth logout once more.  Slightly neater now anyway.
+  * Made apache-proxy and pg-database remove their config files on removal so
+    you don't have to remember to purge them.
+  * Made config files in /tmp group-readable.
+  * Added data_manager_conf.xml.sample to list of sample files to copy
+  * Activate xz packing for drastic size reduction, and fix a couple of
+    Lintian warnings.
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Wed, 02 Apr 2014 16:46:49 +0100
+
+galaxy (1.bl.py27.20140210-0biolinux5) precise; urgency=low
+
+  * Fixed misspelling of shed-tools/shed_tools that messed up symlinks
+  * Don't build galaxy-server-all from this package any more, as the tool
+    defs are not distributed in the Galaxy core.
+  * Initialise just the shed_*.xml configuration files from .sample files
+    on first run, because I don't see that these should be be managed
+    by debconf - they are basically used as a config DB by Galaxy.
+  * Use overridden custom version of tool_data_table_conf.xml until I can work
+    out how to split this into multiple files or else build the config
+    on-the-fly.  Really this should be in bl_tools package.
+  * Remove .svn folders that had crept into debs
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Thu, 27 Mar 2014 17:17:26 +0000
+
+galaxy (1.bl.py27.20140210-0biolinux1) precise; urgency=low
+
+  * Updated Galaxy since previous version seems to have fundamental
+    issues installing from tool shed.
+  * Moved shed-tool-conf.xml to writable location in /var
+  * Note there is now a galaxy-tools-bl package to restore the
+    missing tools in one go
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Tue, 18 Mar 2014 16:46:14 +0000
+
+galaxy (1.bl.py27.20130926-0biolinux6) precise; urgency=low
+
+  * Re-do control files yet again.  I now believe invoke-rc.d is
+    THE way to stop and start services in packages, and not service
+    or start or initctl.
+  * To make this work, add symlink in /etc/init.d
+  * Fix problem where transfer dir ownership is broken on upgrade
+  * Add README files into /usr/share/doc
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Wed, 26 Feb 2014 13:56:29 +0000
+
+galaxy (1.bl.py27.20130926-0biolinux4) precise; urgency=low
+
+  * Now realised that Galaxy will use local libs if it finds the
+    local version is just right.  And it won't fetch those eggs.
+    Oh. Why does it have to be so "clever"?
+    For now, just ensure this is built on a machine without
+    python-migrate installed.
+  * Reduced use_system_python_libs to just localise psycopg for now,
+    as the static version doesn't work properly with socket
+    connections.
+  * Don't set cookie_path at all as it causes issues.
+  * Finish the apache-proxy module, including SFTP uploads and
+    a working (ish) logout.  Authentication via system user/pw and
+    membership of system galaxy group.
+  * Split config into multiple files and worked out how to allow
+    it to be reconstructed under /tmp
+  * Remove old universe_wsgi.ini on upgrade
+  * Fix and improve galaxy-add-administrator script
+  * Be more careful with initctl restart in scripts as it only works
+    when the service was already running.
+  * Ensure cleanup on purge.
+  * Added Simon W. Credit to welcome.html
+  * Ensure binary versions match for pg and apache pkgs
+  * Only use adm group for logs.
+  * Clean out compiled_templates on start
+  * Patch to stop upgrade of SQLite database failing
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 06 Dec 2013 16:54:43 +0000
+
+galaxy (1.bl.py27.20130926-0biolinux1) precise; urgency=low
+
+  * New upstream and try to get uploads to work again.
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Mon, 07 Oct 2013 12:21:41 +0100
+
+galaxy (1.bl.py27.20130812-0biolinux3) precise; urgency=low
+
+  * Reverted use_system_python_libs patch for now due to crazy
+    database corruption issue.
+  * Included psycopg3 egg in debian-galaxy to get pg-database
+    working.
+  * Add some debhelper tokens
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Thu, 03 Oct 2013 12:55:28 +0100
+
+galaxy (1.bl.py27.20130812-0biolinux2) precise; urgency=low
+
+  * Added galaxy-server-pg-database package to set up PG
+  * Fixed dep on Bowtie2
+  * Dropped patch dont_fetch_eggs in favour of custom run script
+  * This upgrades the database before running Galaxy - otherwise
+    in tests I got unexpected failures.  Less hassle for users but
+    maybe more issues as upgrade will be forced without warning the
+    admin to back up.  (HINT - Back up regularly anyway!)
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 06 Sep 2013 15:54:43 +0100
+
+galaxy (1.bl.py27.20130812-0biolinux1) precise; urgency=low
+
+  * Another new upstream
+  * Clean up as many Lintian warnings as I can
+  * Tighten up dependencies
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 23 Aug 2013 15:59:48 +0100
+
+galaxy (1.bl.py27.20130702-1) precise; urgency=low
+
+  * New upstream, and more
+  * Refreshed patches
+  * Forced Galaxy to accept using LOCAL libs instead of its own
+    eggs.
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Thu, 18 Jul 2013 13:39:01 +0100
+
+galaxy (1.bl.py27.20120718-5) precise; urgency=low
+
+  * Fix postinst script to not crash if no log file needs moving.
+    How the heck didn't this get noticed before??
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Tue, 11 Dec 2012 15:20:41 +0000
+
+galaxy (1.bl.py27.20120718-4) precise; urgency=low
+
+  * Various patches to address issues reported by SW
+  *   Increase database pool size
+  *   Make default configuration more sensible for a BL setting
+  *   Help setting up admin user accounts
+  *   Try to make picard-tools work with the Debian package
+  * Also, relax restrictions on user names and passwords
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 09 Nov 2012 10:10:40 +0000
+
+galaxy (1.bl.py27.20120718-2) precise; urgency=low
+
+  * Patch and permissions changes to get run_unit_tests.sh
+    to work.
+  * Moved logs to new location and allowed update script to
+    shift them if necessary.
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 12 Oct 2012 17:41:41 +0100
+
+galaxy (1.bl.py27.20120718-1) precise; urgency=low
+
+  * Rebuild from latest release
+  * Re-munge for Python 2.7
+  * Enable python2 debhelper
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Wed, 29 Aug 2012 17:53:41 +0100
+
+galaxy (1.bl.20120509-lucid1) lucid; urgency=low
+
+  * New upstream version
+  * Stop overwriting integrated_tool_panel.xml on update
+  * Remove the hacky_first_run as Galaxy now seems to work without it.
+    * Why the heck wasn't it working before?
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Thu, 12 Jul 2012 17:52:31 +0100
+
+galaxy (1.bl.20120307-lucid9) lucid; urgency=low
+
+  * Added patch to fix calling clustalw
+  * Fixed [pre/post]rm scripts to stop server before trying to
+    update or to purge the user account.
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Tue, 08 May 2012 17:50:01 +0100
+
+galaxy (1.bl.20120307-lucid7) lucid; urgency=low
+
+  * Added icon and script for people to click on
+  * Fixed issues with egg cache (must be writeable even after first run)
+  * Fixed location of shed_tools and added to package
+  * Fixed symlinks to /usr/share/galaxy-server
+  * Tidied up logging and moved log file init to galaxy.conf
+  * Customised welcome.html
+  * Set arch on all packages to amd64 so as not to upset PPA build
+  * Modified init script to set environment
+  * Changed dependencies of (-all) to match Soon's latest list
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Thu, 03 May 2012 18:19:57 +0100
+
+galaxy (1.bl.20120307-lucid1) lucid; urgency=low
+
+  * Initial release.
+  * Worked on by Soon and Tim.  This is not a pretty package :-(
+
+ -- Tim Booth <tbooth at ceh.ac.uk>  Fri, 27 Apr 2012 15:54:14 +0100
diff --git a/debian/cleanup_everything.sh b/debian/cleanup_everything.sh
new file mode 100755
index 0000000..e759f6c
--- /dev/null
+++ b/debian/cleanup_everything.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+# A script to run all the various cleanup routines as recommended in
+# https://wiki.galaxyproject.org/Admin/Config/Performance/Purge%20Histories%20and%20Datasets
+
+PRESERVE_DAYS=${PRESERVE_DAYS:-10}
+FORCE=${FORCE:-}
+
+export PYTHON_EGG_CACHE=/var/lib/galaxy-server/egg-cache
+
+# Help me make the log readable...
+LOGFILE=/var/log/galaxy/cleanup_everything.log
+lpre() {
+    if [ "$1" = "" ] || [ "$1" = "-" ] ; then
+        pre=
+    elif [ "$1" = '!' ] ; then
+        pre="**** "
+    else
+        pre="$1=> "
+    fi
+    echo -n "$pre"
+}
+
+log() {
+    pre="`lpre "$1"`"
+    shift
+
+    echo "$pre$@" | tee -a "$LOGFILE"
+}
+
+lcmd() {
+    pre="`lpre "$1"`"
+    spre="`echo "$pre" | sed -e 's/[\/&]/\\&/g'`"
+    shift
+
+    echo "${pre}CMD: $@ ===>" | tee -a "$LOGFILE"
+    if [ -n "$pre" ] ; then
+        eval "$@" | sed "s/^/$spre/" | tee -a "$LOGFILE"
+    else
+        eval "$@" | tee -a "$LOGFILE"
+    fi
+}
+
+# First, ensure I'm running as the same user who owns /var/lib/galaxy-server/egg-cache
+G_USER="`stat -c%U "$PYTHON_EGG_CACHE"`"
+
+if [ "$G_USER" != `whoami` ] ; then
+    echo "You need to run this script as $G_USER. Ie. try: sudo -u $G_USER $0"
+    exit 1
+fi
+
+# Then ensure I'm in the right directory
+if ! cd "/usr/lib/galaxy-server" ; then
+    echo "You need to run this script in /usr/lib/galaxy-server"
+    exit 1
+fi
+
+# Then, make myself a config file - copied from run.sh
+UWINI=universe_wsgi.ini
+RMUWINI=0
+
+if [ ! -e "$UWINI" ] ; then
+    UWINI=`mktemp --tmpdir universe_wsgi_XXXX.ini`
+    python ./scripts/build_universe_config.py universe_wsgi.d/ "$UWINI"
+    chmod g+r "$UWINI"
+    RMUWINI=1
+fi
+
+# === OK, the actual cleanupping ===
+
+log '!' "Cleanup run at `date`"
+
+log  duh "delete_userless_histories"
+lcmd duh python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -1
+
+log  ph "purge_histories"
+lcmd ph python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -2 -r
+
+log  pd "purge_datasets"
+lcmd pd python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -3 -r
+
+log  pf "purge_folders"
+lcmd pf python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -5 -r
+
+log  pl "purge_libraries"
+lcmd pl python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -4 -r
+
+log  dd "delete_datasets"
+lcmd dd python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -6 -r
+
+if [ -n "$FORCE" ] ; then
+  log  pd2 "purge_datasets_2 (this time with the -f flag)"
+  lcmd pd2 python ./scripts/cleanup_datasets/cleanup_datasets.py "$UWINI" -d $PRESERVE_DAYS -3 -r -f
+fi
+
+log  du "set_user_disk_usage"
+lcmd du env PYTHONPATH=./lib ./scripts/set_user_disk_usage.py -c "$UWINI" 2>&1
+
+log '!' "Finished at `date`"
+
+# === Done. ===
+
+if [ "$RMUWINI" = 1 ] ; then
+    rm "$UWINI"
+fi
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+8
diff --git a/debian/config_override/README b/debian/config_override/README
new file mode 100644
index 0000000..c2decf5
--- /dev/null
+++ b/debian/config_override/README
@@ -0,0 +1,2 @@
+Galaxy comes with various sample configs that all get copied into /etc/galaxy.
+If an alternative is found in here it will be used instead.
diff --git a/debian/config_override/tool_data_table_conf.xml b/debian/config_override/tool_data_table_conf.xml
new file mode 100644
index 0000000..c7aabb7
--- /dev/null
+++ b/debian/config_override/tool_data_table_conf.xml
@@ -0,0 +1,129 @@
+<!-- Use the file tool_data_table_conf.xml.oldlocstyle if you don't want to update your loc files as changed in revision 4550:535d276c92bc-->
+<tables>
+    <!-- Locations of all fasta files under genome directory -->
+    <table name="all_fasta" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/all_fasta.loc" />
+    </table>
+    <!-- Locations of indexes in the BFAST mapper format -->
+    <table name="bfast_indexes" comment_char="#">
+        <columns>value, dbkey, formats, name, path</columns>
+        <file path="tool-data/bfast_indexes.loc" />
+    </table>
+    <!-- Locations of nucleotide (mega)blast databases -->
+    <table name="blastdb" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/blastdb.loc" />
+    </table>
+    <!-- Locations of protein (mega)blast databases -->
+    <table name="blastdb_p" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/blastdb_p.loc" />
+    </table>
+    <!-- Locations of indexes in the Bowtie2 mapper format -->
+    <table name="bowtie2_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bowtie2_indices.loc" />
+    </table>
+    <!-- Locations of indexes in the BWA mapper format -->
+    <table name="bwa_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bwa_index.loc" />
+    </table>
+    <!-- Locations of indexes in the BWA color-space mapper format -->
+    <table name="bwa_indexes_color" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bwa_index_color.loc" />
+    </table>
+    <!-- Locations of MAF files that have been indexed with bx-python -->
+    <table name="indexed_maf_files">
+        <columns>name, value, dbkey, species</columns>
+        <file path="tool-data/maf_index.loc" />
+    </table>
+    <!-- Locations of fasta files appropriate for NGS simulation -->
+    <table name="ngs_sim_fasta" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/ngs_sim_fasta.loc" />
+    </table>
+    <!-- Locations of PerM base index files -->
+    <table name="perm_base_indexes" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/perm_base_index.loc" />
+    </table>
+    <!-- Locations of PerM color-space index files -->
+    <table name="perm_color_indexes" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/perm_color_index.loc" />
+    </table>
+    <!-- Location of SAMTools indexes and other files (new version)
+         Warning: until Galaxy release_2013.06.03 the format of this
+         table was:
+
+        <columns>line_type, value, path</columns>
+        <file path="tool-data/sam_fa_indices.loc" />
+
+         If you are updating your tool_data_table_conf.xml to the current
+         version you should first migrate your
+         tool-data/sam_fa_indices.loc file to a new
+         tool-data/sam_fa_new_indices.loc file with the format specified
+         below, which is explained in the relative sample file
+         tool-data/sam_fa_new_indices.loc.sample .
+         By using the new format it is possible to let the user choose
+         among multiple indexed genome variants having the same dbkey,
+         e.g. hg19canon vs. hg19full variants for hg19 dbkey.
+    -->
+    <table name="sam_fa_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/sam_fa_new_indices.loc" />
+    </table>
+    <!-- Location of Picard dict file and other files -->
+    <table name="picard_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/picard_index.loc" />
+    </table>
+    <!-- Location of Picard dict files valid for GATK -->
+    <table name="gatk_picard_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/gatk_sorted_picard_index.loc" />
+    </table>
+    <!-- Available of GATK references -->
+    <table name="gatk_annotations" comment_char="#">
+        <columns>value, name, gatk_value, tools_valid_for</columns>
+        <file path="tool-data/gatk_annotations.txt" />
+    </table>
+    <!-- Location of SRMA dict file and other files -->
+    <table name="srma_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/picard_index.loc" />
+    </table>
+    <!-- Locations of indexes in the Bowtie mapper format for TopHat to use -->
+    <table name="tophat_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bowtie_indices.loc" />
+    </table>
+    <!-- Locations of indexes in the Bowtie color-space mapper format for TopHat to use -->
+    <table name="tophat_indexes_color" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bowtie_indices_color.loc" />
+    </table>
+    <!-- Locations of indexes in the Bowtie2 mapper format for TopHat2 to use -->
+    <table name="tophat2_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bowtie2_indices.loc" />
+    </table>
+    <!-- Locations of configurations in the CCAT peak/region caller format -->
+    <table name="ccat_configurations" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/ccat_configurations.loc" />
+    </table>
+    <!-- Location of Mosaik files -->
+    <table name="mosaik_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/mosaik_index.loc" />
+    </table>
+    <!-- Added manually for cufflinks but really belongs in the galaxy-tools-bl package -->
+    <table name="fasta_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/fasta_indexes.loc" />
+    </table>
+</tables>
diff --git a/debian/config_override/welcome.html b/debian/config_override/welcome.html
new file mode 100644
index 0000000..a27c1d3
--- /dev/null
+++ b/debian/config_override/welcome.html
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <link rel="stylesheet" href="style/base.css" type="text/css" />
+</head>
+<body>
+    <div class="document">
+        <div class="donemessagelarge">
+            <strong>This is the Galaxy server, packaged for Bio-Linux.</strong>
+            <hr>
+            To customize this page edit <code>/etc/galaxy-server/static/welcome.html</code> then <code>sudo restart galaxy</code>.
+        </div>
+	<br/>
+	<strong>For more information about Galaxy on Bio-Linux, <a target="_blank" href="http://environmentalomics.org/bio-linux-galaxy"/>read this page.</a></strong>
+	<br/>
+	<br/>
+	To find out more about Galaxy, <a target="_blank" href="http://wiki.g2.bx.psu.edu/Learn"/>start here.</a> 
+        <br/>
+	<!-- TODO, dd something here now the noodles is dead
+        <img src="images/noodles.png" alt="WWFSMD?" style="display: block; margin-left: auto; margin-right: auto;" /></a>
+	-->
+        <hr/>
+        This project is supported in part by <a target="_blank" class="reference" href="http://www.nsf.gov">NSF</a>, <a target="_blank" class="reference" href="http://www.genome.gov">NHGRI</a>, and <a target="_blank" class="reference" href="http://www.huck.psu.edu">the Huck Institutes of the Life Sciences</a>.
+        <br/> <br/>
+	The core Galaxy server and 
+	dependencies were packaged for Bio-Linux by the <a target="_blank" href="http://nebc.nerc.ac.uk">NEBC Team</a> as part of a project
+	under the <a target="_blank" href="http://nbaf.nerc.ac.uk/nbaf-wallingford">NERC Biomolecular Analysis Facility</a> in collaboration 
+	with the <a target="_blank" href="http://bergmanlab.smith.man.ac.uk/">Bergman Lab at the University of Manchester</a> and with
+	<a target="_blank" href="http://www.lstmliverpool.ac.uk/research/departments/staff-profiles/simon-wagstaff">
+	Simon Wagstaff at the Liverpool School of Tropical Medicine Bioinformatics Unit</a>.
+    </div>
+</body>
+</html>
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..68df98d
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,67 @@
+Source: galaxy
+Priority: optional
+Section: science
+Maintainer: Tim Booth <tbooth at ceh.ac.uk>
+Uploaders: H. Soon Gweon <soonio at gmail.com>
+Build-depends: xmlstarlet, python, quilt (>= 0.46-7~), debhelper (>= 8),
+               default-jre
+Standards-Version: 3.9.3
+Homepage: http://galaxy.psu.edu/
+
+Package: galaxy-server
+Architecture: amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, adduser,
+         python-pycryptopp,
+         python-pysqlite2,
+         python-simplejson
+Recommends: sqlite3, netcat-openbsd, zenity
+Description: Web-based analysis environment for bioinformatics
+ This package contains the core code to run the Galaxy server,
+ but most of the functionality is supported by external
+ applications, so you need to install those too or install
+ galaxy-server-all to get them all.
+
+Package: galaxy-server-test
+Architecture: amd64
+Depends: ${misc:Depends}, galaxy-server (= ${binary:Version}), ${python:Depends}
+Description: Test and demo data for Galaxy server
+ This data comes in the main download and is useful for testing
+ but isn't needed to run a regular Galaxy server.
+
+Package: galaxy-server-pg-database
+Architecture: amd64
+Depends: galaxy-server  (= ${binary:Version}), python-psycopg2, ${misc:Depends}
+Pre-Depends: postgresql | postgresql-8.4
+Description: Activates PostgreSQL database back-end for Galaxy
+ This is a convenience package that attempts to set up Galaxy to use a
+ PostgreSQL back-end database.  This is recommeded for any Galaxy installation
+ that needs to support concurrent users or complex pipelines.  The package will
+ create a user and database named 'Debian-galaxy' within the default PostgreSQL
+ cluster.  Galaxy will be configured to use this database and restarted.
+ .
+ The configuration created by this module does not rely on any shared secret
+ passwords, so it will not work if you have disabled peer/ident authentication
+ in pg_hba.conf.
+ If the setup fails, or if you need a different configuration, you should not
+ install this package but do the set-up manually.  With galaxy-server installed,
+ instructions are in /usr/share/doc/galaxy-server/README.postgres-setup.
+ .
+ Note - this package will not work properly with the psycopg egg supplied by
+ Galaxy and so depends on having the system version installed.
+
+Package: galaxy-server-apache-proxy
+Architecture: amd64
+Pre-Depends: apache2
+Depends: galaxy-server (= ${binary:Version}), libapache2-mod-authnz-external, libapache2-mod-authz-unixgroup, pwauth, ${misc:Depends}
+Description: Activates Apache2 proxy for Galaxy server, and PAM authentication
+ This is a convenience package that sets up the Galaxy server to proxy via
+ Apache2 and changes the authentication to validate users with their regular
+ log-in names and passwords.
+ .
+ All users will need to be added to the galaxy group in order to access Galaxy.
+ .
+ This type of configuration should suit a typical lab where a single server
+ is used by several users.  It is not suitable if you want to run a public
+ server instance or allow Galaxy to be used anonymously.
+ If you want to do the configuration manually, see the file
+ /usr/share/doc/galaxy-server/README.apache2-setup.
diff --git a/debian/copy_sample_config.sh b/debian/copy_sample_config.sh
new file mode 100755
index 0000000..afae8f9
--- /dev/null
+++ b/debian/copy_sample_config.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+# The original run.sh copies sample config files before running.
+# We want to do this at the packaging stage.
+# Also, support putting our own stuff in config_override
+
+# This script needs to be run in debian/tmp
+
+# Plus special handling for universe_wsgi.ini which goes to 
+# universe-wsgi.d/00_upstream.ini along with all the stuff from
+# debian/universe-wsgi.d
+
+# Also for shed_tool_conf.xml.sample which needs to go into /var
+# as it gets rewritten as tools are added.
+
+SAMPLES="
+    datatypes_conf.xml.sample
+    data_manager_conf.xml.sample
+    external_service_types_conf.xml.sample
+    migrated_tools_conf.xml.sample
+    reports_wsgi.ini.sample
+    tool_conf.xml.sample
+    tool_data_table_conf.xml.sample
+    tool_sheds_conf.xml.sample
+    tool-data/shared/*/*.sample
+    tool-data/*.sample
+    static/*.sample
+"
+
+#Expand globs in correct directory
+SAMPLES=`( cd usr/lib/galaxy-server ; echo $SAMPLES )`
+
+# Create all the config files
+for sample in $SAMPLES; do
+    file=`echo $sample | sed -e 's/\.sample$//'`
+    filebase=`basename $file`
+    if [ -e "../config_override/$filebase" ] ; then
+	echo "Initializing /etc/galaxy-server/$file from config_override/$filebase"
+	mkdir -p etc/galaxy-server/`dirname $file`
+	cp "../config_override/$filebase" etc/galaxy-server/$file
+	ln -s /etc/galaxy-server/$file usr/lib/galaxy-server/$file
+    else
+	echo "Initializing /etc/galaxy-server/$file from `basename $sample`"
+	mkdir -p etc/galaxy-server/`dirname $file`
+	cp usr/lib/galaxy-server/$sample etc/galaxy-server/$file
+	ln -s /etc/galaxy-server/$file usr/lib/galaxy-server/$file
+    fi
+    #And remove the .sample versions
+    rm usr/lib/galaxy-server/$sample
+done
+
+# Deal with universe_wsgi.d
+d=etc/galaxy-server/universe_wsgi.d
+mkdir -p "$d"
+ln -s /"$d" usr/lib/galaxy-server/
+
+echo "Putting default universe_wsgi.ini into $d"
+mv usr/lib/galaxy-server/universe_wsgi.ini.sample "$d"/00_upstream.ini
+cp ../universe_wsgi.d/1* "$d"
+
+# Deal with shed_tool*_conf.xml
+# These are modified by Galaxy and not manually edited, so belong in /var 
+# but we do need the initial versions, so revert to the idea of copying the
+# sample files.
+for stc in shed_tool_conf.xml shed_tool_data_table_conf.xml shed_data_manager_conf.xml ; do
+  echo "Linking to /var/lib/galaxy-server/${stc}, to be initialised from ${stc}.sample"
+  #mv -v usr/lib/galaxy-server/${stc}.sample var/lib/galaxy-server/shed_tools/${stc}
+  ln -s /var/lib/galaxy-server/shed_tools/${stc} usr/lib/galaxy-server/${stc}
+done
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..1fb8151
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,195 @@
+Format: http://dep.debian.net/deps/dep5/
+Upstream-Name: Galaxy
+Upstream-Contact: Galaxy Devs <galaxy-dev at lists.bx.psu.edu>
+Source: https://bitbucket.org/galaxy/galaxy-dist
+
+Files: *
+Upstream Authors:
+    Many
+Copyright:
+    Copyright (c) 2005-2013 Pennsylvania State University
+License:
+    Academic Free License version 3.0
+
+ 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, 
+    non-exclusive, sublicensable license, for the duration of the copyright, to 
+    do the following:
+
+    a) to reproduce the Original Work in copies, either alone or as part of a 
+       collective work;
+
+    b) to translate, adapt, alter, transform, modify, or arrange the Original 
+       Work, thereby creating derivative works ("Derivative Works") based upon 
+       the Original Work;
+
+    c) to distribute or communicate copies of the Original Work and Derivative 
+       Works to the public, under any license of your choice that does not 
+       contradict the terms and conditions, including Licensor's reserved 
+       rights and remedies, in this Academic Free License;
+
+    d) to perform the Original Work publicly; and
+
+    e) to display the Original Work publicly.
+
+ 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, 
+    non-exclusive, sublicensable license, under patent claims owned or 
+    controlled by the Licensor that are embodied in the Original Work as 
+    furnished by the Licensor, for the duration of the patents, to make, use, 
+    sell, offer for sale, have made, and import the Original Work and 
+    Derivative Works.
+
+ 3) Grant of Source Code License. The term "Source Code" means the preferred 
+    form of the Original Work for making modifications to it and all available 
+    documentation describing how to modify the Original Work. Licensor agrees 
+    to provide a machine-readable copy of the Source Code of the Original Work 
+    along with each copy of the Original Work that Licensor distributes. 
+    Licensor reserves the right to satisfy this obligation by placing a 
+    machine-readable copy of the Source Code in an information repository 
+    reasonably calculated to permit inexpensive and convenient access by You 
+    for as long as Licensor continues to distribute the Original Work.
+
+ 4) Exclusions From License Grant. Neither the names of Licensor, nor the 
+    names of any contributors to the Original Work, nor any of their 
+    trademarks or service marks, may be used to endorse or promote products 
+    derived from this Original Work without express prior permission of the 
+    Licensor. Except as expressly stated herein, nothing in this License 
+    grants any license to Licensor's trademarks, copyrights, patents, trade 
+    secrets or any other intellectual property. No patent license is granted 
+    to make, use, sell, offer for sale, have made, or import embodiments of 
+    any patent claims other than the licensed claims defined in Section 2. 
+    No license is granted to the trademarks of Licensor even if such marks 
+    are included in the Original Work. Nothing in this License shall be 
+    interpreted to prohibit Licensor from licensing under terms different 
+    from this License any Original Work that Licensor otherwise would have a 
+    right to license.
+
+ 5) External Deployment. The term "External Deployment" means the use, 
+    distribution, or communication of the Original Work or Derivative Works 
+    in any way such that the Original Work or Derivative Works may be used by 
+    anyone other than You, whether those works are distributed or 
+    communicated to those persons or made available as an application 
+    intended for use over a network. As an express condition for the grants 
+    of license hereunder, You must treat any External Deployment by You of 
+    the Original Work or a Derivative Work as a distribution under 
+    section 1(c).
+
+ 6) Attribution Rights. You must retain, in the Source Code of any Derivative 
+    Works that You create, all copyright, patent, or trademark notices from 
+    the Source Code of the Original Work, as well as any notices of licensing 
+    and any descriptive text identified therein as an "Attribution Notice." 
+    You must cause the Source Code for any Derivative Works that You create 
+    to carry a prominent Attribution Notice reasonably calculated to inform 
+    recipients that You have modified the Original Work.
+
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that 
+    the copyright in and to the Original Work and the patent rights granted 
+    herein by Licensor are owned by the Licensor or are sublicensed to You 
+    under the terms of this License with the permission of the contributor(s) 
+    of those copyrights and patent rights. Except as expressly stated in the 
+    immediately preceding sentence, the Original Work is provided under this 
+    License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or 
+    implied, including, without limitation, the warranties of 
+    non-infringement, merchantability or fitness for a particular purpose. 
+    THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This 
+    DISCLAIMER OF WARRANTY constitutes an essential part of this License. 
+    No license to the Original Work is granted by this License except under 
+    this disclaimer.
+
+ 8) Limitation of Liability. Under no circumstances and under no legal 
+    theory, whether in tort (including negligence), contract, or otherwise, 
+    shall the Licensor be liable to anyone for any indirect, special, 
+    incidental, or consequential damages of any character arising as a result 
+    of this License or the use of the Original Work including, without 
+    limitation, damages for loss of goodwill, work stoppage, computer failure 
+    or malfunction, or any and all other commercial damages or losses. This 
+    limitation of liability shall not apply to the extent applicable law 
+    prohibits such limitation.
+
+ 9) Acceptance and Termination. If, at any time, You expressly assented to 
+    this License, that assent indicates your clear and irrevocable acceptance 
+    of this License and all of its terms and conditions. If You distribute or 
+    communicate copies of the Original Work or a Derivative Work, You must 
+    make a reasonable effort under the circumstances to obtain the express 
+    assent of recipients to the terms of this License. This License 
+    conditions your rights to undertake the activities listed in Section 1, 
+    including your right to create Derivative Works based upon the Original 
+    Work, and doing so without honoring these terms and conditions is 
+    prohibited by copyright law and international treaty. Nothing in this 
+    License is intended to affect copyright exceptions and limitations 
+    (including "fair use" or "fair dealing"). This License shall terminate 
+    immediately and You may no longer exercise any of the rights granted to 
+    You by this License upon your failure to honor the conditions in 
+    Section 1(c).
+
+10) Termination for Patent Action. This License shall terminate 
+    automatically and You may no longer exercise any of the rights granted 
+    to You by this License as of the date You commence an action, including 
+    a cross-claim or counterclaim, against Licensor or any licensee alleging 
+    that the Original Work infringes a patent. This termination provision 
+    shall not apply for an action alleging patent infringement by 
+    combinations of the Original Work with other software or hardware.
+
+11) Jurisdiction, Venue and Governing Law. Any action or suit relating to 
+    this License may be brought only in the courts of a jurisdiction wherein 
+    the Licensor resides or in which Licensor conducts its primary business, 
+    and under the laws of that jurisdiction excluding its conflict-of-law 
+    provisions. The application of the United Nations Convention on 
+    Contracts for the International Sale of Goods is expressly excluded. Any 
+    use of the Original Work outside the scope of this License or after its 
+    termination shall be subject to the requirements and penalties of 
+    copyright or patent law in the appropriate jurisdiction. This section 
+    shall survive the termination of this License.
+
+12) Attorneys' Fees. In any action to enforce the terms of this License or 
+    seeking damages relating thereto, the prevailing party shall be entitled 
+    to recover its costs and expenses, including, without limitation, 
+    reasonable attorneys' fees and costs incurred in connection with such 
+    action, including any appeal of such action. This section shall survive 
+    the termination of this License.
+
+13) Miscellaneous. If any provision of this License is held to be 
+    unenforceable, such provision shall be reformed only to the extent 
+    necessary to make it enforceable.
+
+14) Definition of "You" in This License. "You" throughout this License, 
+    whether in upper or lower case, means an individual or a legal entity 
+    exercising rights under, and complying with all of the terms of, this 
+    License. For legal entities, "You" includes any entity that controls, is 
+    controlled by, or is under common control with you. For purposes of this 
+    definition, "control" means (i) the power, direct or indirect, to cause 
+    the direction or management of such entity, whether by contract or 
+    otherwise, or (ii) ownership of fifty percent (50%) or more of the 
+    outstanding shares, or (iii) beneficial ownership of such entity.
+
+15) Right to Use. You may use the Original Work in all ways not otherwise 
+    restricted or conditioned by this License or by law, and Licensor 
+    promises not to interfere with or be responsible for such uses by You.
+
+16) Modification of This License. This License is Copyright © 2005 Lawrence 
+    Rosen. Permission is granted to copy, distribute, or communicate this 
+    License without modification. Nothing in this License permits You to 
+    modify this License as applied to the Original Work or to Derivative 
+    Works. However, You may modify the text of this License and copy, 
+    distribute or communicate your modified version (the "Modified 
+    License") and apply it to other original works of authorship subject to 
+    the following conditions: (i) You may not indicate in any way that your 
+    Modified License is the "Academic Free License" or "AFL" and you may not 
+    use those names in the name of your Modified License; (ii) You must 
+    replace the notice specified in the first paragraph above with the 
+    notice "Licensed under <insert your license name here>" or with a notice 
+    of your own that is not confusingly similar to the notice in this 
+    License; and (iii) You may not claim that your original works are open 
+    source software unless your Modified License has been approved by Open 
+    Source Initiative (OSI) and You comply with its license review and 
+    certification process.
+
+
+Some icons found in Galaxy are from the Silk Icons set, available under
+the Creative Commons Attribution 2.5 License, from:
+
+http://www.famfamfam.com/lab/icons/silk/
+
+
+Other images and documentation are licensed under the Creative Commons Attribution 3.0 (CC BY 3.0) License.   See 
+
+http://creativecommons.org/licenses/by/3.0/
diff --git a/debian/galaxy-server-apache-proxy.docs b/debian/galaxy-server-apache-proxy.docs
new file mode 100644
index 0000000..459bd59
--- /dev/null
+++ b/debian/galaxy-server-apache-proxy.docs
@@ -0,0 +1 @@
+debian/README.apache2-setup
diff --git a/debian/galaxy-server-apache-proxy.install b/debian/galaxy-server-apache-proxy.install
new file mode 100644
index 0000000..63aced1
--- /dev/null
+++ b/debian/galaxy-server-apache-proxy.install
@@ -0,0 +1,2 @@
+debian/universe_wsgi.d/31*      /etc/galaxy-server/universe_wsgi.d
+debian/apache-proxy-files/*	/
diff --git a/debian/galaxy-server-apache-proxy.postinst b/debian/galaxy-server-apache-proxy.postinst
new file mode 100644
index 0000000..9a74cfb
--- /dev/null
+++ b/debian/galaxy-server-apache-proxy.postinst
@@ -0,0 +1,59 @@
+#!/bin/sh
+set -e
+set -u
+
+# This script will attempt to make Galaxy work with Apache2 without further user
+# interaction.  There are various stages.  If these fail, install should fail, so that
+# the user is obliged to remove this package or fix the issue and try again.
+# 1 - Enable modules needed in Apache2
+# 2 - Make a group for Galaxy users
+# 3 - Set settings in Galaxy
+# 4 - Reload Apache2 config and Galaxy
+#
+
+#DEBHELPER#
+
+# TODO - on failure, show error via Debconf rather than dumping to terminal.
+
+ifile="/etc/galaxy-server/universe_wsgi.d/31_apache-proxy.ini";
+if [ -e "$ifile.dpkg-bak" -a \! -e "$ifile" ] ; then
+    mv "$ifile.dpkg-bak" "$ifile"
+fi
+
+if [ -n "$1" -a "$1" != "configure" ] ; then
+    #Nowt more to do.
+    #I don't care much about abort-deconfigure right now.
+    exit 0
+fi
+
+# 1 - Note these won't be disabled when you remove the package, as I have
+# no way of knowing if you want them disabled or not.
+if ! a2enmod proxy proxy_http rewrite ; then
+    echo "Failed to activate modules needed for Apache2 proxying."
+    exit 1
+fi
+if ! a2enmod authnz_external authz_unixgroup headers ; then
+    echo "Failed to activate modules needed for Apache2 authentication."
+    exit 1
+fi
+
+# 1a - Also activate the two config fragments.  These will be disabled on
+# removal of the package
+if ! a2enconf galaxy pwauth ; then
+    echo "Failed to activate configuration fragments."
+    exit 1
+fi
+
+# 2
+getent group galaxy >/dev/null || addgroup galaxy
+
+# 3
+# Already done by installation of config fragment
+
+# 4 - Bounce Apache2 and Galaxy, if it's running.  If it is running but won't
+# restart we get upset.
+service apache2 reload 
+if initctl status galaxy | grep -q 'start/running' ; then
+    invoke-rc.d galaxy stop || true
+    invoke-rc.d galaxy start
+fi
diff --git a/debian/galaxy-server-apache-proxy.postrm b/debian/galaxy-server-apache-proxy.postrm
new file mode 100644
index 0000000..4e4e792
--- /dev/null
+++ b/debian/galaxy-server-apache-proxy.postrm
@@ -0,0 +1,35 @@
+#!/bin/sh
+set -e
+set -u
+
+#DEBHELPER#
+
+# I can't deactivate the Apache modules as I have no way to know if the user
+# wanted them anyway.  But I will remove the galaxy group if it is unused.
+
+# Handy members function.
+members(){
+    g_line=`getent group "$1"`
+    [ -n "$g_line" ] || { echo "No such group $1." >&2 ; return 1 ; }
+    getent passwd | awk -F: '$4 == "'`echo "$g_line" | cut -d: -f3`'" { printf("%s ",$1) }'
+    echo "$g_line" | cut -d: -f4 | tr , ' '
+}
+
+# Remove unused group
+[ -n "`members galaxy`" ] || groupdel galaxy || true
+
+# Ensure we no loger see the config fragment
+if [ "$1" = purge ] ; then
+    rm -f /etc/galaxy-server/universe_wsgi.d/31_apache-proxy.ini.dpkg-bak
+elif [ "$1" = remove ] ; then
+    ( cd /etc/galaxy-server/universe_wsgi.d && \
+      mv 31_apache-proxy.ini 31_apache-proxy.ini.dpkg-bak ) || true
+fi
+
+# Deconfigure Apache config fragments
+a2disconf galaxy pwauth || true
+
+# Bounce Apache2 and Galaxy, if it's running
+invoke-rc.d apache2 reload || true
+invoke-rc.d galaxy restart || true
+
diff --git a/debian/galaxy-server-pg-database.docs b/debian/galaxy-server-pg-database.docs
new file mode 100644
index 0000000..79f0575
--- /dev/null
+++ b/debian/galaxy-server-pg-database.docs
@@ -0,0 +1 @@
+debian/README.postgres-setup
diff --git a/debian/galaxy-server-pg-database.install b/debian/galaxy-server-pg-database.install
new file mode 100644
index 0000000..d94be7c
--- /dev/null
+++ b/debian/galaxy-server-pg-database.install
@@ -0,0 +1 @@
+debian/universe_wsgi.d/32*	/etc/galaxy-server/universe_wsgi.d
diff --git a/debian/galaxy-server-pg-database.postinst b/debian/galaxy-server-pg-database.postinst
new file mode 100644
index 0000000..3a7b5ff
--- /dev/null
+++ b/debian/galaxy-server-pg-database.postinst
@@ -0,0 +1,169 @@
+#!/usr/bin/perl
+use strict;
+
+# This script will attempt to make Galaxy work with PostgreSQL without further user
+# interaction.  There are various stages.  If these fail, install should fail, so that
+# the user is obliged to remove this package or fix the issue and try again.
+# 1- Check PG server set-up
+# 2- Check there is no database already
+# 3- Install role and database
+# 4- Modify Galaxy configuration
+# 5- Restart Galaxy
+
+#Ignore Debhelper tag - this is a Perl script.
+scalar('
+#DEBHELPER#
+');
+
+# And I don't know if this could be done with dbconfig-common but I'm pretty sure
+# how I want to handle things.
+
+# TODO - on failure, show error via Debconf rather than dumping to terminal.
+
+# Script written in Perl since I'm faster hacking Perl than Python.
+my $USERNAME = 'Debian-galaxy';
+my $DBNAME = $USERNAME;
+# Note if you do change this you also need to edit 32_pg-database.ini
+
+# In any case, ensure the .ini file is in place.
+my $ifile = "/etc/galaxy-server/universe_wsgi.d/32_pg-database.ini";
+if( -e "$ifile.dpkg-bak" && !-e $ifile )
+{
+	rename("$ifile.dpkg-bak", $ifile) or die $!;
+}
+
+if( $ARGV[0] && $ARGV[0] ne "configure")
+{
+    #Nowt more to do.
+	#I don't care about abort-deconfigure right now.
+    exit 0;
+}
+
+my @pg_lsc;
+{
+  local $ENV{LANG} = "C";
+
+  @pg_lsc = `/usr/bin/pg_lsclusters`;
+  (shift @pg_lsc) =~ /^Ver(?:sion|) / or die "Unexpected output from pg_lsclusters. Aborting.";
+}
+
+# Inspect running instances of PostgreSQL
+my $port_5432;
+my %port_to_ver;
+if(@pg_lsc)
+{
+	for(@pg_lsc)
+	{
+		chomp;
+		my @cluster = split(/\s+/, $_);
+
+		if($cluster[2] eq '5432')
+		{
+			$port_5432 = [ $cluster[0], $cluster[1], $cluster[3] ];
+		}
+		elsif($cluster[1] eq 'main' && $cluster[3] eq 'online')
+		{
+			$port_to_ver{$cluster[2]} = $cluster[0];
+		}
+	}
+}
+else
+{
+	#There are no clusters at all?  I'm going to go ahead and make one!
+	warn "No clusters found - creating a default one.\n";
+
+	my @pg_versions = sort { $b <=> $a } grep {/^[0-9]+\.[0-9]+/} map {/.*\/(.*)/} </usr/lib/postgresql/*>;
+	@pg_versions or die "No default PG version found.";
+
+	my $cc_res = `pg_createcluster --start-conf=auto --start --port=5432 $pg_versions[0] main`;
+	
+	$port_5432 = [ $pg_versions[0], 'main', 'online' ];
+}
+
+# Is there a "main" on "5432"?
+if(!$port_5432 or $port_5432->[1] ne 'main')
+{
+	die "There is no cluster named 'main' set to run on port 5432. Aborting.";
+}
+elsif($port_5432->[2] ne 'online')
+{
+	die "The default cluster is not running.  You need to ensure it starts automatically.  Aborting.";
+}
+
+# Is the database in there already?  If so, check connection and we're done, and just
+# need to fix the config.
+# As the role is created before the database, there should be no situation where the
+# database is there but the role still needs creating, so if the connection fails
+# just abort.
+if(is_database_in_cluster($DBNAME))
+{
+	check_connection($USERNAME) or die "Database already exists but connection failed. Aborting.";
+
+	warn "Database OK.\n";
+}
+else
+{
+
+	# So we probably need to create the DB, but first check -
+	# Are there other mains?
+	for(keys %port_to_ver)
+	{
+		if(is_database_in_cluster($DBNAME, $_))
+		{
+			die "There is already a $DBNAME database in the version $port_to_ver{$_} cluster.\n".
+				"You most likely want to migrate this into the current version of PostgreSQL,\n".
+				"for example by using pg_upgradecluster.  If not, turn off this cluster using\n".
+				"pg_ctlcluster and retry installation of this package.  Aborting.";
+		}
+	}
+
+	# OK, create the role and database.  It's possible if this was half-installed that the role is
+	# already set up.  Rather than error-checking the results of createuser and createdb just test
+	# the connection at the end.
+
+	my $cu_res = `sudo -Hi -u postgres createuser -w $USERNAME -DRS`;
+
+	my $cd_res = `sudo -Hi -u postgres createdb -w $DBNAME -E UTF8 -O $DBNAME`;
+
+	if(!check_connection($USERNAME))
+	{
+		die "The new database should have been created, but testing the connection failed.\n".
+			"You will need to investigate.  Aborting.";
+	}
+	warn "Database $DBNAME created.\n";
+}
+
+# At this point I used to edit the configuration file, but I've now moved to a modular
+# config, which is much saner.
+
+# And that should be that.  Restart Galaxy.
+# Note - if you install this and the main Galaxy package at once, Galaxy will fail to
+# start because the config file points to the DB but the DB is missing.  This is fine,
+# but means we want to start Galaxy whether it was running or not.
+system("invoke-rc.d galaxy restart || invoke-rc.d galaxy start");
+
+### Utility functions...
+
+#See if a given user can connect to a given database
+sub check_connection
+{
+	my $user = $_[0];
+	my $db = $_[1] || $_[0];
+
+	my $res = `cd /tmp; sudo -u $user /usr/bin/psql -d $db -qt -c 'select 1234'`;
+
+	$res =~ /1234/;
+}
+
+#See if a server hosts a database with a given name
+sub is_database_in_cluster
+{
+	my $db = $_[0];
+	my $port = $_[1] ? "-p $_[1]" : "";
+	
+	my @db_list = `sudo -Hi -u postgres /usr/bin/psql $port -l`;
+
+	grep { /^[[:space:]]*$db[[:space:]|]/ } @db_list;
+}
+
+1;
diff --git a/debian/galaxy-server-pg-database.postrm b/debian/galaxy-server-pg-database.postrm
new file mode 100644
index 0000000..42e5a3a
--- /dev/null
+++ b/debian/galaxy-server-pg-database.postrm
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+
+#DEBHELPER#
+
+# This script used to remove lines from universe_wsgi.ini but now I'm using the modular
+# config it is simpler.  I still want to rename the .ini file on removal otherwise it
+# continues to take effect.
+
+# This script will not touch the database at all.  You need to drop that yourself.
+if [ "$1" = purge ] ; then
+    rm -f /etc/galaxy-server/universe_wsgi.d/32_pg-database.ini.dpkg-bak
+    
+    invoke-rc.d galaxy restart || true
+elif [ "$1" = remove ] ; then
+    ( cd /etc/galaxy-server/universe_wsgi.d && \
+      mv 32_pg-database.ini 32_pg-database.ini.dpkg-bak ) || true
+
+    invoke-rc.d galaxy restart || true
+fi
diff --git a/debian/galaxy-server-test.install b/debian/galaxy-server-test.install
new file mode 100644
index 0000000..5e21443
--- /dev/null
+++ b/debian/galaxy-server-test.install
@@ -0,0 +1,5 @@
+#Things needed for the Galaxy testing?
+/usr/lib/galaxy-server/run_*_tests.sh
+/usr/lib/galaxy-server/run_reports.sh
+/usr/share/galaxy-server/test/
+/usr/share/galaxy-server/test-data/
diff --git a/debian/galaxy-server.docs b/debian/galaxy-server.docs
new file mode 100644
index 0000000..a0a13e6
--- /dev/null
+++ b/debian/galaxy-server.docs
@@ -0,0 +1,2 @@
+README.txt
+debian/README.split-ini
diff --git a/debian/galaxy-server.install b/debian/galaxy-server.install
new file mode 100644
index 0000000..eb21f8f
--- /dev/null
+++ b/debian/galaxy-server.install
@@ -0,0 +1,43 @@
+/etc
+/var/lib/galaxy-server/
+/usr/lib/galaxy-server/buildbot_setup.sh
+/usr/lib/galaxy-server/create_db.sh*
+/usr/lib/galaxy-server/cron/
+/usr/lib/galaxy-server/display_applications/
+/usr/lib/galaxy-server/dist-eggs.ini
+/usr/lib/galaxy-server/eggs/
+/usr/lib/galaxy-server/eggs.ini
+/usr/lib/galaxy-server/external_service_types/
+/usr/lib/galaxy-server/extract_dataset_parts.sh*
+debian/goto_galaxy.sh                 /usr/lib/galaxy-server/
+/usr/lib/galaxy-server/lib/
+/usr/lib/galaxy-server/locale/
+debian/make_transfer_dirs.sh          /usr/lib/galaxy-server/
+debian/cleanup_everything.sh          /usr/lib/galaxy-server/scripts/
+/usr/lib/galaxy-server/manage_db.sh*
+/usr/lib/galaxy-server/manage_tools.sh
+/usr/lib/galaxy-server/run_demo_sequencer.sh
+/usr/lib/galaxy-server/run_galaxy_listener.sh
+/usr/lib/galaxy-server/run_tool_shed.sh
+debian/run.sh                         /usr/lib/galaxy-server/
+/usr/lib/galaxy-server/scripts/
+/usr/lib/galaxy-server/set_metadata.sh*
+/usr/lib/galaxy-server/setup_rabbitmq.sh
+/usr/lib/galaxy-server/tool_conf.xml.main
+#/usr/lib/galaxy-server/tool-data
+/usr/lib/galaxy-server/tool_list.py
+/usr/lib/galaxy-server/tools/
+/usr/share/galaxy-server/static/
+/usr/share/galaxy-server/templates/
+### I've taken most of the .sample files out, as they are copied in /etc
+### and protected by debconf.
+/usr/lib/galaxy-server/shed_*.sample
+/usr/lib/galaxy-server/universe_wsgi.d
+
+###Build script creates links to files in /etc/
+/etc/galaxy-server/universe_wsgi.d/00*
+/etc/galaxy-server/universe_wsgi.d/10*
+/usr/lib/galaxy-server/*.xml
+
+###Custom scripts
+debian/sbin/* /usr/sbin/
diff --git a/debian/galaxy-server.postinst b/debian/galaxy-server.postinst
new file mode 100644
index 0000000..51f4cc2
--- /dev/null
+++ b/debian/galaxy-server.postinst
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+set -e
+cd /tmp
+
+#Only deal with configuration right now
+[ "$1" = configure ] || exit 0
+
+#Handy function
+globmatch() { test -e "$1" -o "`echo $1`" != "$1" ; }
+
+stop galaxy || true
+
+# Set up the galaxy user if it doesn't exist
+# We now need a special group too, in order to allow the server process
+# to see into the transfer directories
+if ! getent group Debian-galaxy >/dev/null ; then
+    addgroup --system Debian-galaxy
+fi
+
+if ! id Debian-galaxy >/dev/null 2>&1 ; then
+  adduser --no-create-home --system --ingroup Debian-galaxy --disabled-password --disabled-login --home /var/lib/galaxy-server/database Debian-galaxy
+fi
+
+# Account for the fact that old packages put Debian-galaxy in the daemon group
+if ! groups Debian-galaxy | sed 's/.*://' | grep -q Debian-galaxy ; then
+    usermod -g Debian-galaxy Debian-galaxy
+fi
+
+#DEBHELPER#
+
+touch /usr/lib/galaxy-server/database/integrated_tool_panel.xml
+#Ensure /var area is writeable
+for d in /var/lib/galaxy-server/* ; do
+    bn="`basename $d`"
+    if [ "$bn" != transfer ] ; then
+	chown -R Debian-galaxy $d
+	chgrp Debian-galaxy $d
+	#but this stuff, especially the database, must not be world-readable
+	#apart from the tool-data and shed_tools folders
+	if [ "$bn" = 'tool-data' -o "$bn" = shed_tools ] ; then
+	    chmod 755 $d
+	else
+	    chmod 750 $d
+	fi
+    fi
+done
+
+#I moved the log files, so handle that, even though the startup script
+#also creates the log dir if needed.
+if ! globmatch '/var/log/galaxy/*' ; then
+    mkdir -p /var/log/galaxy
+    chown Debian-galaxy:adm /var/log/galaxy
+    chmod 1775 /var/log/galaxy
+
+    ( cd /var/log ; [ ! -e galaxy.log ] || mv galaxy.log galaxy )
+    ( cd /var/log ; [ ! -e galaxy.out ] || mv galaxy.out galaxy )
+fi
+
+#If the server is being upgraded from < 1.bl.py27.20130926 then get shot of the old
+#universe_wsgi.ini.
+if dpkg --compare-versions "$2" lt 1.bl.py27.20130926 ; then
+   mv /etc/galaxy-server/universe_wsgi.ini /etc/galaxy-server/universe_wsgi.ini.dpkg_old || true
+fi
+
+#Remove stuff from /var/lib/galaxy-server/database/compiled_templates which can be
+#incompatible with the new server.
+rm -rf /var/lib/galaxy-server/database/compiled_templates/*
+
+#The server should start, but not if being installed in a chroot.  How best to detect this?
+#I had the idea of looking for /var/log/boot.log but then realised, I already aliased
+#invoke-rc.d to /bin/true in the chroot so this is redundant.
+
+# Oh, and don't fail the install if the server won't start.  It could be that the pg-database
+# package is partially installed.  Maybe I should detect this explicitly -TODO.
+invoke-rc.d galaxy start || true
+
+true
diff --git a/debian/galaxy-server.postrm b/debian/galaxy-server.postrm
new file mode 100644
index 0000000..caa317d
--- /dev/null
+++ b/debian/galaxy-server.postrm
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -e
+
+# Kill off the special user that was created in postinst, 
+# and scrub the databases and configs.
+if [ "$1" = purge ] ; then
+
+	# killall generates a Lintian warning but killall -u is fine
+	# Debian-galaxy should be the only member of Debian-galaxy
+	ka=/usr/bin/killall
+	$ka -u Debian-galaxy || true
+	! id -u Debian-galaxy || userdel Debian-galaxy
+	! getent group Debian-galaxy || groupdel Debian-galaxy
+	rm -rf /var/lib/galaxy-server
+	rm -rf /etc/galaxy-server
+fi
+
+#DEBHELPER#
+
+true
diff --git a/debian/galaxy-server.preinst b/debian/galaxy-server.preinst
new file mode 100644
index 0000000..b331690
--- /dev/null
+++ b/debian/galaxy-server.preinst
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+set -u
+
+#DEBHELPER#
+
+# If /usr/lib/galaxy-server/tool-data is a directory and /var/lib/galaxy-server/tool-data
+# does not exist, move the thing and symlink it.
+# This reflects a layout change introduced in 20140730-0biolinux1
+
+# Ownership also needs to be changed, but this is done by postinst
+
+if [ -d /usr/lib/galaxy-server/tool-data -a ! -L /usr/lib/galaxy-server/tool-data \
+     -a -d /var/lib/galaxy-server -a ! -e /var/lib/galaxy-server/tool-data ] ; then
+    echo "Shifting tool-data into /var/lib/galaxy-server"
+    mv /usr/lib/galaxy-server/tool-data /var/lib/galaxy-server
+    ln -s /var/lib/galaxy-server/tool-data /usr/lib/galaxy-server/
+fi
diff --git a/debian/galaxy-server.prerm b/debian/galaxy-server.prerm
new file mode 100644
index 0000000..172a500
--- /dev/null
+++ b/debian/galaxy-server.prerm
@@ -0,0 +1,13 @@
+#!/bin/bash
+# I need to do this to keep Lintian happy, but I certainly don't want to abort just
+#because the server won't stop.
+set -e
+
+# Stop it.
+invoke-rc.d galaxy stop || true
+
+#DEBHELPER#
+
+# TODO - this doesn't seem to clean out all .pyc files.  Need to do that manually?
+
+true
diff --git a/debian/galaxy.conf b/debian/galaxy.conf
new file mode 100644
index 0000000..393b40c
--- /dev/null
+++ b/debian/galaxy.conf
@@ -0,0 +1,28 @@
+# galaxy script
+# this script will start/stop galaxy server
+
+# By default the server will start on boot.  Comment
+# out the next line below to prevent this
+
+start on filesystem and net-device-up IFACE=lo
+stop on runlevel [!2345]
+
+description "Galaxy Server"
+version "1.1"
+author "Tim Booth, H. Soon Gweon"
+
+pre-start script
+    #Ensure log files are available for Galaxy, and directory
+    #is readable/writeable to adm user.
+    mkdir -p /var/log/galaxy
+    ( cd /var/log/galaxy ; umask 0027 ; touch galaxy-server.log galaxy-server.out )
+    chmod 1775 /var/log/galaxy
+    chown Debian-galaxy:adm /var/log/galaxy/*
+    # sort out transfer directories - has to be done as root
+    /usr/lib/galaxy-server/make_transfer_dirs.sh
+end script
+
+# start galaxy and send standard output and error to /var/log/galaxy.out
+exec sudo -u Debian-galaxy -H \
+    /usr/lib/galaxy-server/run.sh --log-file /var/log/galaxy/galaxy-server.log \
+    >/var/log/galaxy/galaxy-server.out 2>&1
diff --git a/debian/galaxy.desktop b/debian/galaxy.desktop
new file mode 100644
index 0000000..6f45832
--- /dev/null
+++ b/debian/galaxy.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=/usr/share/galaxy-server/static/galaxy_icon.png
+Exec=/usr/lib/galaxy-server/goto_galaxy.sh
+Name=Galaxy
+GenericName=Galaxy
+Comment=Open the Galaxy Server interface in a browser
+Type=Application
+Categories=Biology;Science;Education;Bioinformatics;
diff --git a/debian/galaxy_icon.png b/debian/galaxy_icon.png
new file mode 100644
index 0000000..f4bacd5
Binary files /dev/null and b/debian/galaxy_icon.png differ
diff --git a/debian/get-orig-source.sh b/debian/get-orig-source.sh
new file mode 100755
index 0000000..9e1599b
--- /dev/null
+++ b/debian/get-orig-source.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+set -u
+
+# Galaxy is a pain as:
+#  1 - it has no proper version numbers
+#  2 - it needs to download various Python eggs on first run, and at the
+#      moment various bugs appear if you try to use the system versions of libs
+
+# Ensure we have the commands we need
+for cmd in xmlstarlet wget ; do
+  if ! which "$cmd" > /dev/null ; then
+	echo "The $cmd command is not found."
+	exit 1
+  fi
+done
+
+# First off, make a tarballs directory...
+[ -d ../debian ] && cd ..
+[ -d debian ] && cd ..
+[ ! -d tarballs ] && mkdir tarballs
+pushd tarballs
+
+LATEST_TARBALL=`ls galaxy-tip_*.tar.bz2 2>/dev/null | egrep -o '[0-9]{8}' | sort -n | head -n 1`
+
+# This gets a revision number out of the local repo but apparently these
+# are not stable across branches.
+#GALAXY_VERSION=1.`hg heads -a -r tip | grep changeset | tr -d ' ' | cut -d: -f2`
+
+# This one gets a version from the RSS feed directly, based on the date:
+REMOTE_VERSION="`wget -q -O- https://bitbucket.org/galaxy/galaxy-dist/rss | xmlstarlet sel -t -m //pubDate -v . -n - | head -n1`"
+REMOTE_VERSION=`date '+%Y%m%d' -d"$REMOTE_VERSION"`
+echo "REMOTE_VERSION=$REMOTE_VERSION"
+
+# Find out the current local python version
+PY="py"`python --version |& grep -o '[0-9.]*' | cut -c1,3`
+REPACK_VERSION="$PY.$REMOTE_VERSION"
+
+# Clean up any old working directory
+rm -rvf galaxy-dist galaxy-galaxy-dist* tip.tar.bz2*
+
+if [ "$LATEST_TARBALL" = "$REMOTE_VERSION" ] ; then
+	if [ -e "galaxy-repack_$REPACK_VERSION.tar.xz" ] ; then
+		echo "Latest upstream $LATEST_TARBALL is up-to-date."
+		exit 0
+	else
+		echo "Download version $LATEST_TARBALL is up-to-date but seems to need repacking."
+	fi
+else
+	wget https://bitbucket.org/galaxy/galaxy-dist/get/tip.tar.bz2
+	mv tip.tar.bz2 "galaxy-tip_$REMOTE_VERSION.tar.bz2"
+fi
+
+GALAXY_VERSION="1.bl.$REPACK_VERSION"
+
+# Now we have to repack the tarball with all eggs.
+echo "Unpacking galaxy-tip_$REMOTE_VERSION.tar.bz2"
+tar -xvjf "galaxy-tip_$REMOTE_VERSION.tar.bz2"
+
+# Work on the tarball...
+# Sort out the directory name
+mv -v galaxy-galaxy-dist-* galaxy-dist
+# Download all the eggs, but not psychopg2
+# Purge any .pyc files
+pushd galaxy-dist
+    python ./scripts/fetch_eggs.py -c universe_wsgi.ini.sample
+    #python ./scripts/fetch_eggs.py -c universe_wsgi.ini.sample -e psycopg2
+    python ./scripts/fetch_eggs.py -c universe_wsgi.ini.sample -e sqlalchemy-migrate	
+    find -name '*.pyc' -delete
+popd
+
+echo "Repacking galaxy-repack_$REPACK_VERSION.tar.xz"
+tar -cvJf "galaxy-repack_$REPACK_VERSION.tar.xz" galaxy-dist
+rm -rf galaxy-dist
+
+popd
+ln -sf tarballs/"galaxy-repack_$REPACK_VERSION.tar.xz" "galaxy_$GALAXY_VERSION.orig.tar.xz"
+echo "Done - downloaded and linked galaxy_$GALAXY_VERSION.orig.tar.xz"
diff --git a/debian/goto_galaxy.sh b/debian/goto_galaxy.sh
new file mode 100755
index 0000000..2994e8d
--- /dev/null
+++ b/debian/goto_galaxy.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# This script will pop the local Galaxy instance up in their web browser.
+# Infer the port by inspecting the conf file, but failing that assume 8080
+GPORT=8080
+GPATH=
+GPROT=http
+
+if [ -r /etc/apache2/conf.d/galaxy ] ; then
+    #Galaxy is proxied via Apache, we assume.  Port is probably 80, and if
+    #not the user will need to override GALAXY_PORT and maybe GALAXY_PROTO.
+    GPORT=80
+    GPATH=`awk '$1 == "Alias" && $3 == "/usr/share/galaxy-server" {print $2}' /etc/apache2/conf.d/galaxy`
+else
+    # The .ini file can have many sections.  The logic here is to ensure we get the port= line from
+    # within the [server:main] section.
+    # If the file is split, combine it and search that.
+    UWSGI=/usr/lib/galaxy-server/universe_wsgi.ini
+    if [ -r "$UWSGI" ] ; then
+	UWSGI="cat '$UWSGI'"
+    else
+	UWSGI="( cd `dirname $UWSGI` ; python ./scripts/build_universe_config.py universe_wsgi.d/ /dev/stdout )"
+    fi
+
+    portline=`eval "$UWSGI" | grep -E '^\[|^port[[:space:]]*=[[:space:]]*[[:digit:]]+' \
+              | grep -E -A 1 '^\[server:main\]' \
+	      | grep -E '^port'`
+
+    if [ -n "$portline" ] ; then
+	GPORT=`echo "$portline" | grep -Eo '[[:digit:]]+'`
+    fi
+fi
+
+# Now allow the port and extension to be overridden, just in case
+GPORT=${GALAXY_PORT:-$GPORT}
+GPATH=${GALAXY_PATH:-$GPATH}
+GPROT=${GALAXY_PROTO:-$GPROT}
+
+# Now see if the server looks to be running.  We can do this just by using netcat.
+if  [ "$GPROT" != "http" ] || \
+    echo "HEAD $GPATH/xxx HTTP/1.1\nHost: localhost\nUser-Agent: telnet\n" \
+    | nc -q3 localhost "$GPORT" | grep -qi galaxy
+then
+   #Open the thing in the favoured browser 
+    exec gnome-open "$GPROT://localhost:$GPORT$GPATH"
+else
+    xargs -0i <<END zenity --error --no-wrap --title="Galaxy Not Running" --text="{}"
+The Galaxy server doesn't seem to be running on your machine.  
+You may need to start it with the command:
+
+  sudo start galaxy
+
+Or else Galaxy may still be starting up (it takes a couple 
+of minutes to get going on the first run).
+END
+fi
diff --git a/debian/make_transfer_dirs.sh b/debian/make_transfer_dirs.sh
new file mode 100755
index 0000000..c9710ee
--- /dev/null
+++ b/debian/make_transfer_dirs.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+if [ "`id -u`" != 0 ] ; then
+    echo "This script needs to be run as root, since it needs to set file ownerships."
+    exit 1
+fi
+
+#If users are added to the "galaxy" group, give them a place to upload files
+#directly to the server.  There is a "members" command to find group members
+#but I'd need to add it as a package dep and it seems a bit pointless.  So...
+members(){
+    g_line=`getent group "$1"`
+    [ -n "$g_line" ] || { echo "No such group $1." >&2 ; return 1 ; }
+    getent passwd | awk -F: '$4 == "'`echo "$g_line" | cut -d: -f3`'" { printf("%s ",$1) }'
+    echo "$g_line" | cut -d: -f4 | tr , ' '
+}
+
+#Note that "galaxy" is the group that identifies Galaxy users, but "Debian-galaxy"
+#is the system group used to permit the Galaxy server process to get at the
+#transferred files in directories owned by the user.  Got it?
+
+#If there is no galaxy group this won't do anything other than print a warning.
+#If -apache-proxy is installed but no users then we need to make the transfer dir anyway,
+#otherwise Galaxy gets upset that the folder is missing.
+grep -q 'ftp_upload_dir[[:space:]]*=[[:space:]]*/var/lib/galaxy-server/transfer' \
+    /etc/galaxy-server/universe_wsgi.d/* && install -d /var/lib/galaxy-server/transfer
+for m in `members galaxy` ; do
+    folder=/var/lib/galaxy-server/transfer/$m at localhost
+    # Force permissions, because this was getting screwed up in too many cases.
+    if [ -e "$folder" ] ; then
+	chown "$m:Debian-galaxy" "$folder" && chmod 770 "$folder"
+	continue
+    fi
+    install -o $m -g Debian-galaxy -m 770 -d "$folder"
+done
diff --git a/debian/patches/add_favicon_to_masthead b/debian/patches/add_favicon_to_masthead
new file mode 100644
index 0000000..5fe72ac
--- /dev/null
+++ b/debian/patches/add_favicon_to_masthead
@@ -0,0 +1,20 @@
+--- a/templates/base/base_panels.mako
++++ b/templates/base/base_panels.mako
+@@ -299,6 +299,7 @@
+         %else:
+             <title>${self.title()}</title>
+         %endif
++	<link rel="shortcut icon" href="/galaxy/favicon.ico" type="image/x-icon" />
+         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+         ## For mobile browsers, don't scale up
+         <meta name = "viewport" content = "maximum-scale=1.0">
+--- a/templates/webapps/galaxy/galaxy.panels.mako
++++ b/templates/webapps/galaxy/galaxy.panels.mako
+@@ -161,6 +161,7 @@
+ <html>
+     <head>
+         <title></title>
++        <link rel="shortcut icon" href="/galaxy/favicon.ico" type="image/x-icon" />
+         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+         
+         ## for mobile browsers, don't scale up
diff --git a/debian/patches/commit_1298d3f b/debian/patches/commit_1298d3f
new file mode 100644
index 0000000..c7a663a
--- /dev/null
+++ b/debian/patches/commit_1298d3f
@@ -0,0 +1,68 @@
+# https://bitbucket.org/galaxy/galaxy-central/commits/1298d3f
+# HG changeset patch
+# User Nate Coraor <nate at bx.psu.edu>
+# Date 1392832833 21600
+# Branch stable
+# Node ID 1298d3f6aca59825d0eb3d32afd5686c4b1b9294
+# Parent  44968207ddd283d0023c72e3d25fd39b1c71eb99
+Stop jobs when all output datasets are deleted via the API.
+
+--- a/lib/galaxy/web/base/controller.py
++++ b/lib/galaxy/web/base/controller.py
+@@ -892,6 +892,18 @@
+             break
+         return job
+ 
++    def stop_hda_creating_job( self, hda ):
++        """
++        Stops an HDA's creating job if all the job's other outputs are deleted.
++        """
++        if hda.parent_id is None and len( hda.creating_job_associations ) > 0:
++            # Mark associated job for deletion
++            job = hda.creating_job_associations[0].job
++            if job.state in [ self.app.model.Job.states.QUEUED, self.app.model.Job.states.RUNNING, self.app.model.Job.states.NEW ]:
++                # Are *all* of the job's other output datasets deleted?
++                if job.check_if_output_datasets_deleted():
++                    job.mark_deleted( self.app.config.track_jobs_in_database )
++                    self.app.job_manager.job_stop_queue.put( job.id )
+ 
+ 
+ class UsesLibraryMixin:
+--- a/lib/galaxy/webapps/galaxy/api/history_contents.py
++++ b/lib/galaxy/webapps/galaxy/api/history_contents.py
+@@ -278,6 +278,8 @@
+             # get_dataset can return a string during an error
+             if hda and isinstance( hda, trans.model.HistoryDatasetAssociation ):
+                 changed = self.set_hda_from_dict( trans, hda, payload )
++                if payload.get( 'deleted', False ):
++                    self.stop_hda_creating_job( hda )
+         except Exception, exception:
+             log.error( 'Update of history (%s), HDA (%s) failed: %s',
+                         history_id, id, str( exception ), exc_info=True )
+@@ -347,6 +349,8 @@
+                     trans.sa_session.flush()
+                 rval[ 'purged' ] = True
+ 
++            self.stop_hda_creating_job( hda )
++
+             trans.sa_session.flush()
+             rval[ 'deleted' ] = True
+ 
+--- a/lib/galaxy/webapps/galaxy/controllers/dataset.py
++++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py
+@@ -839,14 +839,7 @@
+             hda.mark_deleted()
+             hda.clear_associated_files()
+             trans.log_event( "Dataset id %s marked as deleted" % str(id) )
+-            if hda.parent_id is None and len( hda.creating_job_associations ) > 0:
+-                # Mark associated job for deletion
+-                job = hda.creating_job_associations[0].job
+-                if job.state in [ self.app.model.Job.states.QUEUED, self.app.model.Job.states.RUNNING, self.app.model.Job.states.NEW ]:
+-                    # Are *all* of the job's other output datasets deleted?
+-                    if job.check_if_output_datasets_deleted():
+-                        job.mark_deleted( self.app.config.track_jobs_in_database )
+-                        self.app.job_manager.job_stop_queue.put( job.id )
++            self.stop_hda_creating_job( hda )
+             trans.sa_session.flush()
+         except Exception, e:
+             msg = 'HDA deletion failed (encoded: %s, decoded: %s)' % ( dataset_id, id )
diff --git a/debian/patches/drop_tmp_table_before_upgrade b/debian/patches/drop_tmp_table_before_upgrade
new file mode 100644
index 0000000..2b2abbb
--- /dev/null
+++ b/debian/patches/drop_tmp_table_before_upgrade
@@ -0,0 +1,25 @@
+--- a/eggs/sqlalchemy_migrate-0.7.2-py2.7.egg/migrate/changeset/databases/sqlite.py
++++ b/eggs/sqlalchemy_migrate-0.7.2-py2.7.egg/migrate/changeset/databases/sqlite.py
+@@ -7,6 +7,7 @@
+ from copy import copy
+ 
+ from sqlalchemy.databases import sqlite as sa_base
++from sqlalchemy.exc import OperationalError
+ 
+ from migrate import exceptions
+ from migrate.changeset import ansisql
+@@ -32,6 +33,14 @@
+         for index in table.indexes:
+             index.drop()
+ 
++	# Drop table first as it might already exist.  The lack of error
++        # handling in this module is shocking.
++        try:
++            self.append('DROP TABLE migration_tmp')
++            self.execute()
++	except OperationalError:
++            pass
++
+         self.append('ALTER TABLE %s RENAME TO migration_tmp' % table_name)
+         self.execute()
+ 
diff --git a/debian/patches/fix_build_universe_config b/debian/patches/fix_build_universe_config
new file mode 100644
index 0000000..37edf73
--- /dev/null
+++ b/debian/patches/fix_build_universe_config
@@ -0,0 +1,11 @@
+--- a/scripts/build_universe_config.py
++++ b/scripts/build_universe_config.py
+@@ -11,7 +11,7 @@
+         message = "%s: Must specify directory to merge configuration files from." % argv[0]
+         raise Exception(message)
+     conf_directory = argv[1]
+-    conf_files = [f for f in listdir(conf_directory) if match(r'.*\.ini', f)]
++    conf_files = [f for f in listdir(conf_directory) if match(r'.*\.ini$', f)]
+     conf_files.sort()
+ 
+     parser = ConfigParser()
diff --git a/debian/patches/fix_unit_test b/debian/patches/fix_unit_test
new file mode 100644
index 0000000..62b99c9
--- /dev/null
+++ b/debian/patches/fix_unit_test
@@ -0,0 +1,25 @@
+--- a/run_unit_tests.sh
++++ b/run_unit_tests.sh
+@@ -2,6 +2,11 @@
+ 
+ ## Excluding controllers due to the problematic genetrack dependency
+ ## Excluding job runners due to various external dependencies
++if [ ! -w /var/log/galaxy ] ; then
++  echo "You need write permissions to /var/log/galaxy, which is owned by group" \
++         `stat -c %G /var/log/galaxy`.
++  exit 1
++fi
+ 
+ COVERAGE=`which coverage`
+ COVERAGE_ARG=""
+@@ -11,6 +16,9 @@
+ 
+ python ./scripts/nosetests.py -v \
+     $COVERAGE_ARG \
+-    --with-nosehtml --html-report-file run_unit_tests.html \
++    --with-nosehtml --html-report-file /var/log/galaxy/run_unit_tests.html \
+     --with-doctest --exclude=functional --exclude="^get" \
+     --exclude=controllers --exclude=runners lib test/unit
++
++# Clean up a random temporary file
++rm "`readlink -f lib/galaxy/datatypes/test/temp.txt`"
diff --git a/debian/patches/fix_workflow_misconfiguration_report b/debian/patches/fix_workflow_misconfiguration_report
new file mode 100644
index 0000000..5a15bff
--- /dev/null
+++ b/debian/patches/fix_workflow_misconfiguration_report
@@ -0,0 +1,16 @@
+# This patch addresses http://lists.bx.psu.edu/pipermail/galaxy-dev/2012-June/010303.html
+--- a/templates/webapps/galaxy/workflow/run.mako
++++ b/templates/webapps/galaxy/workflow/run.mako
+@@ -582,9 +582,12 @@
+               # Filter possible inputs to data types that are valid for subsequent steps
+               type_filter = []
+               for oc in step.output_connections:
++                try:
+                   for ic in oc.input_step.module.get_data_inputs():
+                       if 'extensions' in ic and ic['name'] == oc.input_name:
+                           type_filter += ic['extensions']
++                except AttributeError:
++                      pass
+               if not type_filter:
+                   type_filter = ['data']
+               %>
diff --git a/debian/patches/force_use_of_bash_interpreter b/debian/patches/force_use_of_bash_interpreter
new file mode 100644
index 0000000..a1225e0
--- /dev/null
+++ b/debian/patches/force_use_of_bash_interpreter
@@ -0,0 +1,32 @@
+--- a/buildbot_setup.sh
++++ b/buildbot_setup.sh
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/bin/bash
+ 
+ cd `dirname $0`
+ 
+--- a/install_and_test_tool_shed_repositories.sh
++++ b/install_and_test_tool_shed_repositories.sh
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/bin/bash
+ 
+ # A good place to look for nose info: http://somethingaboutorange.com/mrl/projects/nose/
+ 
+--- a/run_functional_tests.sh
++++ b/run_functional_tests.sh
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/bin/bash
+ 
+ # A good place to look for nose info: http://somethingaboutorange.com/mrl/projects/nose/
+ rm -f run_functional_tests.log 
+--- a/tools/solid_tools/qualsolid_boxplot_graph.sh
++++ b/tools/solid_tools/qualsolid_boxplot_graph.sh
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/bin/bash
+ 
+ #    Modified fastq_quality_boxplot_graph.sh from FASTX-toolkit - FASTA/FASTQ preprocessing tools.
+ #    Copyright (C) 2009  A. Gordon (gordon at cshl.edu)
diff --git a/debian/patches/keep_shed_tools_in_this_directory b/debian/patches/keep_shed_tools_in_this_directory
new file mode 100644
index 0000000..09ff3b5
--- /dev/null
+++ b/debian/patches/keep_shed_tools_in_this_directory
@@ -0,0 +1,16 @@
+--- a/migrated_tools_conf.xml.sample
++++ b/migrated_tools_conf.xml.sample
+@@ -1,3 +1,3 @@
+ <?xml version="1.0"?>
+-<toolbox tool_path="../shed_tools">
+-</toolbox>
+\ No newline at end of file
++<toolbox tool_path="shed_tools">
++</toolbox>
+--- a/shed_tool_conf.xml.sample
++++ b/shed_tool_conf.xml.sample
+@@ -1,3 +1,3 @@
+ <?xml version="1.0"?>
+-<toolbox tool_path="../shed_tools">
++<toolbox tool_path="shed_tools">
+ </toolbox>
diff --git a/debian/patches/relax_password_length_restriction b/debian/patches/relax_password_length_restriction
new file mode 100644
index 0000000..614ab3b
--- /dev/null
+++ b/debian/patches/relax_password_length_restriction
@@ -0,0 +1,55 @@
+# The Galaxy server comes with hard-coded restrictions on user account names
+# and passwords that are sensible for a globally available public server but
+# annoying for small-time users.  This patch relaxes restrictions on password
+# length, user name length and validation of e-mail addresses.
+--- a/lib/galaxy/security/validate_user_input.py
++++ b/lib/galaxy/security/validate_user_input.py
+@@ -3,7 +3,8 @@
+ VALID_PUBLICNAME_RE = re.compile( "^[a-z0-9\-]+$" )
+ VALID_PUBLICNAME_SUB = re.compile( "[^a-z0-9\-]" )
+ #  Basic regular expression to check email validity.
+-VALID_EMAIL_RE = re.compile( "[^@]+@[^@]+\.[^@]+" )
++#  Restriction relaxed by Bio-Linux patch
++VALID_EMAIL_RE = re.compile( "[^@]+@[^@]+" )
+ FILL_CHAR = '-'
+ 
+ 
+@@ -32,12 +33,8 @@
+     # letters, numbers, and the '-' character.
+     if user and user.username == publicname:
+         return ''
+-    if trans.webapp.name == 'tool_shed':
+-        if len( publicname ) < 3:
+-            return "Public name must be at least 3 characters in length"
+-    else:
+-        if len( publicname ) < 4:
+-            return "Public name must be at least 4 characters in length"
++    if len( publicname ) < 2:
++	return "Public name must be at least 2 characters in length"
+     if len( publicname ) > 255:
+         return "Public name cannot be more than 255 characters in length"
+     if not( VALID_PUBLICNAME_RE.match( publicname ) ):
+@@ -63,8 +60,8 @@
+ 
+ 
+ def validate_password( trans, password, confirm ):
+-    if len( password ) < 6:
+-        return "Use a password of at least 6 characters"
++    if len( password ) < 3:
++        return "Use a password of at least 3 characters"
+     elif password != confirm:
+         return "Passwords do not match"
+     return ''
+--- a/lib/galaxy/web/base/controllers/admin.py
++++ b/lib/galaxy/web/base/controllers/admin.py
+@@ -722,8 +722,8 @@
+                 user = get_user( trans, user_id )
+                 password = kwd.get( 'password', None )
+                 confirm = kwd.get( 'confirm' , None )
+-                if len( password ) < 6:
+-                    message = "Use a password of at least 6 characters."
++                if len( password ) < 3:
++                    message = "Use a password of at least 3 characters."
+                     status = 'error'
+                     break
+                 elif password != confirm:
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..6531cff
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,11 @@
+keep_shed_tools_in_this_directory
+fix_unit_test
+relax_password_length_restriction
+tell_user_how_to_add_administrator
+use_system_python_libs
+force_use_of_bash_interpreter
+drop_tmp_table_before_upgrade
+shed_tools_data_path
+fix_build_universe_config
+add_favicon_to_masthead
+fix_workflow_misconfiguration_report
diff --git a/debian/patches/shed_tools_data_path b/debian/patches/shed_tools_data_path
new file mode 100644
index 0000000..3942066
--- /dev/null
+++ b/debian/patches/shed_tools_data_path
@@ -0,0 +1,11 @@
+--- a/lib/tool_shed/util/tool_util.py
++++ b/lib/tool_shed/util/tool_util.py
+@@ -212,7 +212,7 @@
+     is ~/tool-data.
+     """
+     if dest_path is None:
+-        dest_path = os.path.abspath( app.config.tool_data_path )
++        dest_path = os.path.abspath( app.config.shed_tool_data_path )
+     sample_file_name = suc.strip_path( filename )
+     copied_file = sample_file_name.replace( '.sample', '' )
+     full_source_path = os.path.abspath( filename )
diff --git a/debian/patches/tell_user_how_to_add_administrator b/debian/patches/tell_user_how_to_add_administrator
new file mode 100644
index 0000000..b947fc4
--- /dev/null
+++ b/debian/patches/tell_user_how_to_add_administrator
@@ -0,0 +1,12 @@
+--- a/lib/galaxy/webapps/galaxy/controllers/user.py
++++ b/lib/galaxy/webapps/galaxy/controllers/user.py
+@@ -782,6 +782,9 @@
+                     success = False
+             else:  # User activation is OFF, proceed without sending the activation email.
+                 message = 'Now logged in as %s.<br><a target="_top" href="%s">Return to the home page.</a>' % ( user.email, url_for( '/' ) )
++
++		message += '''<br><br><i>If you want this user to be an administrator in Galaxy, you need to run the command </i>
++		           <b>sudo galaxy-add-administrator "%s"</b><i> on the server.</i>''' % (user.email)
+                 success = True
+         return ( message, status, user, success )
+ 
diff --git a/debian/patches/use_system_python_libs b/debian/patches/use_system_python_libs
new file mode 100644
index 0000000..cf2fcf0
--- /dev/null
+++ b/debian/patches/use_system_python_libs
@@ -0,0 +1,71 @@
+--- a/eggs.ini
++++ b/eggs.ini
+@@ -11,6 +11,11 @@
+ ; these eggs must be scrambled for your local environment
+ no_auto = pbs_python
+ 
++; A version of "LOCAL" means use whatever is on the system.
++; It is assumed that these are tracked by an external package manager (eg. Dpkg)
++; or that you know what you are doing and are prepared to FACE THE CONSEQUENCES.
++; Local psycopg2 is needed, I think, or else connection fails.
++
+ [eggs:platform]
+ bx_python = 0.7.2
+ Cheetah = 2.2.2
+@@ -20,8 +25,8 @@
+ PyRods = 3.2.4
+ numpy = 1.6.0
+ pbs_python = 4.3.5
+-psycopg2 = 2.5.1
+-pycrypto = 2.5
++psycopg2 = LOCAL  ; was 2.5.1
++pycrypto = LOCAL  ; was 2.5
+ pysam = 0.4.2
+ pysqlite = 2.5.6
+ python_lzo = 1.08_2.03_static
+--- a/lib/galaxy/eggs/__init__.py
++++ b/lib/galaxy/eggs/__init__.py
+@@ -32,6 +32,16 @@
+     def http_error_default( *args ):
+         urllib.URLopener.http_error_default( *args )
+ 
++# Added by Tim as a way to use local objects
++class LocalEgg( object ):
++    def __init__( self, name=None ):
++	self.name = name
++	self.distribution = pkg_resources.Distribution('LOCAL',None,None,'0');
++    def require( self ):
++	return True
++    def fetch( self, installer=None ):
++	return self.distribution
++
+ class Egg( object ):
+     """
+     Contains information about locating and downloading eggs.
+@@ -266,14 +276,18 @@
+         self.parse_egg_section( self.config.items( 'eggs:noplatform' ), self.config.items( 'tags' ) )
+     def parse_egg_section( self, eggs, tags, full_platform=False, egg_class=Egg ):
+         for name, version in eggs:
+-            tag = dict( tags ).get( name, '' )
+-            url = '/'.join( ( self.repo, name ) )
+-            if full_platform:
+-                platform = self.platform or '-'.join( ( py, pkg_resources.get_platform() ) )
+-            else:
+-                platform = self.py_platform or py
+-            egg = egg_class( name=name, version=version, tag=tag, url=url, platform=platform, crate=self )
+-            self.eggs[name] = egg
++	    if version == 'LOCAL' :
++		#Added by Tim as a way to force using local modules.
++		self.eggs[name] = LocalEgg( name=name )
++	    else :
++		tag = dict( tags ).get( name, '' )
++		url = '/'.join( ( self.repo, name ) )
++		if full_platform:
++		    platform = self.platform or '-'.join( ( py, pkg_resources.get_platform() ) )
++		else:
++		    platform = self.py_platform or py
++		egg = egg_class( name=name, version=version, tag=tag, url=url, platform=platform, crate=self )
++		self.eggs[name] = egg
+     @property
+     def config_missing( self ):
+         """
diff --git a/debian/remove_obsolete_eggs.sh b/debian/remove_obsolete_eggs.sh
new file mode 100755
index 0000000..4a34d6a
--- /dev/null
+++ b/debian/remove_obsolete_eggs.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Scrub out the Python modules that I no longer have to leave in the package thanks
+# to the use_system_python_libs patch.
+cd eggs
+
+rm -rf pycrypto-*.egg
+rm -rf pysqlite-*.egg
+rm -rf simplejson-*.egg
+# rm -rf SQLAlchemy-*.egg
+# rm -rf sqlalchemy_migrate-*.egg
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..2379784
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,95 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+#  A big messy build for a big messy system.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# No, Python, you can't squirrel files away in the home dir!
+export PYTHON_EGG_CACHE=$(CURDIR)/eggs
+
+# And no you can't connect to the net and fetch random files!
+export http_proxy=http://0.0.0.0:0
+export ftp_proxy=http://0.0.0.0:0
+
+%:
+	dh $@ --with python2
+
+override_dh_builddeb:
+	dh_builddeb -- -Z xz
+
+override_dh_auto_clean:
+	#Man there is a lot of crud in here...
+	dh_auto_clean
+	find . -name "*.pyc" -exec rm '{}' ';'
+	# Maybe have to remove .so? - no just a few that got unpacked
+	rm -rf eggs/*.egg-tmp
+	find . \( -name "._*" -or -name '.DS_Store' -or -name '.gitignore' \) -exec rm '{}' ';'
+	rm -f database/universe.sqlite
+	rm -f integrated_tool_panel.xml database/integrated_tool_panel.xml
+	rm -f logging
+	rm -f hacky_first_run.log
+	rm -rf database/tmp
+	rm -f lib/galaxy/datatypes/test/temp.txt
+	#./debian/remove_obsolete_eggs.sh
+	rm -rf static/scripts/packed
+
+override_dh_auto_build:
+	chmod a-x tool-data/*.loc.sample
+	#Note pack_scripts.py needs Java, but doesn't throw an error if java is missing
+	which java
+	cd static/scripts && ./pack_scripts.py
+
+# Custom manual install to debian/tmp.  Sorry - long winded.
+override_dh_auto_install:
+	#Split into usr, var and etc
+	mkdir -p debian/tmp/usr/lib/galaxy-server
+	mkdir -p debian/tmp/usr/share/galaxy-server
+	mkdir -p debian/tmp/etc/galaxy-server
+	mkdir -p debian/tmp/var/lib/galaxy-server/egg-cache
+	mkdir -p debian/tmp/var/lib/galaxy-server/shed_tools
+	mkdir -p debian/tmp/var/lib/galaxy-server/genetrack_plots
+	cp -r * debian/tmp/usr/lib/galaxy-server || true
+	( cd ./debian/tmp ; ../copy_sample_config.sh ) 
+	for x in tool-data database ; do \
+	    mv debian/tmp/usr/lib/galaxy-server/$$x debian/tmp/var/lib/galaxy-server ; \
+	done
+	for x in static templates test test-data ; do \
+	    mv debian/tmp/usr/lib/galaxy-server/$$x debian/tmp/usr/share/galaxy-server ; \
+	done
+	mv debian/tmp/usr/lib/galaxy-server/eggs/*.egg-tmp debian/tmp/var/lib/galaxy-server/egg-cache || true
+	find debian/tmp/usr/share -type f -exec chmod a-x '{}' ';'
+	chmod a+x debian/tmp/usr/lib/galaxy-server/*.sh
+	cp debian/galaxy_icon.png debian/tmp/usr/share/galaxy-server/static
+	#Things that I previously did by running the server once as root
+	mkdir -p debian/tmp/usr/lib/galaxy-server/tool-data/shared/jars
+	#And some permissions fixes
+	find -type f -name '*.xml' -exec chmod a-x '{}' ';'
+	( cd debian/tmp/usr/share/galaxy-server/static && \
+	  rm june_2007_style && mkdir june_2007_style && mv style/blue june_2007_style && \
+	  rm -r style )
+	#Execute permissions are set apparently randomly.  So, erm, maybe this...
+	find debian/tmp/usr \( -name '*.py' -or -name '*.pl' -or -name '*.sh' \) -exec \
+	  sh -c 'if [ "`head -c 2 "{}"`" = "#!" ] ; then chmod a+x "{}" ; else chmod a-x "{}" ; fi' \;
+	#And interpreters are a bit random too, so:
+	find debian/tmp/usr -name '*.py' -exec sed -i -e '1s/#! \?.*python[0-9.]*/#!\/usr\/bin\/python/' '{}' \;
+
+override_dh_install:
+	dh_install -X.svn
+	#Make a load of symlinks to allow Galaxy to write to various directories, but only in /var/lib/galaxy-server
+	dh_link -pgalaxy-server /var/lib/galaxy-server/tool-data /usr/lib/galaxy-server/tool-data
+	dh_link -pgalaxy-server /var/lib/galaxy-server/database /usr/lib/galaxy-server/database
+	dh_link -pgalaxy-server /var/lib/galaxy-server/shed_tools /usr/lib/galaxy-server/shed_tools
+	dh_link -pgalaxy-server /usr/share/galaxy-server/static /usr/lib/galaxy-server/static
+	dh_link -pgalaxy-server /usr/share/galaxy-server/templates /usr/lib/galaxy-server/templates
+	dh_link -pgalaxy-server /var/lib/galaxy-server/genetrack_plots /usr/share/galaxy-server/static/genetrack/plots
+	dh_link -pgalaxy-server-test /usr/share/galaxy-server/test /usr/lib/galaxy-server/test
+	dh_link -pgalaxy-server-test /usr/share/galaxy-server/test-data /usr/lib/galaxy-server/test-data
+	#Server expects to write to these files, the dangling symlink is intentional
+	dh_link -pgalaxy-server /var/lib/galaxy-server/database/integrated_tool_panel.xml /usr/lib/galaxy-server/integrated_tool_panel.xml
+	dh_link -pgalaxy-server-test /var/lib/galaxy-server/test/temp.txt /usr/lib/galaxy-server/lib/galaxy/datatypes/test/temp.txt
+	chmod g+w debian/galaxy-server-test/var/lib/galaxy-server/test || true
+	#Startup files and links
+	dh_install -pgalaxy-server debian/galaxy.conf /etc/init
+	dh_link -pgalaxy-server /lib/init/upstart-job /etc/init.d/galaxy
+	dh_install -pgalaxy-server debian/galaxy.desktop /usr/share/applications
diff --git a/debian/run.sh b/debian/run.sh
new file mode 100755
index 0000000..3ed4dc3
--- /dev/null
+++ b/debian/run.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd `dirname $0`
+
+python ./scripts/check_python.py
+
+#For Deb package we don't need most of the regular startup script
+#Galaxy does expect somewhere to unpack 'eggs'
+export PYTHON_EGG_CACHE=/var/lib/galaxy-server/egg-cache
+
+# Needed to make gops_join work...
+export PYTHONPATH=`echo /usr/lib/galaxy-server/eggs/bx_python-*.egg | tr ' ' ':'`
+
+#This script would normally be called by upstart from /etc/init/galaxy.conf
+#You can run it manually but be sure to run it as the right user.
+RIGHT_USER=`stat -c%U "$PYTHON_EGG_CACHE"`
+if ! [ `id -un` = $RIGHT_USER ] ; then
+    echo "You should start Galaxy as $RIGHT_USER."
+    echo "Try: sudo -u $RIGHT_USER $0"
+    exit 1
+fi
+
+# Initialise shed_tools files from .sample files.  Initial installation will
+# leave dangling symlinks to location under /var.
+# Note integrated_tool_panel.xml has no sample file.
+for sam in *.sample ; do
+    file="`basename "$sam" .sample`"
+
+    if [ -L "$file" -a \! -e "$file" ] ; then
+	echo "Initializing $file from $sam"
+	cat "$sam" > "$file"
+    fi
+done
+
+# Make universe_wsgi.ini on-the-fly unless it already exists.
+# Hint - you most probably don't ever want to make a monolithic UWINI
+# unless you are are doing it for testing purposes.
+UWINI=universe_wsgi.ini
+
+if [ ! -e "$UWINI" ] ; then
+    UWINI=`mktemp --tmpdir universe_wsgi_XXXX.ini`
+    python ./scripts/build_universe_config.py universe_wsgi.d/ "$UWINI"
+    chmod g+r "$UWINI"
+fi
+
+#For some reason I seem to be having issues initialising the database when it's
+#done by Galaxy, but I can't reproduce it when I do it manually.  So just update
+#the database here.
+echo "Ensuring the database is set up and the version is right."
+./manage_db.sh -c "$UWINI" version_control 2>/dev/null || true
+./manage_db.sh -c "$UWINI" upgrade
+
+exec python ./scripts/paster.py serve "$UWINI" "$@"
+
diff --git a/debian/sbin/galaxy-add-administrator b/debian/sbin/galaxy-add-administrator
new file mode 100755
index 0000000..b367182
--- /dev/null
+++ b/debian/sbin/galaxy-add-administrator
@@ -0,0 +1,190 @@
+#!/usr/bin/perl
+use strict; use warnings;
+
+# Script added for the Bio-Linux package by Tim Booth
+# This script may be freely redistributed under the same terms as galaxy itself.
+
+# This script used to edit /etc/galaxy-server/universe_wsgi.ini but now
+# it writes to /etc/galaxy-server/universe_wsgi.d/11_admin_users.ini
+
+#my $ini="/etc/galaxy-server/universe_wsgi.ini";
+my $ini="/etc/galaxy-server/universe_wsgi.d/11_admin_users.ini";
+my $create_ini = 1;
+
+#TODO - get this from config so user can change it and still add users by
+#       short name.
+my $maildomain="localhost";
+
+# A helper script to set Galaxy administrators
+my $mode = 'show';
+my $user_to_add = 'None';
+if($ARGV[0])
+{
+    if($ARGV[0] eq '--del')
+    {
+	    $mode = 'del';
+	    $user_to_add = $ARGV[1] or usage();
+    }
+    else
+    {
+	    $mode = 'add';
+	    $user_to_add = $ARGV[0];
+    }
+}
+
+if ( $mode ne 'show' )
+{
+    $user_to_add =~ /@/ or $user_to_add = "$user_to_add\@$maildomain";
+    $user_to_add =~ /. at ./ or usage();
+    $user_to_add =~ /[^\w.@~]/ and usage();
+}
+
+#Quick load from ini file
+my $fh; 
+my @ini_all;
+if(open $fh, "<$ini")
+{
+    $create_ini = 0;
+
+    # Slurp it!
+    @ini_all = <$fh>;
+}
+else
+{
+    $create_ini or die
+		"Can't open the file $ini for reading.\n";
+
+    @ini_all = new_ini();
+}
+undef $fh;
+
+my( @admusers, @admcomments );
+my $nn = 0;
+for( @ini_all )
+{
+    /^\s*admin_users\s*=/ && push(@admusers, $nn);
+    /^\s*#\s*admin_users\s*=/ && push(@admcomments, $nn);
+	$nn++;
+}
+
+my $line_to_process = undef;
+my $line_contents;
+
+# Now, being fairly paranoid, sort the config
+if( @admusers > 1 )
+{
+    die "You seem to have multiple 'admin_users' lines in the config file.\n" .
+	    "Unable to process it.  You should edit $ini manually.\n";
+}
+elsif( @admusers == 1 )
+{
+    $line_to_process = $admusers[0];
+    $line_contents = $ini_all[$line_to_process];
+}
+else
+{
+    if(!@admcomments)
+    {
+	die "Can't find the right location to insert an 'admin_users' line in the config file.\n" .
+	    "Unable to process it.  You should edit $ini manually.\n";
+    }
+    else
+    {
+	$line_to_process = $admcomments[0];
+	$line_contents = "admin_users=";
+    }
+}
+
+#Now process the line
+# extract current users
+my @curusers = split /,/, join("", $line_contents =~ /[^=]+=(.*)/);
+map { s/^\s+//, s/\s+$// } @curusers;
+ at curusers = grep { $_ and lc($_) ne 'none' } @curusers;
+
+if(@curusers)
+{
+    print "These " . @curusers ." users are currently administrators:\n";
+    print "$_\n" for @curusers;
+}
+elsif( $create_ini && $mode eq 'show' )
+{
+    print "The file $ini was not found.\n".
+	  "If you add an administrator with this script it will be created for you.\n";
+    usage();	
+}
+else
+{
+    print "There are currently no administrative users set up in Galaxy.\n";
+}
+
+# look for user required
+(my $match) = grep { $_ eq $user_to_add } @curusers;
+
+if($mode eq 'add')
+{
+    # add to list
+    $match && die "Error: $user_to_add is already listed as an admin user.\n";
+
+    push @curusers, $user_to_add;
+}
+elsif($mode eq 'del')
+{
+    $match || die "Error: $user_to_add is not listed as an admin user.\n";
+
+    @curusers = grep { $_ ne $user_to_add } @curusers;
+    @curusers or @curusers = ('None');
+}
+
+#And finally, save the result.
+if($mode ne 'show')
+{
+    $ini_all[$line_to_process] = "admin_users = " . join(',', @curusers) . "\n";
+
+    my $newfile = sprintf("%s.new.%x", $ini, time());
+
+    open $fh, ">$newfile" or die 
+	    "Unable to write changes to $newfile
+You should run this script with root privileges using \"sudo\".\n";
+    print $fh @ini_all;
+    undef $fh;
+
+    rename $newfile, $ini or die 
+	    "Unable to copy changes from $newfile to $ini
+You should run this script with root privileges using \"sudo\".\n";
+
+}
+
+if($mode eq 'add')
+{
+    print "\nUser $user_to_add was added. Restarting Galaxy - this will take about 30 seconds.\n";
+    system("initctl restart galaxy || initctl start galaxy");
+}
+elsif($mode eq 'del')
+{
+    print "\nUser $user_to_add removed. Restarting Galaxy - this will take about 30 seconds.\n";
+    system("initctl restart galaxy || initctl start galaxy");
+}
+
+sub new_ini
+{
+    map {/[\s]*(.*\n)/} split /(?<=\n)/,
+   "# Administrative users on the Galaxy server.  
+    # This file was created by the galaxy-add-administrator script.  You can use 
+	# that script to modify the list of admins or you can just edit this file 
+	# yourself, but don't forget you need to restart the server for the changes 
+	# to take effect.
+	
+	[app:main]
+    # admin_users=
+   ";
+}
+
+sub usage
+{
+	die
+"Usage: galaxy-add-administrator [ [--del] <username> ]
+
+Where <username> must be a valid e-mail address that has been
+set up as a user in Galaxy.
+";
+}
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/source/include-binaries b/debian/source/include-binaries
new file mode 100644
index 0000000..73e9976
--- /dev/null
+++ b/debian/source/include-binaries
@@ -0,0 +1 @@
+debian/galaxy_icon.png
diff --git a/debian/universe_wsgi.d/10_debian_defaults.ini b/debian/universe_wsgi.d/10_debian_defaults.ini
new file mode 100644
index 0000000..48d1d49
--- /dev/null
+++ b/debian/universe_wsgi.d/10_debian_defaults.ini
@@ -0,0 +1,54 @@
+# General configuration overrides for Galaxy in Debian/Bio-Linux.
+# Simon suggested some more appropriate default configurations for a standalone
+# server - see +bug/1064920
+
+# To set your own settings, you are urged not to edit this file but
+# to to put the settings into /etc/galaxy-server/universe_wsgi.d/50_local.ini
+# Settings found in any higher numbered file will override anything
+# in here. 
+
+[app:main]
+
+# This is necessary if you want to assemble the temporary config file outside the
+# base Galaxy directory, which I do.
+here = /usr/lib/galaxy-server
+
+# I want to make it easy for people to proxy Galaxy through Apache and
+# it doesn't seem to hurt to activate proxy-prefix by defualt, even though
+# the other config stuff is in the galaxy-server-apache-proxy package.
+# Enable the proxy-prefix filter
+filter-with = proxy-prefix
+ 
+# Also the cookie path.
+# Setting this seems to cause various problems - failed uploads, failed
+# logins.  So leave it as default for now.
+#cookie_path = galaxy
+ 
+# This should be fine on BL as Galaxy has an unprivileged account, and I'd assume
+# that anyone having Galaxy admin access also has some shell access.
+allow_library_path_paste = True
+ 
+# Allow administrators to delete accounts.
+allow_user_deletion = True
+ 
+# Allow administrators to log in as other users (useful for debugging)
+allow_user_impersonation = False
+
+# Allow users to remove their datasets from disk immediately (otherwise,
+# datasets will be removed after a time period specified by an administrator in
+# the cleanup scripts run via cron)
+allow_user_dataset_purge = True
+ 
+# By default, users' data will be public, but setting this to True will cause
+# it to be private.  Does not affect existing users and data, only ones created
+# after this option is set.  Users may still change their default back to
+# public.
+new_user_dataset_access_role_default_private = True
+
+# By default tool defs installed into the shed try to write to ./tool-data,
+# but that is read-only.
+shed_tools_data_path = shed_tools/data
+tool_dependency_dir = shed_tools/deps
+
+# And no debugging, ta.
+debug = False
diff --git a/debian/universe_wsgi.d/31_apache-proxy.ini b/debian/universe_wsgi.d/31_apache-proxy.ini
new file mode 100644
index 0000000..ddb86ca
--- /dev/null
+++ b/debian/universe_wsgi.d/31_apache-proxy.ini
@@ -0,0 +1,17 @@
+# Settings added by debian-galaxy-apache-proxy to switch Galaxy over to
+# authenticating by real user accounts and also permitting uploads.
+
+[app:main]
+
+# Other scripts assume that maildomain is localhsot, so you can't just
+# change the setting below and expect everythig to work.
+use_remote_user = True
+remote_user_maildomain = localhost
+
+# Users may copy files here directly or upload via SFTP/SCP
+ftp_upload_dir = /var/lib/galaxy-server/transfer
+ftp_upload_site = *** Transfer files via SCP or SFTP to /var/lib/galaxy-server/transfer/... ***
+
+# There is no neat way to log out a user with Basic Auth, but here is a non-neat way.
+# Not yet tested on IE.
+remote_user_logout_href = logout1.html
diff --git a/debian/universe_wsgi.d/32_pg-database.ini b/debian/universe_wsgi.d/32_pg-database.ini
new file mode 100644
index 0000000..ddd03c8
--- /dev/null
+++ b/debian/universe_wsgi.d/32_pg-database.ini
@@ -0,0 +1,8 @@
+# Configuration fragments added by galaxy-server-apache-proxy
+
+[app:main]
+
+database_connection = postgresql:///Debian-galaxy
+base_engine_option_server_side_cursors = True
+database_engine_option_strategy = threadlocal
+
diff --git a/galaxy_16.10.orig.tar.xz.delta b/galaxy_16.10.orig.tar.xz.delta
deleted file mode 100644
index 4b53230..0000000
Binary files a/galaxy_16.10.orig.tar.xz.delta and /dev/null differ
diff --git a/galaxy_16.10.orig.tar.xz.id b/galaxy_16.10.orig.tar.xz.id
deleted file mode 100644
index c3bbc28..0000000
--- a/galaxy_16.10.orig.tar.xz.id
+++ /dev/null
@@ -1 +0,0 @@
-177617788cf8959573223b2c2dba4795e4b1dab1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/galaxy.git



More information about the debian-med-commit mailing list