Kaydet (Commit) 1eed54b6 authored tarafından Your Name's avatar Your Name

pspec için git desteği eklendi (sha1sum yerine branch yazabilirsiniz :D )

üst 87a5ee04
...@@ -194,7 +194,10 @@ class ArchiveBinary(ArchiveBase): ...@@ -194,7 +194,10 @@ class ArchiveBinary(ArchiveBase):
# directory and leave the dirty job to actions.py ;) # directory and leave the dirty job to actions.py ;)
target_file = os.path.join(target_dir, target_file = os.path.join(target_dir,
os.path.basename(self.file_path)) os.path.basename(self.file_path))
shutil.copyfile(self.file_path, target_file) if os.path.isfile(self.file_path):
shutil.copyfile(self.file_path, target_file)
elif os.path.isdir(self.file_path):
shutil.copytree(self.file_path, target_file)
class ArchiveBzip2(ArchiveBase): class ArchiveBzip2(ArchiveBase):
...@@ -896,6 +899,8 @@ class SourceArchive: ...@@ -896,6 +899,8 @@ class SourceArchive:
ctx.config.archives_dir(), self.url.filename()) ctx.config.archives_dir(), self.url.filename())
self.archive = archive self.archive = archive
self.progress = None self.progress = None
self.isgit=(self.url.get_uri().startswith("git://") or self.url.get_uri().endswith(".git"))
self.branch="master" # TODO need support branch from pspec
def fetch(self, interactive=True): def fetch(self, interactive=True):
if not self.is_cached(interactive): if not self.is_cached(interactive):
...@@ -910,6 +915,9 @@ class SourceArchive: ...@@ -910,6 +915,9 @@ class SourceArchive:
self.fetch_from_mirror() self.fetch_from_mirror()
elif self.url.get_uri().startswith("file://") or self.url.get_uri().startswith("/"): elif self.url.get_uri().startswith("file://") or self.url.get_uri().startswith("/"):
self.fetch_from_locale() self.fetch_from_locale()
elif self.isgit:
self.branch=self.archive.sha1sum
inary.fetcher.fetch_git(self.url,ctx.config.archives_dir()+"/"+self.url.filename(),self.branch)
else: else:
inary.fetcher.fetch_url( inary.fetcher.fetch_url(
self.url, ctx.config.archives_dir(), self.progress) self.url, ctx.config.archives_dir(), self.progress)
...@@ -944,6 +952,7 @@ class SourceArchive: ...@@ -944,6 +952,7 @@ class SourceArchive:
self.progress) self.progress)
def is_cached(self, interactive=True): def is_cached(self, interactive=True):
if not os.access(self.archiveFile, os.R_OK): if not os.access(self.archiveFile, os.R_OK):
return False return False
...@@ -959,6 +968,7 @@ class SourceArchive: ...@@ -959,6 +968,7 @@ class SourceArchive:
def unpack(self, target_dir, clean_dir=True): def unpack(self, target_dir, clean_dir=True):
# check archive file's integrity # check archive file's integrity
if not util.check_file_hash(self.archiveFile, self.archive.sha1sum): if not util.check_file_hash(self.archiveFile, self.archive.sha1sum):
ctx.ui.warning(_("Archive File: {}\n * Expected sha1 value: {}\n * Received sha1 value: {}\n".format( ctx.ui.warning(_("Archive File: {}\n * Expected sha1 value: {}\n * Received sha1 value: {}\n".format(
......
...@@ -342,6 +342,18 @@ class Fetcher: ...@@ -342,6 +342,18 @@ class Fetcher:
# helper function # helper function
def fetch_git(url, destdir="",branch="master"):
if os.path.isdir(destdir):
os.system("rm -rf \"{}\"".format(destdir))
status=os.system("git clone \"{0}\" \"{1}\" -b \"{2}\"".format(url,destdir,branch))
if status != 0:
print(status)
ctx.ui.error(
_('Failed to clone git repository from {}.').format(url))
exit(1)
def fetch_url(url, destdir=None, progress=None, destfile=None, pkgname=''): def fetch_url(url, destdir=None, progress=None, destfile=None, pkgname=''):
if not destdir: if not destdir:
...@@ -436,4 +448,8 @@ def fetch(packages=None, path=os.path.curdir): ...@@ -436,4 +448,8 @@ def fetch(packages=None, path=os.path.curdir):
repodb.get_repo_url(repo)), str( repodb.get_repo_url(repo)), str(
uri.path())) uri.path()))
fetch_url(url, path, ctx.ui.Progress) if url.startswith("git://") or url.endswith(".git"):
branch="master"
fetch_git(url.replace("git://","https://"),path,branch)
else:
fetch_url(url, path, ctx.ui.Progress)
#!/usr/bin/python3
import sys
esc="\x1b"
class logger:
logfile=None
nocolor=False
nodebug=True
noverbose=True
noinfo=False
BLACK=30
RED=31
GREEN=32
YELLOW=33
BLUE=34
PURPLE=35
CYAN=36
WHITE=37
RESET=0
BOLD=1
DIM=2
ITALIC=3
UNDERLINE=4
BLINK=5
REVERSE=7
HIDDEN=8
def print(self,msg,color=0,attr=0,fd=sys.stdout,nowrite=False):
if(not nowrite):
fd.write(self.colorize(msg,color,attr))
if(self.logfile):
self.logfile.write(msg)
def println(self,msg,color=0,attr=0,fd=sys.stdout,nl=True,nowrite=False):
if(nl):
self.print(msg+"\n",color,attr,fd,nowrite)
else:
self.print(msg,color,attr,fd,nowrite)
def colorize(self,msg,color=None,attr=None):
if((not self.nocolor) or ((not attr) and (not color))):
ret=""
if (attr):
ret="{0}{1}[{2}m".format(ret,esc,str(attr))
if (color):
ret="{0}{1}[{2}m".format(ret,esc,str(color))
ret="{0}{1}{2}[;0m".format(ret,msg,esc)
return ret
else:
return msg
def output(self,msg,newline=True):
"""Level 1 output"""
self.println(msg,nl=newline)
def info(self,msg,newline=True):
"""Level 2 output"""
self.println(msg,color=self.BLUE,attr=self.BOLD,nl=newline,nowrite=self.noinfo)
def verbose(self,msg,newline=True):
"""Level 3 output"""
self.println(msg,color=self.CYAN,nl=newline,nowrite=self.noverbose)
def debug(self,msg,newline=True):
"""Level 4 output"""
self.println(msg,color=self.GREEN,attr=self.ITALIC,nl=newline,nowrite=self.nodebug)
def warning(self,msg,newline=True):
"""Level 5 output"""
self.println(msg,color=self.YELLOW,attr=self.BOLD,fd=sys.stderr,nl=newline)
def error(self,msg,newline=True):
"""Level 6 output"""
self.println(msg,color=self.PURPLE,attr=self.UNDERLINE,fd=sys.stderr,nl=newline)
def fatal(self,msg,status=1,newline=True):
"""Level 7 output"""
self.println(msg,color=self.RED,attr=self.BOLD,fd=sys.stderr,nl=newline)
exit(status)
...@@ -734,6 +734,8 @@ def get_file_hashes(top, excludePrefix=None, removePrefix=None): ...@@ -734,6 +734,8 @@ def get_file_hashes(top, excludePrefix=None, removePrefix=None):
def check_file_hash(filename, hash): def check_file_hash(filename, hash):
"""Check the file's integrity with a given hash.""" """Check the file's integrity with a given hash."""
if os.path.isdir(filename+"/.git"):
return True
return sha1_file(filename) == hash return sha1_file(filename) == hash
......
...@@ -10,11 +10,13 @@ from inary.actionsapi import get ...@@ -10,11 +10,13 @@ from inary.actionsapi import get
from inary.actionsapi import inarytools from inary.actionsapi import inarytools
from inary.actionsapi import mesontools from inary.actionsapi import mesontools
from inary.actionsapi import cmaketools from inary.actionsapi import cmaketools
from inary.actionsapi import autotools
def setup():
pass
def build():
pass
def install(): def install():
print("curdir="+get.curDIR()) autotools.install("DESTDIR={} >/dev/null".format(get.installDIR()))
print("workdir="+get.workDIR())
shelltools.system("mkdir -p {}/usr/bin/".format(get.installDIR()))
shelltools.system("install space {}/usr/bin/hello".format(get.installDIR()))
shelltools.system("env")
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!DOCTYPE INARY SYSTEM "https://raw.githubusercontent.com/Zaryob/inary/master/inary-spec.dtd"> <!DOCTYPE INARY SYSTEM "https://raw.githubusercontent.com/Zaryob/inary/master/inary-spec.dtd">
<INARY> <INARY>
<Source> <Source>
<Name>hello</Name> <Name>unibuild</Name>
<Homepage>https://gitlab.com/sulinos/devel/inary</Homepage> <Homepage>https://gitlab.com/sulinos/devel/inary</Homepage>
<Packager> <Packager>
<Name>Ali Rıza KESKİN</Name> <Name>Ali Rıza KESKİN</Name>
...@@ -11,16 +11,17 @@ ...@@ -11,16 +11,17 @@
<License>GPLv2</License> <License>GPLv2</License>
<IsA>app:console</IsA> <IsA>app:console</IsA>
<PartOf>system.base</PartOf> <PartOf>system.base</PartOf>
<Summary>Hello package build test</Summary> <Summary>unibuild package build test</Summary>
<Description>Pakcage build test for inary.</Description> <Description>Pakcage build test for inary.</Description>
<Archive sha1sum="b858cb282617fb0956d960215c8e84d1ccf909c6" type="binary" >https://gitlab.com/sulincix/outher/-/raw/gh-pages/space</Archive> <Archive sha1sum="master" >https://gitlab.com/sulinos/devel/unibuild.git</Archive>
</Source> </Source>
<Package> <Package>
<IsA>postOps</IsA> <IsA>postOps</IsA>
<Name>hello</Name> <Name>unibuild</Name>
<Files> <Files>
<Path fileType="executable">/usr/bin</Path> <Path fileType="executable">/usr/bin</Path>
<Path fileType="library">/usr/lib</Path>
</Files> </Files>
</Package> </Package>
......
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