pisi-build artık bir PSPEC dosyasından birden fazla paket oluşturmayı destekliyor.
Meren, archive.py içerisindeki comment'e bir bak.
This commit is contained in:
+26
-13
@@ -77,25 +77,38 @@ class ArchiveZip(ArchiveBase):
|
||||
"""Close the zip archive."""
|
||||
self.zip.close()
|
||||
|
||||
def add_to_archive(self, fileName):
|
||||
"""A wrapper function to handle working directory sh*t"""
|
||||
# Meren: Bu kapsülleyici fonksiyonu ben istemiştim ama sanırım
|
||||
# yanılmışım. Paketi oluştururken farklı dosyaları install
|
||||
# içerisinden yüklemeye çalışırken verilen tüm path'i pakete koymasını
|
||||
# istememiz gerekiyor. Yani add_to_package("install/usr/include")
|
||||
# dediğimiz zaman. Zip içerisine install/usr/include şeklinde koyması
|
||||
# gerekiyor. Bu fonksiyonu şimdilik comment-out ediyorum ve bu
|
||||
# özelliğe de ihtiyacımız olur belki diye silmiyorum. Belki kolay
|
||||
# hatırlanır olmayan (sık kullanmayacağız) farklı bir isim ile burada
|
||||
# tutmak isteriz (add_basedir_to_archive?).
|
||||
|
||||
# *********************************************************************
|
||||
# def add_to_archive(self, fileName):
|
||||
# """A wrapper function to handle working directory sh*t"""
|
||||
|
||||
# # Fuck zipfile! It's a pity that it can't handle unicode strings. Grrr!
|
||||
# fileName = str(fileName)
|
||||
# cwd = os.getcwd()
|
||||
# pathName = os.path.dirname(fileName)
|
||||
# fileName = os.path.basename(fileName)
|
||||
# if pathName:
|
||||
# os.chdir(pathName)
|
||||
# self.add_file(fileName)
|
||||
# os.chdir(cwd)
|
||||
|
||||
def add_to_archive(self, fileName):
|
||||
"""Add file or directory to a zip file"""
|
||||
# Fuck zipfile! It's a pity that it can't handle unicode strings. Grrr!
|
||||
fileName = str(fileName)
|
||||
cwd = os.getcwd()
|
||||
pathName = os.path.dirname(fileName)
|
||||
fileName = os.path.basename(fileName)
|
||||
if pathName:
|
||||
os.chdir(pathName)
|
||||
self.add_file(fileName)
|
||||
os.chdir(cwd)
|
||||
|
||||
def add_file(self, fileName):
|
||||
"""Add file or directory to a zip file"""
|
||||
if os.path.isdir(fileName) and not os.path.islink(fileName):
|
||||
self.zip.writestr(fileName + '/', '')
|
||||
for f in os.listdir(fileName):
|
||||
self.add_file(fileName + '/' + f)
|
||||
self.add_to_archive(fileName + '/' + f)
|
||||
else:
|
||||
if os.path.islink(fileName):
|
||||
dest = os.readlink(fileName)
|
||||
|
||||
+38
-19
@@ -19,6 +19,27 @@ from package import Package
|
||||
class PisiBuildError(Exception):
|
||||
pass
|
||||
|
||||
# helper functions
|
||||
def getFileType(path, pinfoList):
|
||||
"""Return the file type of a path according to the given PathInfo
|
||||
list"""
|
||||
# The usage of depth is somewhat confusing. It is used for
|
||||
# finding the best match to package.paths. For an example,
|
||||
# if package.paths contains
|
||||
# ['/usr/share','/usr/share/doc'] and frpath is
|
||||
# /usr/share/doc/filename our iteration over package.paths
|
||||
# should match the second item.
|
||||
depth = 0
|
||||
ftype = ""
|
||||
for pinfo in pinfoList:
|
||||
if path.startswith(pinfo.pathname):
|
||||
length = len(pinfo.pathname)
|
||||
if depth < length:
|
||||
depth = length
|
||||
ftype = pinfo.fileType
|
||||
return ftype
|
||||
|
||||
|
||||
class PisiBuild:
|
||||
"""PisiBuild class, provides the package build and creation routines"""
|
||||
def __init__(self, buildcontext):
|
||||
@@ -168,24 +189,14 @@ class PisiBuild:
|
||||
generated files by the build system."""
|
||||
files = Files()
|
||||
install_dir = self.ctx.pkg_install_dir()
|
||||
for fpath, fhash in util.get_file_hashes(install_dir):
|
||||
# get the relative path
|
||||
frpath = fpath[len(install_dir):]
|
||||
ftype = ""
|
||||
# The usage of depth is somewhat confusing. It is used for
|
||||
# finding the best match to package.paths. For an example,
|
||||
# if package.paths contains
|
||||
# ['/usr/share','/usr/share/doc'] and frpath is
|
||||
# /usr/share/doc/filename our iteration over package.paths
|
||||
# should match the second item.
|
||||
depth = 0
|
||||
for path in package.paths:
|
||||
if frpath.startswith(path.pathname):
|
||||
if depth < len(path.pathname):
|
||||
depth = len(path.pathname)
|
||||
ftype = path.fileType
|
||||
fsize = str(os.path.getsize(fpath))
|
||||
files.append(FileInfo(frpath, ftype, fsize, fhash))
|
||||
for pinfo in package.paths:
|
||||
path = install_dir + pinfo.pathname
|
||||
for fpath, fhash in util.get_file_hashes(path):
|
||||
frpath = fpath[len(install_dir):] # relative path
|
||||
ftype = getFileType(frpath, package.paths)
|
||||
fsize = str(os.path.getsize(fpath))
|
||||
files.append(FileInfo(frpath, ftype, fsize, fhash))
|
||||
|
||||
files.write(os.path.join(self.ctx.pkg_dir(), const.files_xml))
|
||||
|
||||
def buildPackages(self):
|
||||
@@ -214,6 +225,14 @@ class PisiBuild:
|
||||
os.chdir(self.ctx.pkg_dir())
|
||||
pkg.add_to_package(const.metadata_xml)
|
||||
pkg.add_to_package(const.files_xml)
|
||||
pkg.add_to_package("install")
|
||||
|
||||
# Now it is time to add files to the packages. We should
|
||||
# only add the files listed in the Files section of the
|
||||
# Package.
|
||||
for pinfo in package.paths:
|
||||
p = os.path.join("install" + pinfo.pathname)
|
||||
if os.path.exists(p):
|
||||
pkg.add_to_package(p)
|
||||
|
||||
pkg.close()
|
||||
os.chdir(c)
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
<Files>
|
||||
<Path fileType="sharedLib">/usr/lib</Path>
|
||||
<Path fileType="doc">/usr/share/doc</Path>
|
||||
<Path fileType="header">/usr/include</Path>
|
||||
</Files>
|
||||
<History>
|
||||
<Update>
|
||||
@@ -53,4 +52,14 @@
|
||||
</Update>
|
||||
</History>
|
||||
</Package>
|
||||
|
||||
<Package>
|
||||
<Name>startup-notification-devel</Name>
|
||||
<Summary xml:lang="en">Development files for startup notification and feedback library</Summary>
|
||||
<Description>sn development</Description>
|
||||
<Files>
|
||||
<Path fileType="header">/usr/include</Path>
|
||||
</Files>
|
||||
</Package>
|
||||
|
||||
</PISI>
|
||||
|
||||
Reference in New Issue
Block a user