def main(argv): # --distros must be "build_os" value, not actual distro name ("ubuntu1404" vs. "ubuntu") # distros=[Distro(distro) for distro in DISTROS] DISTRO_CHOICES=[] for distro in distros: DISTRO_CHOICES.extend(distro.build_os()) parser = argparse.ArgumentParser(description='Build MongoDB Packages') parser.add_argument("-s", "--server-version", help="Server version to build (e.g. 2.7.8-rc0)") parser.add_argument("-m", "--metadata-gitspec", help="Gitspec to use for package metadata files", required=False) parser.add_argument("-r", "--release-number", help="RPM release number base", type=int, required=False) parser.add_argument("-d", "--distros", help="Distros to build for", choices=DISTRO_CHOICES, required=False, default=[], action='append') parser.add_argument("-a", "--arches", help="Architecture to build", choices=DEFAULT_ARCHES, default=DEFAULT_ARCHES, required=False, action='append') parser.add_argument("-t", "--tarball", help="Local tarball to package instead of downloading (only valid with one distro/arch combination)", required=False, type=lambda x: is_valid_file(parser, x)) args = parser.parse_args() if len(args.distros) * len(args.arches) > 1 and args.tarball: parser.error("Can only specify local tarball with one distro/arch combination") spec = Spec(args.server_version, args.metadata_gitspec, args.release_number) oldcwd=os.getcwd() srcdir=oldcwd+"/../" # We do all our work in a randomly-created directory. You can set # TEMPDIR to influence where this program will do stuff. prefix=tempfile.mkdtemp() print "Working in directory %s" % prefix os.chdir(prefix) try: # Download the binaries. urlfmt="http://downloads.mongodb.com/linux/mongodb-linux-%s-enterprise-%s-%s.tgz" # Build a package for each distro/spec/arch tuple, and # accumulate the repository-layout directories. for (distro, arch) in crossproduct(distros, args.arches): for build_os in distro.build_os(): if build_os in args.distros or not args.distros: if args.tarball: filename = tarfile(build_os, arch, spec) ensure_dir(filename) shutil.copyfile(args.tarball,filename) else: httpget(urlfmt % (arch, build_os, spec.version()), ensure_dir(tarfile(build_os, arch, spec))) repo = make_package(distro, build_os, arch, spec, srcdir) make_repo(repo, distro, build_os, spec) finally: os.chdir(oldcwd)
def main(argv): distros = [EnterpriseDistro(distro) for distro in DISTROS] args = packager.get_args(distros, ARCH_CHOICES) spec = EnterpriseSpec(args.server_version, args.metadata_gitspec, args.release_number) oldcwd = os.getcwd() srcdir = oldcwd + "/../" # Where to do all of our work. Use a randomly-created directory if one # is not passed in. prefix = args.prefix if prefix is None: prefix = tempfile.mkdtemp() print "Working in directory %s" % prefix os.chdir(prefix) try: # Download the binaries. urlfmt = "http://downloads.mongodb.com/linux/mongodb-linux-%s-enterprise-%s-%s.tgz" made_pkg = False # Build a package for each distro/spec/arch tuple, and # accumulate the repository-layout directories. for (distro, arch) in packager.crossproduct(distros, args.arches): for build_os in distro.build_os(arch): if build_os in args.distros or not args.distros: if args.tarball: filename = tarfile(build_os, arch, spec) packager.ensure_dir(filename) shutil.copyfile(args.tarball, filename) else: packager.httpget( urlfmt % (arch, build_os, spec.version()), packager.ensure_dir(tarfile(build_os, arch, spec))) repo = make_package(distro, build_os, arch, spec, srcdir) make_repo(repo, distro, build_os, spec) made_pkg = True if not made_pkg: raise Exception("No valid combination of distro and arch selected") finally: os.chdir(oldcwd)
def main(argv): distros=[EnterpriseDistro(distro) for distro in DISTROS] args = packager.get_args(distros, ARCH_CHOICES) spec = EnterpriseSpec(args.server_version, args.metadata_gitspec, args.release_number) oldcwd=os.getcwd() srcdir=oldcwd+"/../" # Where to do all of our work. Use a randomly-created directory if one # is not passed in. prefix = args.prefix if prefix is None: prefix=tempfile.mkdtemp() print "Working in directory %s" % prefix os.chdir(prefix) try: # Download the binaries. urlfmt="http://downloads.mongodb.com/linux/mongodb-linux-%s-enterprise-%s-%s.tgz" made_pkg = False # Build a package for each distro/spec/arch tuple, and # accumulate the repository-layout directories. for (distro, arch) in packager.crossproduct(distros, args.arches): for build_os in distro.build_os(arch): if build_os in args.distros or not args.distros: if args.tarball: filename = tarfile(build_os, arch, spec) packager.ensure_dir(filename) shutil.copyfile(args.tarball,filename) else: packager.httpget(urlfmt % (arch, build_os, spec.version()), packager.ensure_dir(tarfile(build_os, arch, spec))) repo = make_package(distro, build_os, arch, spec, srcdir) make_repo(repo, distro, build_os, spec) made_pkg = True if not made_pkg: raise Exception("No valid combination of distro and arch selected") finally: os.chdir(oldcwd)
def main(): """Execute Main program.""" distros = [EnterpriseDistro(distro) for distro in DISTROS] args = packager.get_args(distros, ARCH_CHOICES) spec = EnterpriseSpec(args.server_version, args.metadata_gitspec, args.release_number) oldcwd = os.getcwd() srcdir = oldcwd + "/../" # Where to do all of our work. Use a randomly-created directory if one # is not passed in. prefix = args.prefix if prefix is None: prefix = tempfile.mkdtemp() print("Working in directory %s" % prefix) os.chdir(prefix) try: made_pkg = False # Build a package for each distro/spec/arch tuple, and # accumulate the repository-layout directories. for (distro, arch) in packager.crossproduct(distros, args.arches): for build_os in distro.build_os(arch): if build_os in args.distros or not args.distros: filename = tarfile(build_os, arch, spec) packager.ensure_dir(filename) shutil.copyfile(args.tarball, filename) repo = make_package(distro, build_os, arch, spec, srcdir) make_repo(repo, distro, build_os) made_pkg = True if not made_pkg: raise Exception("No valid combination of distro and arch selected") finally: os.chdir(oldcwd)