-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eugenio Paolantonio (g7) <[email protected]>
- Loading branch information
0 parents
commit 9efca45
Showing
20 changed files
with
373 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
libchannels | ||
=========== | ||
|
||
libchannels is a python library that permits to easily manage Semplice's | ||
update channels. |
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 @@ | ||
[provider] | ||
name = Base system | ||
description = Provider for the base system |
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,11 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import libchannels.discovery | ||
|
||
discovery = libchannels.discovery.ChannelDiscovery() | ||
|
||
discovery.discover() | ||
|
||
|
||
print(discovery.channels) |
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,22 @@ | ||
[channel] | ||
name = Debian 8.0 | ||
description = Channel providing Debian 8.0 jessie with updates | ||
provides = base | ||
|
||
[main] | ||
default_mirror = http://ftp.debian.org/debian/ | ||
origin = Debian | ||
codename = jessie | ||
components = main contrib non-free | ||
|
||
[updates] | ||
default_mirror = http://ftp.debian.org/debian/ | ||
origin = Debian | ||
codename = jessie-updates | ||
components = main contrib non-free | ||
|
||
[security] | ||
default_mirror = http://security.debian.org/ | ||
origin = Debian | ||
codename = jessie | ||
components = updates/main updates/contrib updates/non-free |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,112 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# libchannels - update channels management library | ||
# Copyright (C) 2015 Eugenio "g7" Paolantonio | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
|
||
import configparser | ||
|
||
from aptsources.sourceslist import SourceEntry | ||
|
||
class Channel(configparser.ConfigParser): | ||
|
||
""" | ||
A Channel is, basically, a set of Debian repositories with Dependency | ||
and "Provider" support. | ||
A channel should have the ".channel" extension and it should look like this: | ||
[channel] | ||
name = Channel name | ||
description = Channel description | ||
depends = eventual-dependencies | ||
provides = eventual-provider | ||
[repo1] | ||
default_mirror = http://path/to/mirror | ||
origin = Repository origin, as given in the Release file | ||
codename = distribution codename | ||
components = repository components | ||
[repo2] | ||
default_mirror = http://path/to/mirror | ||
origin = Repository origin, as given in the Release file | ||
codename = distribution codename | ||
components = repository components | ||
[repo3] | ||
... | ||
Enabling a channel will enable every repository in the set. | ||
""" | ||
|
||
def __init__(self, channel_name): | ||
""" | ||
Initializes the class. | ||
""" | ||
|
||
super().__init__() | ||
|
||
self.repositories = {} | ||
|
||
self.channel_name = channel_name | ||
|
||
self.read("./%s.channel" % channel_name) # FIXME: Should properly retrieve the path! | ||
|
||
# Build repository dictionary | ||
for repository in self.sections(): | ||
if repository == "channel": | ||
continue | ||
|
||
self.repositories[repository] = None # check() will eventually change that to the appropriate SourceEntry | ||
|
||
def __str__(self): | ||
""" | ||
Returns a stringified version of the object. | ||
""" | ||
|
||
return self["channel"]["name"] | ||
|
||
def check(self, origin, label, codename, source_entry): | ||
""" | ||
Returns True if the given InRelease file stream | ||
""" | ||
|
||
for repository in self.repositories: | ||
|
||
#print(self["channel"]["name"], origin, codename, source_entry) | ||
|
||
if origin != self[repository]["origin"]: | ||
continue | ||
|
||
if codename != self[repository]["codename"]: | ||
continue | ||
|
||
#if label != self[repository]["label"]: | ||
# continue | ||
|
||
# Good! | ||
self.repositories[repository] = source_entry | ||
|
||
@property | ||
def enabled(self): | ||
""" | ||
Returns True if the channel is enabled, False if not. | ||
""" | ||
|
||
#return (not (None in self.repositories.values())) | ||
return (not (False in [(type(x) == SourceEntry) for x in self.repositories.values()])) |
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# libchannels - update channels management library | ||
# Copyright (C) 2015 Eugenio "g7" Paolantonio | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
|
||
import aptsources.sourceslist | ||
|
||
sourceslist = aptsources.sourceslist.SourcesList() |
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,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# libchannels - update channels management library | ||
# Copyright (C) 2015 Eugenio "g7" Paolantonio | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
|
||
CHANNEL_SEARCH_PATH = "./" |
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,113 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# libchannels - update channels management library | ||
# Copyright (C) 2015 Eugenio "g7" Paolantonio | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
|
||
import os | ||
|
||
import libchannels.channel | ||
import libchannels.common | ||
import libchannels.config | ||
|
||
class ChannelDiscovery: | ||
|
||
""" | ||
The ChannelDiscovery() class permits to discover every enabled channel | ||
and is used to get a precise status of a given channel. | ||
""" | ||
|
||
channels = {} | ||
|
||
def __init__(self): | ||
""" | ||
Initializes the class. | ||
""" | ||
|
||
pass | ||
|
||
def discover(self): | ||
""" | ||
Discovers the currently enabled channels. | ||
""" | ||
|
||
cache = {} | ||
|
||
# Pre-load channels | ||
for channel in os.listdir(libchannels.config.CHANNEL_SEARCH_PATH): | ||
|
||
if not channel.endswith(".channel"): | ||
continue | ||
|
||
# Obtain name | ||
channel = channel.replace(".channel","") | ||
|
||
cache[channel] = libchannels.channel.Channel(channel) | ||
|
||
# Loop through enabled repositories to get a list of enabled channels | ||
for repository in libchannels.common.sourceslist: | ||
if repository.disabled or repository.uri == "" or repository.type == "deb-src": | ||
continue | ||
|
||
# Generate InRelease filename from repository URI | ||
release_base = repository.uri.replace("/","_").split("_") | ||
# Remove empty (former) trailslashes | ||
while release_base.count("") > 0: | ||
release_base.remove("") | ||
# Add other informations | ||
release_base += ["dists", repository.dist] | ||
# Remove protocol | ||
release_base.pop(0) | ||
|
||
# InRelease | ||
InRelease = os.path.join("/var/lib/apt/lists", "_".join(release_base + ["InRelease"])) | ||
# Release (fallback) | ||
Release = os.path.join("/var/lib/apt/lists", "_".join(release_base[1:] + ["Release"])) | ||
|
||
# Check existence | ||
if os.path.exists(InRelease): | ||
# InRelease found | ||
release_file = open(InRelease) | ||
elif os.path.exists(Release): | ||
# Release found | ||
release_file = open(Release) | ||
else: | ||
# Nothing found, continue | ||
continue | ||
|
||
# Obtain informations | ||
origin = label = codename = None | ||
for line in release_file: | ||
line = line.strip().split(" ") | ||
if line[0] == "Origin:": | ||
origin = " ".join(line[1:]) | ||
elif line[0] == "Label:": | ||
label = " ".join(line[1:]) | ||
elif line[0] == "Codename:": | ||
codename = " ".join(line[1:]) | ||
|
||
# Search for the right channel | ||
for channel, obj in cache.items(): | ||
obj.check(origin, label, codename, repository) | ||
|
||
# Close | ||
release_file.close() | ||
|
||
for channel, obj in cache.items(): | ||
if obj.enabled: | ||
self.channels[channel] = obj | ||
|
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 @@ | ||
[provider] | ||
name = Semplice base system | ||
description = Semplice base system provider |
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,17 @@ | ||
[channel] | ||
name = Semplice current channel | ||
description = Semplice main update channel | ||
depends = sid | ||
provides = semplice-base | ||
|
||
[main] | ||
default_mirror = http://archive.semplice-linux.org/semplice/ | ||
origin = Semplice Project | ||
codename = unstable | ||
components = main contrib non-free | ||
|
||
[changes] | ||
default_mirror = http://archive.semplice-linux.org/semplice/ | ||
origin = Semplice Project | ||
codename = changes-unstable | ||
components = main contrib non-free |
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,16 @@ | ||
[channel] | ||
name = Semplice development channel | ||
description = Semplice developer updates channel | ||
depends = semplice-current | ||
|
||
[main] | ||
default_mirror = http://archive.semplice-linux.org/semplice/ | ||
origin = Semplice Project | ||
codename = devel | ||
components = main contrib non-free | ||
|
||
[changes] | ||
default_mirror = http://archive.semplice-linux.org/semplice/ | ||
origin = Semplice Project | ||
codename = changes-devel-unstable | ||
components = main contrib non-free |
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,17 @@ | ||
[channel] | ||
name = Semplice for Workstations 2015 | ||
description = Channel for Semplice for Workstations 2015 | ||
depends = jessie | ||
provides = semplice-base | ||
|
||
[main] | ||
default_mirror = http://archive.semplice-linux.org/semplice/ | ||
origin = Semplice Project | ||
codename = jessie | ||
components = main contrib non-free | ||
|
||
[changes] | ||
default_mirror = http://archive.semplice-linux.org/semplice/ | ||
origin = Semplice Project | ||
codename = changes-jessie | ||
components = main contrib non-free |
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,10 @@ | ||
[channel] | ||
name = Debian unstable channel | ||
description = Debian unstable "sid" | ||
provides = base | ||
|
||
[unstable] | ||
default_mirror = http://ftp.debian.org/debian/ | ||
origin = Debian | ||
codename = sid | ||
components = main contrib non-free |