TIME_10M = 10
TIME_24H = 60*24
-SOURCE_PACKAGE_META = """\
-
-PKG_NAME="%(PKG_NAME)s"
-
-"""
-
-BINARY_PACKAGE_META = """\
+ORPHAN_DIRECTORIES = [
+ "lib", "lib64", "usr/lib", "usr/lib64", "libexec", "usr/libexec",
+ "bin", "sbin", "usr/bin", "usr/sbin", "usr/include", "usr/share",
+ "usr/share/man", "usr/share/man/man0", "usr/share/man/man1",
+ "usr/share/man/man2", "usr/share/man/man3", "usr/share/man/man4",
+ "usr/share/man/man5", "usr/share/man/man6", "usr/share/man/man7",
+ "usr/share/man/man8", "usr/share/man/man9", "usr/lib/pkgconfig",
+]
+ORPHAN_DIRECTORIES.sort(cmp=lambda x,y: cmp(len(x), len(y)), reverse=True)
+
+BINARY_PACKAGE_META = SOURCE_PACKAGE_META = """\
### %(name)s package
VERSION="%(package_format)s"
PKG_PROVIDES="%(provides)s"
PKG_PAYLOAD_COMP="%(payload_comp)s"
+PKG_PAYLOAD_HASH1="%(payload_hash1)s"
"""
import lzma
import os
import progressbar
+import re
import shutil
import sys
import tarfile
import zlib
import pakfire.compress
+import util
from pakfire.constants import *
from pakfire.i18n import _
# Create the tarball and add all data to it.
self.create_tarball()
- chroot_tempdir = self.tempdir[len(self.env.chrootPath()):]
- self.info.update({
- "requires" : self.env.do("/usr/lib/buildsystem-tools/dependency-tracker requires %s" % chroot_tempdir,
- returnOutput=True, env=self.pkg.env).strip(),
- "provides" : self.env.do("/usr/lib/buildsystem-tools/dependency-tracker provides %s" % chroot_tempdir,
- returnOutput=True, env=self.pkg.env).strip(),
- })
+ e = self.env.do("/usr/lib/buildsystem-tools/dependency-tracker %s" % \
+ self.tempdir[len(self.env.chrootPath()):], returnOutput=True,
+ env=self.pkg.env)
+
+ for line in e.splitlines():
+ m = re.match(r"^(\w+)=(.*)$", line)
+ if m is None:
+ continue
+
+ key, val = m.groups()
+
+ if not key in ("requires", "provides"):
+ continue
+
+ val = val.strip("\"")
+ val = val.split()
+
+ self.info[key] = " ".join(sorted(val))
self.create_info()
else:
files.append(pattern)
- else:
- logging.warning("Unrecognized pattern type: %s" % pattern)
-
files = []
for file in includes:
# Skip if file is already in the file set or
file_tar = file_real[len(self.env.chrootPath(self.env.buildroot)) + 1:]
file_tmp = os.path.join(self.tempdir, file_tar)
+ if file_tar in ORPHAN_DIRECTORIES and not os.listdir(file_real):
+ logging.debug("Found an orphaned directory: %s" % file_tar)
+ os.unlink(file_real)
+ continue
+
tar.add(file_real, arcname=file_tar)
# Record the packaged file to the filelist.
pakfire.compress.compress(self.archive_files["data.img"],
algo=compress, progress=True)
+ # Calc hashsum of the payload of the package.
+ self.info["payload_hash1"] = util.calc_hash1(self.archive_files["data.img"])
+
def create_info(self):
f = open(self.archive_files["info"], "w")
f.write(BINARY_PACKAGE_META % self.info)