-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a nice APT library along with the supportrepo module (set-ups t…
…he support repo present in latest snapshots) modules/bootloader: inst: fetch bootloader from supportrepo, if we can core/main: support for enums.
- Loading branch information
Showing
10 changed files
with
177 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
# linstaller core apt library - (C) 2013 Eugenio "g7" Paolantonio and the Semplice Team. | ||
# All rights reserved. Work released under the GNU GPL license, version 3 or later. | ||
# | ||
# This is a module of linstaller, should not be executed as a standalone application. | ||
|
||
import linstaller.core.main as m | ||
|
||
import apt | ||
import os | ||
|
||
RepositoryType = m.enum("Trivial", "Automatic") | ||
|
||
class Cache(apt.cache.Cache): | ||
|
||
""" This class is intended to manage packages and repositories in target, | ||
outside the chroot. """ | ||
|
||
def __init__(self, rootdir="/linstaller/target", memonly=True, sourceslist="/tmp/linstaller_sourceslist.list"): | ||
|
||
# Just one catch: we need to specify rootdir as libraries cannot | ||
# access the main_settings dictionary. | ||
# The calling module should set rootdir to self.main_settings["target"]. | ||
|
||
apt.cache.Cache.__init__(self, progress=None, rootdir=rootdir, memonly=memonly) | ||
|
||
self.sourceslist = sourceslist | ||
|
||
def add_repository(self, mode, path, binarydir="./", distro=None, sections=None, withsrc=False): | ||
""" Adds the repository to self.sourceslist. | ||
path is the URI of the repository. | ||
mode is the relevant repository type (see RepositoryType enum) | ||
If mode is RepositoryType.TRIVIAL, binarydir is the only addition parameter (defaults to ./) | ||
If mode is RepositoryType.AUTOMATIC, the additional - and required - parameters are distro and | ||
sections (tuple), while withsrc is the only additional parameter. If True, it will set deb-src | ||
repositories too. """ | ||
|
||
if os.path.exists(self.sourceslist): | ||
openmode = "a" | ||
else: | ||
openmode = "w" | ||
|
||
if mode == RepositoryType.TRIVIAL: | ||
with open(self.sourceslist, openmode) as f: | ||
f.write("deb %(path)s %(binarydir)s\n") % {"path":path, "binarydir":binarydir} | ||
elif mode == RepositoryType.AUTOMATIC: | ||
if None in (distro, sections): | ||
raise TypeError("add_repository() in RepositoryType.AUTOMATIC mode needs distro and sections defined") | ||
|
||
with open(self.sourceslist, openmode) as f: | ||
f.write("deb %(path)s %(distro)s %(sections)s\n") % {"path":path, "distro":distro, "sections":" ".join(sections)} | ||
if withsrc: | ||
f.write("deb-src %(path)s %(distro)s %(sections)s\n") % {"path":path, "distro":distro, "sections":" ".join(sections)} | ||
|
||
def update(self, fetch_progress=None, pulse_interval=0, raise_on_error=True): | ||
""" Run the equivalent of apt-get update. | ||
See apt.cache.update() for a detailed explanation. | ||
This method will call update() with the sources_list overrided by self.sourceslist. """ | ||
|
||
apt.cache.update(self, | ||
fetch_progress=fetch_progress, | ||
pulse_interval=pulse_interval, | ||
raise_on_error=raise_on_error, | ||
sources_list=self.sources_list | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
# linstaller supportrepo module install - (C) 2013 Eugenio "g7" Paolantonio and the Semplice Team. | ||
# All rights reserved. Work released under the GNU GPL license, version 3 or later. | ||
# | ||
# This is a module of linstaller, should not be executed as a standalone application. | ||
|
||
import linstaller.core.module as module | ||
import linstaller.core.apt as aptl | ||
|
||
import os | ||
|
||
class Module(module.Module): | ||
def _associate_(self): | ||
""" Shut up associate as we do not have any frontend. """ | ||
|
||
pass | ||
|
||
def start(self): | ||
""" Start module. """ | ||
|
||
# We need to support older semplice-current releases (Semplice 4) | ||
# which may get this linstaller by auto-update and will not be | ||
# able to install the bootloader because it will try to install | ||
# the packages from the CD (repositories have been added starting | ||
# from Semplice 5) | ||
|
||
if os.path.exists(self.settings["path"]) | ||
self.cache = aptl.Cache(rootdir=self.main_settings["target"]) | ||
self.cache.add_repository(aptl.RepositoryType.TRIVIAL, self.settings["path"], binarydir=self.settings["binarydir"]) | ||
|
||
# Update | ||
self.cache.update() | ||
|
||
# Cache the cache object. This will be used by whoever wants to use the supportrepo. | ||
self.settings["cache"] = self.cache | ||
else: | ||
self.settings["cache"] = None | ||
|
||
def revert(self): | ||
""" Revert changes. """ | ||
|
||
# Is this really needed? (cache created with memonly and sources file in /tmp) | ||
pass | ||
|
||
def seedpre(self): | ||
""" Cache settings """ | ||
|
||
self.cache("path") | ||
self.cache("binarydir", "./") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import linstaller.core.libmodules.partdisks.lvm as lvm | ||
|
||
print lvm.return_pv() |