Exemple #1
0
    def Init(self):
        distributions = FieldSet("")
        distributions["Codename"] = self.codename
        distributions["Components"] = self.component
        distributions["Architectures"] = " ".join(self.architectures)
        for line in subprocess.check_output(
            ["gpg", "--list-secret-keys", "--with-colons"]).splitlines():
            parts = line.split(":")
            distributions["SignWith"] = parts[4][-8:]
        Key(bucket=self.bucket, name=self.prefix + "conf/distributions")\
          .set_contents_from_string(str(distributions), policy=self.acl)

        release = ReleaseFile.New(self.codename, self.architectures,
                                  self.component)

        for architecture in self.architectures:
            # Add empty package lists for each architecture
            packages_file_relative_path = "dists/" + self.codename + "/" + \
              self.component + "/" + "binary-" + architecture + \
              "/Packages"
            Key(bucket=self.bucket, name=self.prefix + packages_file_relative_path)\
              .set_contents_from_string("", policy=self.acl)
            release.UpdateFile(self.component + "/" + "binary-" + architecture + \
              "/Packages", "")
        release.Store(self.bucket,
                      self.prefix + "dists/" + self.codename + "/Release",
                      acl=self.acl)
Exemple #2
0
    def AddPackage(self, path, remove_old_versions=False):
        metadata = FieldSet(
            subprocess.check_output(["dpkg-deb", "-I", path, "control"]))

        package = metadata["Package"]
        relative_path = "pool/" + self.component + "/" + package[0] + "/" + \
          package + "/" + basename(path)
        key = Key(bucket=self.bucket, name=self.prefix + relative_path)
        key.set_contents_from_filename(path, policy=self.acl)

        metadata["Filename"] = relative_path
        metadata["Size"] = str(os.stat(path).st_size)
        metadata["MD5"] = hashlib.md5(open(path, "rb").read()).hexdigest()
        metadata["SHA1"] = hashlib.sha1(open(path, "rb").read()).hexdigest()
        metadata["SHA256"] = hashlib.sha256(open(path,
                                                 "rb").read()).hexdigest()

        if metadata["Architecture"] == "all":
            architectures = self.architectures[:]
        else:
            architectures = metadata["Architecture"].split()

        files_to_delete = []

        for architecture in architectures:
            packages_file_relative_path = "dists/" + self.codename + "/" + \
              self.component + "/" + "binary-" + architecture + \
              "/Packages"
            packages = PackagesFile.Load(
                self.bucket, self.prefix + packages_file_relative_path)

            if remove_old_versions:
                files_to_delete.extend(packages.RemovePackage(package))

            packages.AddPackage(metadata)

            packages_str, packages_gz_str = packages.Store(
                self.bucket,
                self.prefix + packages_file_relative_path,
                acl=self.acl)

            release = ReleaseFile.Load(
                self.bucket,
                self.prefix + "dists/" + self.codename + "/Release")
            release.UpdateFile(self.component + "/" + "binary-" + architecture + \
              "/Packages", packages_str)
            release.UpdateFile(self.component + "/" + "binary-" + architecture + \
              "/Packages.gz", packages_gz_str)
            release.Store(self.bucket,
                          self.prefix + "dists/" + self.codename + "/Release",
                          acl=self.acl)

        for file_to_delete in files_to_delete:
            self.bucket.delete_key(self.prefix + file_to_delete)
Exemple #3
0
 def __init__(self, str):
     self.field_set = FieldSet(str)
Exemple #4
0
 def __init__(self, contents):
   self.packages = []
   for package_str in contents.split("\n\n"):
     if package_str == "":
       continue
     self.packages.append(FieldSet(package_str))