1. VectorLinux Core
  2. vinstall

Commits

Rodrigo Bistolfi  committed e9dbace

Live/advanced: install packages implementation

  • Participants
  • Parent commits 09c95ae
  • Branches master

Comments (0)

Files changed (1)

File vinstall/controller/packages.py

View file
             yield self.installpkg, (package,), "Installing %s" % package.split("/")[-1]
         yield self.postinstall, tuple(), "Installing setup routines"
         yield self.install_kernel, tuple(), "Installing Linux kernel"
-        yield self.vector_version, tuple(), "Writting /etc/vector-version"
+        yield self.vector_version, tuple(), "Writing /etc/vector-version"
 
     def packages(self, bulks):
         """Return packages to be installed by chaining required packages with
             utils.mountiso(install_media.path, mountpoint)
         else:
             utils.mount(install_media.path, mountpoint, filesystem="auto")
+
+
+class LivePackageInstaller(object):
+    """Install packages from a Live CD
+    
+    """
+    def init(self):
+        self.mount_source()
+
+    def next(self):
+        """Return next step
+
+        """
+        from vinstall.controller import usersetup
+        return usersetup.UserSetup
+
+    def previous(self):
+        """
+
+        """
+        from vinstall.controller import mountpoints
+        return mountpoints.Mountpoint
+ 
+    def command(self):
+        yield self.preinstall, tuple(), "Preparing package install"
+        for package in self.packages():
+            yield self.installpkg, (package,), "Installing %s" % package.split("/")[-1]
+        yield self.install_kernel, tuple(), "Installing Linux kernel"
+        yield self.vector_version, tuple(), "Writing /etc/vector-version"
+
+    def packages(self):
+        """Return an iterable containing all available packages for a Live
+        edition
+        
+        """
+        return glob.glob("/mnt/SOURCE/*/base/*xzm")
+
+    def installpkg(self, package):
+        """Install a package from a Live install media
+        
+        """
+        command = "/usr/bin/xzm2dir %s %s" % (package, "/mnt/TARGET")
+        subprocess.check_call(command.split())
+
+    def install_kernel(self):
+        """Install Linux image from a Live install media
+        
+        """
+        return NotImplemented
+
+    def preinstall(self):
+        """Run before installing packages, used for creating needed dirs
+
+        """
+        root = "/mnt/TARGET"
+        for d in ("tmp", "mnt", "sys", "proc", "dev"):
+            d2 = os.path.join(root, d)
+            os.mkdir(d2)
+        for d in ("cdrom", "cdwriter", "dvd", "dvdwriter", "floppy", "hd",
+                "linux", "loop", "memory", "pendrive", "tmp", "vl-hot",
+                "win", "zip"):
+            d2 = os.path.join(root, "mnt", d)
+            os.mkdir(d2)
+
+    def vector_version(self):
+        """write /etc/vector-version based on the information
+        in VINSTALL.INI
+
+        """
+        install_media = self.config["install_media"]
+        distro = install_media.config.get("general", "distro").replace("\"", "")
+        version = install_media.config.get("general", "version").replace("\"", "")
+        build_date = install_media.config.get("general",
+                "build_date").replace("\"", "")
+        vector_version =  "%s built on %s\n" % (version, build_date)
+        with open("/mnt/TARGET/etc/vector-version", 'w') as f:
+            f.write(vector_version)
+
+    def mount_source(self):
+        """Mount the install media, needed for looking for available packages
+
+        """
+        mountpoint = "/mnt/SOURCE"
+        if not os.path.exists(mountpoint):
+            os.mkdir(mountpoint)
+        install_media = self.config["install_media"]
+        if install_media.is_iso():
+            if not os.path.exists(install_media.path):
+                print "mount container here"
+		mntpoint = install_media.path.rsplit("/", 1)[0]
+		dev = mntpoint.replace("/mnt", "/dev")
+            	utils.mount(dev, mntpoint)
+            utils.mountiso(install_media.path, mountpoint)
+        else:
+            utils.mount(install_media.path, mountpoint, filesystem="auto")
+