2014-11-03 17:32:54 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2014-11-04 06:36:28 +02:00
|
|
|
# repositories.py file is part of slpkg.
|
2014-11-03 17:32:54 +02:00
|
|
|
|
2015-05-21 02:00:07 +03:00
|
|
|
# Copyright 2014-2015 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
2014-11-03 17:32:54 +02:00
|
|
|
# All rights reserved.
|
|
|
|
|
2014-12-19 06:57:56 +02:00
|
|
|
# Slpkg is a user-friendly package manager for Slackware installations
|
2014-11-03 17:32:54 +02:00
|
|
|
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
2014-11-21 12:51:02 +02:00
|
|
|
import os
|
2014-12-31 10:44:38 +02:00
|
|
|
|
2015-01-31 02:47:36 +02:00
|
|
|
from utils import Utils
|
2015-06-07 16:38:52 +03:00
|
|
|
from __metadata__ import MetaData as _meta_
|
2014-11-21 12:51:02 +02:00
|
|
|
|
|
|
|
|
2014-11-03 18:02:47 +02:00
|
|
|
class Repo(object):
|
2015-08-05 06:58:28 +03:00
|
|
|
"""Central repository urls
|
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
def __init__(self):
|
2015-06-08 06:28:49 +03:00
|
|
|
self.meta = _meta_
|
2015-01-04 03:40:35 +02:00
|
|
|
self.repo_file = "/etc/slpkg/custom-repositories"
|
2015-01-31 02:47:36 +02:00
|
|
|
self.repositories_list = Utils().read_file(self.repo_file)
|
2014-12-31 10:44:38 +02:00
|
|
|
|
|
|
|
def add(self, repo, url):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-01-01 10:55:05 +02:00
|
|
|
Write custom repository name and url in a file
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-31 10:44:38 +02:00
|
|
|
repo_name = []
|
2015-06-05 14:42:52 +03:00
|
|
|
if not url.endswith("/"):
|
|
|
|
url = url + "/"
|
2014-12-31 10:44:38 +02:00
|
|
|
for line in self.repositories_list.splitlines():
|
|
|
|
line = line.lstrip()
|
2015-01-01 10:55:05 +02:00
|
|
|
if line and not line.startswith("#"):
|
2014-12-31 10:44:38 +02:00
|
|
|
repo_name.append(line.split()[0])
|
2015-06-08 06:28:49 +03:00
|
|
|
if (repo in self.meta.repositories or repo in repo_name or
|
|
|
|
repo in self.meta.default_repositories):
|
2014-12-31 10:44:38 +02:00
|
|
|
print("\nRepository name '{0}' exist, select different name.\n"
|
2015-01-07 12:43:06 +02:00
|
|
|
"View all repositories with command 'repo-list'.\n".format(
|
2014-12-31 10:44:38 +02:00
|
|
|
repo))
|
2015-08-05 06:20:04 +03:00
|
|
|
raise SystemExit()
|
2014-12-31 10:44:38 +02:00
|
|
|
elif len(repo) > 6:
|
2015-01-01 10:55:05 +02:00
|
|
|
print("\nMaximum repository name length must be six (6) "
|
2014-12-31 10:44:38 +02:00
|
|
|
"characters\n")
|
2015-08-05 06:20:04 +03:00
|
|
|
raise SystemExit()
|
2014-12-31 10:44:38 +02:00
|
|
|
with open(self.repo_file, "a") as repos:
|
2015-06-05 14:42:52 +03:00
|
|
|
new_line = " {0}{1}{2}\n".format(repo, " " * (10 - len(repo)), url)
|
2014-12-31 10:44:38 +02:00
|
|
|
repos.write(new_line)
|
|
|
|
repos.close()
|
2015-01-01 10:55:05 +02:00
|
|
|
print("\nRepository '{0}' successfully added\n".format(repo))
|
2015-08-05 06:20:04 +03:00
|
|
|
raise SystemExit()
|
2015-01-01 10:55:05 +02:00
|
|
|
|
|
|
|
def remove(self, repo):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-01-01 10:55:05 +02:00
|
|
|
Remove custom repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-01-03 07:53:50 +02:00
|
|
|
rem_repo = False
|
2015-01-01 10:55:05 +02:00
|
|
|
with open(self.repo_file, "w") as repos:
|
|
|
|
for line in self.repositories_list.splitlines():
|
|
|
|
repo_name = line.split()[0]
|
|
|
|
if repo_name != repo:
|
|
|
|
repos.write(line + "\n")
|
2015-01-03 07:53:50 +02:00
|
|
|
else:
|
|
|
|
print("\nRepository '{0}' successfully "
|
2015-01-01 10:55:05 +02:00
|
|
|
"removed\n".format(repo))
|
2015-01-03 07:53:50 +02:00
|
|
|
rem_repo = True
|
2015-01-01 10:55:05 +02:00
|
|
|
repos.close()
|
2015-01-03 07:53:50 +02:00
|
|
|
if not rem_repo:
|
|
|
|
print("\nRepository '{0}' doesn't exist\n".format(repo))
|
2015-08-05 06:20:04 +03:00
|
|
|
raise SystemExit()
|
2014-12-31 10:44:38 +02:00
|
|
|
|
2015-01-01 10:55:05 +02:00
|
|
|
def custom_repository(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-01-01 10:55:05 +02:00
|
|
|
Return dictionary with repo name and url
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-31 10:44:38 +02:00
|
|
|
dict_repo = {}
|
|
|
|
for line in self.repositories_list.splitlines():
|
|
|
|
line = line.lstrip()
|
|
|
|
if not line.startswith("#"):
|
|
|
|
dict_repo[line.split()[0]] = line.split()[1]
|
|
|
|
return dict_repo
|
2014-11-03 18:02:47 +02:00
|
|
|
|
|
|
|
def slack(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
Official slackware repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-21 12:51:02 +02:00
|
|
|
default = "http://mirrors.slackware.com/slackware/"
|
2015-08-10 06:36:07 +03:00
|
|
|
if self.meta.arch.startswith("arm"):
|
|
|
|
default = "http://ftp.arm.slackware.com/slackwarearm/"
|
2014-11-21 12:51:02 +02:00
|
|
|
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
|
2015-06-08 06:28:49 +03:00
|
|
|
mirrors = Utils().read_file(
|
|
|
|
self.meta.conf_path + "slackware-mirrors")
|
2014-11-21 12:51:02 +02:00
|
|
|
for line in mirrors.splitlines():
|
|
|
|
line = line.rstrip()
|
|
|
|
if not line.startswith("#") and line:
|
|
|
|
default = line.split()[-1]
|
|
|
|
return default
|
2014-11-03 18:02:47 +02:00
|
|
|
|
|
|
|
def sbo(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
SlackBuilds.org repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
return "http://slackbuilds.org/slackbuilds/"
|
|
|
|
|
|
|
|
def rlw(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
|
|
|
Robby"s repoisitory
|
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
return "http://rlworkman.net/pkgs/"
|
|
|
|
|
|
|
|
def alien(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
|
|
|
Alien"s slackbuilds repository
|
|
|
|
"""
|
2015-06-26 17:58:08 +03:00
|
|
|
return "http://taper.alienbase.nl/mirrors/people/alien/sbrepos/"
|
2014-11-03 18:02:47 +02:00
|
|
|
|
|
|
|
def slacky(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
Slacky.eu repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-03 18:02:47 +02:00
|
|
|
return "http://repository.slacky.eu/"
|
2014-11-28 12:30:36 +02:00
|
|
|
|
|
|
|
def studioware(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-28 12:30:36 +02:00
|
|
|
Studioware repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-11-28 12:30:36 +02:00
|
|
|
return "http://studioware.org/files/packages/"
|
2014-12-18 08:15:07 +02:00
|
|
|
|
|
|
|
def slackers(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-18 08:15:07 +02:00
|
|
|
Slackers.it repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-06-11 16:06:32 +03:00
|
|
|
return "http://ponce.cc/slackers/repository/"
|
2014-12-18 17:10:02 +02:00
|
|
|
|
|
|
|
def slackonly(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-18 17:10:02 +02:00
|
|
|
Slackonly.com repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-18 17:10:02 +02:00
|
|
|
return "https://slackonly.com/pub/packages/"
|
2014-12-24 07:42:06 +02:00
|
|
|
|
|
|
|
def ktown(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
|
|
|
Alien"s ktown repository
|
|
|
|
"""
|
2014-12-24 07:42:06 +02:00
|
|
|
return "http://alien.slackbook.org/ktown/"
|
2014-12-24 11:22:07 +02:00
|
|
|
|
|
|
|
def multi(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
|
|
|
Alien"s multilib repository
|
|
|
|
"""
|
2014-12-24 11:22:07 +02:00
|
|
|
return "http://www.slackware.com/~alien/multilib/"
|
2014-12-25 10:47:18 +02:00
|
|
|
|
|
|
|
def slacke(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-25 10:47:18 +02:00
|
|
|
Slacke slacke{17|18} repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-25 10:47:18 +02:00
|
|
|
return "http://ngc891.blogdns.net/pub/"
|
2014-12-25 18:40:30 +02:00
|
|
|
|
|
|
|
def salix(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-25 18:40:30 +02:00
|
|
|
SalixOS salix repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-25 18:40:30 +02:00
|
|
|
return "http://download.salixos.org/"
|
2014-12-27 00:58:03 +02:00
|
|
|
|
|
|
|
def slackel(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-27 00:58:03 +02:00
|
|
|
Slackel.gr slackel repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2014-12-27 00:58:03 +02:00
|
|
|
return "http://www.slackel.gr/repo/"
|
2015-01-07 08:23:30 +02:00
|
|
|
|
|
|
|
def restricted(self):
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-01-07 08:23:30 +02:00
|
|
|
Slackel.gr slackel repository
|
2015-06-05 14:42:52 +03:00
|
|
|
"""
|
2015-01-07 08:23:30 +02:00
|
|
|
return ("http://taper.alienbase.nl/mirrors/people/alien/"
|
|
|
|
"restricted_slackbuilds/")
|
2015-06-12 23:27:20 +03:00
|
|
|
|
|
|
|
def msb(self):
|
|
|
|
"""
|
|
|
|
MSB mate repository
|
|
|
|
"""
|
2015-06-25 01:16:36 +03:00
|
|
|
return "http://slackware.org.uk/msb/"
|