mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-17 07:48:18 +01:00
update custom repository
This commit is contained in:
parent
a620cb7024
commit
9ae83e56bb
4 changed files with 39 additions and 19 deletions
|
@ -1,9 +1,10 @@
|
|||
Version 2.1.6
|
||||
30-12-2014
|
||||
02-1-2015
|
||||
|
||||
[Updated] - Fix queue downloads.
|
||||
- Update find argument.
|
||||
|
||||
[Feature] - Added custom binary repository.
|
||||
|
||||
|
||||
Version 2.1.5
|
||||
|
|
|
@ -64,23 +64,32 @@ class Initialization(object):
|
|||
if not os.path.exists(slpkg_tmp_patches):
|
||||
os.makedirs(slpkg_tmp_patches)
|
||||
|
||||
def custom(self):
|
||||
def custom(self, name):
|
||||
'''
|
||||
Creating user select repository local library
|
||||
'''
|
||||
for name, repo in Repo().custom_repository().items():
|
||||
log = log_path + name + "/"
|
||||
lib = lib_path + "{0}_repo/".format(name)
|
||||
lib_file = "PACKAGES.TXT"
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
if not os.path.exists(log):
|
||||
os.mkdir(log)
|
||||
if not os.path.exists(lib):
|
||||
os.mkdir(lib)
|
||||
packages_txt = "{0}{1}".format(repo, lib_file)
|
||||
checksums_md5 = "{0}{1}".format(repo, md5_file)
|
||||
self.write(lib, lib_file, packages_txt)
|
||||
self.write(lib, md5_file, checksums_md5)
|
||||
repo = Repo().custom_repository()[name]
|
||||
log = log_path + name + "/"
|
||||
lib = lib_path + "{0}_repo/".format(name)
|
||||
lib_file = "PACKAGES.TXT"
|
||||
lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
if not os.path.exists(log):
|
||||
os.mkdir(log)
|
||||
if not os.path.exists(lib):
|
||||
os.mkdir(lib)
|
||||
packages_txt = "{0}{1}".format(repo, lib_file)
|
||||
filelist_txt = ""
|
||||
checksums_md5 = "{0}{1}".format(repo, md5_file)
|
||||
changelog_txt = "{0}{1}".format(repo, log_file)
|
||||
self.write(lib, lib_file, packages_txt)
|
||||
self.write(lib, md5_file, checksums_md5)
|
||||
if URL(changelog_txt).reading() != ' ':
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file,
|
||||
packages_txt, md5_file, checksums_md5, lst_file,
|
||||
filelist_txt)
|
||||
|
||||
def slack(self):
|
||||
'''
|
||||
|
@ -571,7 +580,7 @@ class Update(object):
|
|||
if repo in default_repositories:
|
||||
exec('{0}.{1}()'.format(self._init, repo))
|
||||
else:
|
||||
exec('{0}.{1}()'.format(self._init, 'custom'))
|
||||
Initialization().custom(repo)
|
||||
sys.stdout.write("{0}Done{1}\n".format(color['GREY'],
|
||||
color['ENDC']))
|
||||
print("") # new line at end
|
||||
|
|
|
@ -43,6 +43,8 @@ class Repo(object):
|
|||
Write custom repository name and url in a file
|
||||
'''
|
||||
repo_name = []
|
||||
if not url.endswith('/'):
|
||||
url = url + '/'
|
||||
for line in self.repositories_list.splitlines():
|
||||
line = line.lstrip()
|
||||
if line and not line.startswith("#"):
|
||||
|
@ -67,14 +69,19 @@ class Repo(object):
|
|||
'''
|
||||
Remove custom repository
|
||||
'''
|
||||
rem_repo = False
|
||||
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")
|
||||
print("Repository '{0}' successfully "
|
||||
else:
|
||||
print("\nRepository '{0}' successfully "
|
||||
"removed\n".format(repo))
|
||||
rem_repo = True
|
||||
repos.close()
|
||||
if not rem_repo:
|
||||
print("\nRepository '{0}' doesn't exist\n".format(repo))
|
||||
sys.exit(0)
|
||||
|
||||
def custom_repository(self):
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
import sys
|
||||
import urllib2
|
||||
|
||||
from __metadata__ import color
|
||||
|
||||
|
||||
class URL(object):
|
||||
|
||||
|
@ -38,8 +40,9 @@ class URL(object):
|
|||
f = urllib2.urlopen(self.link)
|
||||
return f.read()
|
||||
except (urllib2.URLError, ValueError):
|
||||
print("\nslpkg: error: connection refused\n")
|
||||
sys.exit(0)
|
||||
print("\n{0}Can't read file '{1}'{2}".format(
|
||||
color['RED'], self.link.split('/')[-1], color['ENDC']))
|
||||
return ' '
|
||||
except KeyboardInterrupt:
|
||||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in a new issue