AdditionalFiles ile ilgili bir sorun cikti.. Cozumu icin ya fileas diye bir attribute eklemek gerekiyordu,
 ya da util icerisindeki copy_file kodunun degistirilmesi gerekiyordu. Cunku aksi taktirde AF icerisindeki
 target ile gosterilen dosya adinda bir dizin yaratiyordu kod. Kendi isminden farkli bir isimle kopyalanmak
 istenen dosyalar icin target'ta dosya ismi belirtmek zorunlulugunu 'fileas' isimli attribute'te dosya ismini
 belirterek cozmek uygun gorundu. Aksi taktirde su anda bir suru yerde kullanilan ve o yerler icin duzgun
 calisan copy_file kodunu degistirmek gerekecekti. Simdi commit edecegim, sonra uzerinden bir daha gecip bu kodu
 refactor edecegiz.

 Ayrica filex.xml icerisinde additional file'lar yanlis sekilde ekleniyordu, Caglar onu fix etti..

 Bu commit'te ikisi birden mevcut.. Afiyet olsun :(
This commit is contained in:
A. Murat Eren
2005-07-27 16:12:28 +00:00
parent ec41e6c868
commit bf8fe6793e
3 changed files with 35 additions and 28 deletions
+27 -26
View File
@@ -227,21 +227,38 @@ class PisiBuild:
fsize = "0"
files.append(FileInfo(frpath, ftype, fsize, fhash))
# append AdditionalFiles to files.xml
for afile in package.additionalFiles:
fpath = install_dir + afile.target
ftype = "AdditionalFile"
fhash = util.sha1_file(fpath)
fsize = str(os.path.getsize(fpath))
frpath = util.removepathprefix(install_dir, fpath) # relative path
files.append(FileInfo(frpath, ftype, fsize, fhash))
files.write(os.path.join(self.ctx.pkg_dir(), const.files_xml))
def buildPackages(self):
"""Build each package defined in PSPEC file. After this process there
will be .pisi files hanging around, AS INTENDED ;)"""
for package in self.spec.packages:
c = os.getcwd()
# add comar files to package
os.chdir(self.pspecDir)
for pcomar in package.providesComar:
fname = os.path.join(const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# store additional files
install_dir = self.ctx.pkg_dir() + const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(const.files_dir, afile.filename)
dest = os.path.join(install_dir + afile.target)
if not afile.fileas:
util.copy_file(src, dest, fileas=afile.filename)
dest += afile.filename
else:
util.copy_file(src, dest, fileas=afile.fileas)
dest += afile.fileas
if afile.permission:
os.chmod(dest, int(afile.permission) | 0777)
os.chdir(c)
ui.action("** Building package %s\n" % package.name);
ui.action("Generating %s..." % const.metadata_xml)
@@ -259,26 +276,10 @@ class PisiBuild:
ui.action("Creating PISI package %s\n" % name)
pkg = Package(name, 'w')
c = os.getcwd()
# add comar files to package
os.chdir(self.pspecDir)
for pcomar in package.providesComar:
fname = os.path.join(const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# store additional files
install_dir = self.ctx.pkg_dir() + const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(const.files_dir, afile.filename)
dest = os.path.join(install_dir + afile.target, afile.filename)
util.copy_file(src, dest)
if afile.permission:
os.chmod(dest, afile.permission)
# add xmls and files
os.chdir(self.ctx.pkg_dir())
pkg.add_to_package(const.metadata_xml)
pkg.add_to_package(const.files_xml)
+3
View File
@@ -37,6 +37,7 @@ class AdditionalFileInfo:
self.target = getNodeAttribute(node, "target")
self.permission = getNodeAttribute(node, "permission")
self.owner = getNodeAttribute(node, "owner")
self.fileas = getNodeAttribute(node, "fileas")
def elt(self, xml):
node = xml.newNode("AdditionalFile")
@@ -46,6 +47,8 @@ class AdditionalFileInfo:
node.setAttribute("permission", self.permission)
if self.owner:
node.setAttribute("owner", self.owner)
if self.owner:
node.setAttribute("fileas", self.fileas)
def verify(self):
if not self.filename: return False
+5 -2
View File
@@ -166,11 +166,14 @@ def dir_size(dir):
yield sum([getsize(join(root, name)) for name in files if not islink(join(root,name))])
return sum( sizes() )
def copy_file(src,dest):
def copy_file(src, dest, fileas=''):
"""copy source file to destination file"""
check_file(src)
check_dir(os.path.dirname(dest))
shutil.copyfile(src, dest)
if not fileas:
shutil.copyfile(src, dest)
else:
shutil.copyfile(src, dest + '/' + fileas)
def get_file_hashes(top, excludePrefixes=None, removePrefix=None):
"""Generator function iterates over a toplevel path and returns the