Kaydet (Commit) a81da592 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz
......@@ -3,7 +3,7 @@ Name: inary
Version: 1.0
Summary: Inary (Special Package Manager)
Home-page: https://gitlab.com/sulinos/sulinproject/inary
Author: Ali Riza KESKIN (sulincix) & Suleyman POYRAZ (zaryob)
Author: Sulin Project Developers
Author-email: zaryob.dev@gmail.com
License: GNU GPL3
Description: Inary is the package management system of Sulin Linux and use with Mac OS, Solaris and FreeBSD
......
......@@ -29,8 +29,11 @@ import inary.misc.epoch2string as e2s
class AddRepo(command.Command, metaclass=command.autocommand):
__doc__ = _("""Add a repository
Usage: add-repo <indexuri>
Usage: add-repo <repo-name> <indexuri>
add-repo <indexuri>
<repo-name>: It is the optional parameter that using to define repository name.
Unless defined, random data will be used as repository name.
<indexuri>: URI of index file
NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
......@@ -60,22 +63,28 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
repository.remove_repo(repo)
def run(self):
name, indexuri = None, None
if len(self.args) == 1:
#We need time based random name.
name=e2s.nextString()
name = e2s.nextString()
indexuri = self.args[0]
self.init()
ctx.ui.debug(name+" "+indexuri)
if ctx.get_option('no_fetch'):
if not ctx.ui.confirm(_('Add {} repository without updating the database?\nBy confirming '
'this you are also adding the repository to your system without '
'checking the distribution of the repository.\n'
'Do you want to continue?').format(name)):
return
repository.add_repo(name, indexuri, ctx.get_option('at'))
elif len(self.args) == 2:
name, indexuri = self.args
else:
self.help()
return
self.init()
ctx.ui.debug(_("The repository: {} \tIndex URI: {} "))
if ctx.get_option('no_fetch'):
if not ctx.ui.confirm(_('Add {} repository without updating the database?\nBy confirming '
'this you are also adding the repository to your system without '
'checking the distribution of the repository.\n'
'Do you want to continue?').format(name)):
return
repository.add_repo(name, indexuri, ctx.get_option('at'))
......@@ -23,6 +23,7 @@ import inary.db
import inary.db.itembyrepo
import inary.db.lazydb as lazydb
from inary.sxml import xmlext
import inary.util as util
import gettext
__trans = gettext.translation('inary', fallback=True)
......@@ -62,7 +63,7 @@ class PackageDB(lazydb.LazyDB):
for node in packages:
if xmlext.getNodeText(node, "Replaces"):
replaces.append(xmlext.getNodeText(node, "Name"))
return uniq(replaces)
return util.uniq(replaces)
@staticmethod
def __generate_obsoletes(doc):
......@@ -271,4 +272,4 @@ class PackageDB(lazydb.LazyDB):
if enter_date >= since_date:
packages.append(pkg)
return uniq(packages)
return util.uniq(packages)
......@@ -34,16 +34,6 @@ import inary.util as util
xmlext içine tag için remove eklenene kadar böyle
"""
try:
import ciksemel
parser = "ciksemel"
except:
import xml.dom.minidom as minidom
parser = "minidom"
class RepoError(inary.errors.Error):
pass
......@@ -82,29 +72,15 @@ class RepoOrder:
def set_status(self, repo_name, status):
repo_doc = self._get_doc()
for r in xmlext.getTagByName(repo_doc, "Repo"):
if xmlext.getNodeText(r, "Name") == repo_name:
status_node = xmlext.getNode(r, "Status")
if status_node:
xmlext.removeChild(status_node, r)
xmlext.addText(r, "Status", status)
else:
xmlext.addText(r, "Status", status)
if parser == "ciksemel":
for r in repo_doc.tags("Repo"):
if r.getTagData("Name") == repo_name:
status_node = r.getTag("Status")
if status_node:
status_node.firstChild().hide()
status_node.insertData(status)
else:
status_node = r.insertTag("Status")
status_node.insertData(status)
else:
for r in repo_doc.childNodes:
if r.nodeType == r.ELEMENT_NODE and r.tagName == "Repo":
if r.getElementsByTagName("Name")[0].firstChild.data == repo_name:
status_node = r.getElementsByTagName("Status")[0]
if status_node:
status_node.childNodes[0].nodeValue = status
else:
status_node = repo_node.createElement("Status")
status_node.appendChild(repo_doc.createTextNode("active"))
r.appendChild(status_node)
self._update(repo_doc)
......@@ -120,17 +96,12 @@ class RepoOrder:
return "inactive"
def remove(self, repo_name):
repo_doc = self._get_doc()
if parser == "ciksemel":
for r in repo_doc.tags("Repo"):
if r.getTagData("Name") == repo_name:
r.hide()
else:
for r in repo_doc.getElementsByTagName("Repo"):
if r.getElementsByTagName("Name")[0].firstChild.data == repo_name:
repo_doc.removeChild(r)
for r in xmlext.getChildElts(repo_doc):
if xmlext.getNodeText(r, "Name") == repo_name:
xmlext.removeChild(r, repo_doc)
self._update(repo_doc)
......
from . import *
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019, Sulin Community
#
# 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.
#
# Please read the COPYING file.
#
import inary.errors
class Error(inary.errors.Error):
pass
class Exception(inary.errors.Exception):
pass
from inary.misc.mergesort import *
def uniq(list,sort=False):
newlist=[]
if list != []:
if sort:
list.sort()
mcout=len(list)
cout=0
newlist.append(list[0])
while cout < mcout-1:
if list[cout+1] != list[cout]:
newlist.append(list[cout])
cout=cout+1
else:
for item in list:
if item not in newlist:
newlist.append(item)
else:
newlist=[]
return newlist
......@@ -295,7 +295,7 @@ def plan_install_pkg_names(A):
uniqdep=[]
for dep in pkg.runtimeDependencies():
uniqdep.append(dep)
uniqdep=uniq(uniqdep)
uniqdep=util.uniq(uniqdep)
for dep in uniqdep:
ctx.ui.debug(' -> checking {}'.format(str(dep)))
if not dep.satisfied_by_installed():
......
......@@ -191,13 +191,12 @@ def addText(node, tagpath, text):
node.insertData(text)
def removeChild(node, tag):
r = node.getTag(tag)
r.hide()
def removeChild(node, doc):
node.hide()
def removeChildText(node):
pass
def removeChildText(node, text):
node.firstChild().hide()
def removeAttribute(node):
......
......@@ -215,12 +215,12 @@ def addText(node, tagPath, text, branch=True):
return addNode(node, tagPath, newnode, branch=branch)
def removeChild(node, tag):
node.removeChild(tag)
def removeChild(node, doc):
doc.removeChild(node)
def removeChildText(node):
pass
node.childNodes[0].nodeValue = ""
def removeAttribute(node):
......
......@@ -162,6 +162,28 @@ def flatten_list(l):
# See: http://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python
return [item for sublist in l for item in sublist]
def uniq(list, sort=False):
"""Uniq is a list generation algorithm to delete againist arguments by Ali Rıza"""
newlist=[]
if list != []:
if sort:
list.sort()
mcout=len(list)
cout=0
newlist.append(list[0])
while cout < mcout-1:
if list[cout+1] != list[cout]:
newlist.append(list[cout])
cout=cout+1
else:
for item in list:
if item not in newlist:
newlist.append(item)
else:
newlist=[]
return newlist
def strlist(l):
"""Concatenate string reps of l's elements."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment