diff --git a/pisi/archive.py b/pisi/archive.py
index 8a603583..223c4f5a 100644
--- a/pisi/archive.py
+++ b/pisi/archive.py
@@ -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)
diff --git a/pisi/build.py b/pisi/build.py
index 01efb65a..65578acf 100644
--- a/pisi/build.py
+++ b/pisi/build.py
@@ -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)
diff --git a/samples/startup-notification/startup-notification.pspec b/samples/startup-notification/startup-notification.pspec
index 9dbde277..721c79bc 100644
--- a/samples/startup-notification/startup-notification.pspec
+++ b/samples/startup-notification/startup-notification.pspec
@@ -43,7 +43,6 @@
/usr/lib
/usr/share/doc
- /usr/include
@@ -53,4 +52,14 @@
+
+
+ startup-notification-devel
+ Development files for startup notification and feedback library
+ sn development
+
+ /usr/include
+
+
+