]> git.ipfire.org Git - pakfire.git/commitdiff
Drop distro.py
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 May 2022 12:15:27 +0000 (12:15 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 May 2022 12:15:27 +0000 (12:15 +0000)
This has been replaced with a much simpler implemenation.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/pakfire/distro.py [deleted file]

index 4b50fb988b554c7ee35b9514a378649c8087ddcd..4025c77e5ee1a6093be3bd0599d94600dd1e1913 100644 (file)
@@ -128,7 +128,6 @@ pakfire_PYTHON = \
        src/pakfire/config.py \
        src/pakfire/constants.py \
        src/pakfire/daemon.py \
-       src/pakfire/distro.py \
        src/pakfire/errors.py \
        src/pakfire/hub.py \
        src/pakfire/i18n.py \
diff --git a/src/pakfire/distro.py b/src/pakfire/distro.py
deleted file mode 100644 (file)
index ddfcde3..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/usr/bin/python3
-###############################################################################
-#                                                                             #
-# Pakfire - The IPFire package management system                              #
-# Copyright (C) 2011 Pakfire development team                                 #
-#                                                                             #
-# This program is free software: you can redistribute it and/or modify        #
-# it under the terms of the GNU General Public License as published by        #
-# the Free Software Foundation, either version 3 of the License, or           #
-# (at your option) any later version.                                         #
-#                                                                             #
-# This program 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 General Public License for more details.                                #
-#                                                                             #
-# You should have received a copy of the GNU General Public License           #
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
-#                                                                             #
-###############################################################################
-
-import logging
-import os
-import re
-
-log = logging.getLogger("pakfire.distro")
-log.propagate = 1
-
-class Distribution(object):
-       def __init__(self,  data=None):
-               self._data = {}
-
-               if data:
-                       self.update(data)
-               else:
-                       # Read /etc/os-release if it does exist.
-                       self.read_osrelease()
-
-               # Dump all data
-               self.dump()
-
-       def read_osrelease(self):
-               filename = "/etc/os-release"
-
-               if not os.path.exists(filename):
-                       return
-
-               keymap = {
-                       "NAME"        : "name",
-                       "PRETTY_NAME" : "pretty_name",
-                       "VERSION_ID"  : "release",
-               }
-
-               data = {}
-
-               f = open(filename)
-               for line in f.readlines():
-                       m = re.match(r"^(.*)=(.*)$", line)
-                       if m:
-                               k, v = m.groups()
-
-                               v = v.replace("\"", "")
-                               v = v.strip()
-
-                               try:
-                                       k = keymap[k]
-                               except KeyError:
-                                       continue
-
-                               data[k] = v
-               f.close()
-
-               self.update(data)
-
-       def dump(self):
-               log.debug("Distribution configuration:")
-
-               attrs = ("name", "release", "sname", "dist", "vendor", "contact", "source_dl")
-               for attr in attrs:
-                       log.debug(" %s : %s" % (attr, getattr(self, attr)))
-
-       def get_config(self):
-               lines = [
-                       "[distro]",
-                       "name = %s" % self.name,
-                       "release = %s" % self.release,
-                       "slogan = %s" % self.slogan,
-                       "",
-                       "vendor = %s" % self.vendor,
-                       "contact = %s" % self.contact,
-               ]
-
-               return "\n".join(lines)
-
-       def update(self, config):
-               if not config:
-                       return
-
-               # Exceptional handling for arch.
-               if "arch" in config:
-                       self.arch = config["arch"]
-                       del config["arch"]
-
-               self._data.update(config)
-
-       @property
-       def name(self):
-               return self._data.get("name", "unknown")
-
-       @property
-       def pretty_name(self):
-               pretty_name = self._data.get("pretty_name", None)
-               if not pretty_name:
-                       pretty_name = " ".join((self.name, self.release))
-
-               return pretty_name
-
-       @property
-       def release(self):
-               return self._data.get("release", "0")
-
-       @property
-       def sname(self):
-               return self.name.strip().lower()
-
-       @property
-       def slogan(self):
-               return self._data.get("slogan", "N/A")
-
-       @property
-       def vendor(self):
-               vendor = self._data.get("vendor")
-               if vendor is None:
-                       vendor = "%s Project" % self.name
-
-               return vendor
-
-       @property
-       def contact(self):
-               return self._data.get("contact", "N/A")
-
-       @property
-       def dist(self):
-               return self.sname[:2] + self.release
-
-       @property
-       def source_dl(self):
-               return self._data.get("source_dl", None)
-
-       @property
-       def environ(self):
-               """
-                       An attribute that adds some environment variables to the
-                       chroot environment.
-               """
-               env = {
-                       "DISTRO_NAME"         : self.name,
-                       "DISTRO_SNAME"        : self.sname,
-                       "DISTRO_RELEASE"      : self.release,
-                       "DISTRO_DISTTAG"      : self.dist,
-                       "DISTRO_VENDOR"       : self.vendor,
-                       "DISTRO_CONTACT"      : self.contact,
-                       "DISTRO_SLOGAN"       : self.slogan,
-               }
-
-               return env
-
-       @property
-       def info(self):
-               info = {}
-
-               for k, v in list(self.environ.items()):
-                       info[k.lower()] = v
-
-               return info