Anonymous avatar Anonymous committed 391eb1d

Adding an uninstall hook

Comments (0)

Files changed (2)

 environment it allows each level of support to function
 independently. The application level has the ability to install and
 use the underlying system, while also allowing overriding those
-features as necessary. 
+features as necessary.
 
 The result is that system administrators can safely upgrade systems
 without being limited by an application requirements. An application
   $ XE_ROOT=xenv xe run python
 
 
+Packages
+========
+
+A package is a single file that contains a directory structure to
+untar on top a xenv. It may place files anywhere in the xenv and
+is responsible for not corrupting the environment.
+
+The only restriction is that it may not add any hidden (.) files
+to the root directory.
+
+Package Name
+------------
+
+The package must be a tarball (.tar) or gzipped tar (.tar.gz). It
+must be named using the following pattern: ::
+
+  {package-name}-{version}.tar[.gz]
+
+The version must comply with the semver.org specification.
+
+File Hiearchy
+-------------
+
+The file hierarchy can be whatever the package creator likes. The
+only restrictions are the following.
+
+
+The /usr Directory
+~~~~~~~~~~~~~~~~~~
+
+The usr directory is where an xenv installs its core utilities and
+executables. For example, we install a virtualenv in /usr for
+using Python.
+
+
+The /local Directory
+~~~~~~~~~~~~~~~~~~~~
+
+If you create a /local/bin, it will be added to the PATH when
+running something via xe.
+
+
+Installation Hooks
+------------------
+
+A xenv package does not aim to be a "real" package format and as
+such, it may wrap a more complex package such as an RPM. For this
+reason we provide a package hook in order to allow installing
+these sorts of packages.
+
+When a package is installed (untarred) in the xenv, an install
+script can be placed at /packages/install. This file must be
+executable. It may use any language that is available on the host
+system via a shebang.
+
+After it is installed, the install script will be moved to: ::
+
+  /packages/{package-name}/{version}/install
+
+In the future xenv will also supporting a "uninstall" hook file as
+well that can be used to script removing packages that might not have
+been untarred. For example, if you wanted to make a package that
+installed some packages from pypi, it might be a single tarball with
+an install and uninstall script. 
+
+Here is what an install script might look like: ::
+
+  #!/usr/bin/bash
+
+  xe run pip install pyramid
+  xe run pip install http://urlto.somerepo.com/my-pyramidapp-4.3.5.tar.gz
+
+And the uninstall might be: ::
+
+  #!/usr/bin/bash
+
+  xe run pip uninstall my-pyramidapp
+  xe run pip uninstall pyramid
+
+In this way the "package" is really just a tool to deploy the
+application via other means.
+
+
 Seriously? That is it?
 ======================
 
             'PATH': self.xenv_fs.path()
         }
         try:
-            print cmd
             call(cmd, env=env)
         except KeyboardInterrupt:
             pass
         (self.root/ pkg.fname).move(history)
 
     def uninstall(self, pkg):
-        filelist = check_output(['tar', 'tf', self.root/'packages'/pkg.name/pkg.version/pkg.fname])
+        filelist = check_output([
+            'tar', 'tf', self.root/'packages'/pkg.name/pkg.version/pkg.fname
+        ])
+        uninstall_hook = self.root/'packages'/pkg.name/pkg.version/'uninstall'
+        history = self.root / 'packages' / pkg.name / pkg.version
+        
         for line in filelist.split('\n'):
             name = path(line)
             if name.isfile():
                 name.remove()
-                
-        
 
-               
+        if uninstall_hook.isfile():
+            call(uninstall_hook.abspath(), cwd=self.root)
+
+        history.removedirs()
+
+
 class Package(object):
     '''
-    A package is a single file that contains a directory structure to
-    untar on top a xenv. It may place files anywhere in the xenv and
-    is responsible for not corrupting the environment.
-
-    The only restriction is that it may not add any hidden (.) files
-    to the root directory.
-
-    Package Name
-    ============
-
-    The package must be a tarball (.tar) or gzipped tar (.tar.gz). It
-    must be named using the following pattern: ::
-    
-      {package-name}-{version}.tar[.gz]
-
-    The version must comply with the semver.org specification.
-
-    File Hiearchy
-    =============
-
-    The file hierarchy can be whatever the package creator likes. The
-    only restrictions are the following.
-
-
-    The /usr Directory
-    ------------------
-
-    The usr directory is where an xenv installs its core utilities and
-    executables. For example, we install a virtualenv in /usr for
-    using Python.
-
-    
-    The /local Directory
-    --------------------
-
-    If you create a /local/bin, it will be added to the PATH when
-    running something via xe.
-
-
-    Installation Hooks
-    ==================
-
-    A xenv package does not aim to be a "real" package format and as
-    such, it may wrap a more complex package such as an RPM. For this
-    reason we provide a package hook in order to allow installing
-    these sorts of packages.
-
-    When a package is installed (untarred) in the xenv, an install
-    script can be placed at /packages/install. This file must be
-    executable. It may use any language that is available on the host
-    system via a shebang.
-
-    After it is installed, the install script will be moved to: ::
-      /packages/{package-name}/{version}/install
+    A simple package format for a xenv. See the README for more info.
     '''
 
     def __init__(self, name, version, base='file:'):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.