diff --git a/slpkg/load.py b/slpkg/load.py new file mode 100644 index 00000000..d42e78d9 --- /dev/null +++ b/slpkg/load.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# load.py file is part of slpkg. + +# Copyright 2014-2015 Dimitris Zlatanidis +# All rights reserved. + +# Slpkg is a user-friendly package manager for Slackware installations + +# https://github.com/dslackw/slpkg + +# Slpkg 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 . + + +import os +from utils import Utils +from splitting import split_package +from __metadata__ import MetaData as _meta_ + +from pkg.find import find_package + + +def library(repo): + """Load packages from slpkg library and from local + """ + pkg_list, packages = [], "" + if repo == "sbo": + if (os.path.isfile( + _meta_.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))): + packages = Utils().read_file(_meta_.lib_path + "{0}_repo/" + "SLACKBUILDS.TXT".format(repo)) + else: + if (os.path.isfile( + _meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(repo))): + packages = Utils().read_file(_meta_.lib_path + "{0}_repo/" + "PACKAGES.TXT".format(repo)) + for line in packages.splitlines(): + if repo == "sbo": + if line.startswith("SLACKBUILD NAME: "): + pkg_list.append(line[17:].strip()) + elif "local" not in repo: + if line.startswith("PACKAGE NAME: "): + pkg_list.append(line[15:].strip()) + if repo == "local": + pkg_list = find_package("", _meta_.pkg_path) + return pkg_list + + +def skiped(pkgs): + """Grap packages and added in skip + """ + skip, data = [], [] + for pkg in pkgs.split(","): + pr = pkg.split(":") + data = library(pr[0]) + if len(pr) > 1: + for d in data: + if pr[1].startswith("*") and pr[1].endswith("*"): + if pr[1][1:-1] in d: + if pr[0] == "sbo": + skip.append(d) + else: + skip.append(split_package(d)[0]) + elif pr[1].endswith("*"): + if d.startswith(pr[1][:-1]): + if pr[0] == "sbo": + skip.append(d) + else: + skip.append(split_package(d)[0]) + elif pr[1].startswith("*"): + if d.endswith(pr[1][1:]): + if pr[0] == "sbo": + skip.append(d) + else: + skip.append(split_package(d)[0]) + else: + if pr[0] == "sbo": + skip.append(d) + else: + skip.append(split_package(d)[0]) + else: + skip += pkg.split() + return skip