def build_packages(options, args=None): """Build RPM and/or deb packages""" if not args: print "To build packages you must specifiy either 'rpm', " \ "'deb', or 'all'" exit(0) if args[0] not in ['rpm', 'deb', 'all']: raise Exception("Packge type must be rpm, deb, or all") if 'rpm' in args or 'all' in args: # Since we need to cd to build rpms, we call this sh script cmd = ['tools/build_rpms.sh'] for package in BASE_PACKAGES + PLUGINS: print "Building %s rpm" % package pcmd = deepcopy(cmd) pcmd.append(package) install_venv.run_command(pcmd) print "done." if 'deb' in args or 'all' in args: cmd = ['tools/build_debs.sh'] for p in BASE_PACKAGES + PLUGINS: print "Building %s deb" % p pcmd = deepcopy(cmd) pcmd.append(p) install_venv.run_command(pcmd) print "done."
def install_packages(options, args=None): """Builds and installs packages""" # Start building a command list cmd = ['pip', 'install'] # If no options, just a regular install. If venv, create, prepare and # install in venv. If --user install in user's local dir. Usually # ~/.local/ if options.venv: if install_venv.VENV_EXISTS: print "Virtual-env exists" else: install_venv.create_virtualenv(install_pip=False) install_venv.install_dependencies() cmd.extend(['-E', install_venv.VENV]) elif options.user: cmd.append('--user') # Install packages # TODO(Tyler) allow users to pass in packages in cli for package in BASE_PACKAGES + PLUGINS: print "Installing %s" % package # Each package needs its own command list, and it needs the path # in the correct place (after "pip install") pcmd = deepcopy(cmd) pcmd.insert(2, path.join(ROOT, clean_path(package))) if package is 'server': pcmd.append("--install-option=--install-scripts=%s" %\ script_dir()) print pcmd install_venv.run_command(pcmd) print "done."
def build_packages(options, args=None): """Build RPM and/or deb packages""" # If we weren't given a package type, default to rpm if not args: args = ["rpm"] if args[0] not in ["rpm", "deb", "all"]: raise Exception("Packge type must be rpm, deb, or all") # Since we need to cd to build rpms, we call this sh script cmd = ["tools/build_rpms.sh"] for package in BASE_PACKAGES + PLUGINS: print "Building %s rpm" % package pcmd = deepcopy(cmd) pcmd.append(package) install_venv.run_command(pcmd) print "done." # If we're only building rpms we're done if args[0] is "rpm": return # Use alien to build debs from the rpms alien, fakeroot = check_deb_build_dependencies() cmd = ["tools/build_debs.sh"] if fakeroot: cmd.insert(0, "fakeroot") try: for p in BASE_PACKAGES + PLUGINS: print "Building %s deb" % p pcmd = deepcopy(cmd) pcmd.append(p) install_venv.run_command(pcmd) print "done." except: print "You must be root or install fakeroot"
def check_deb_build_dependencies(): alien = bool(install_venv.run_command(["which", "alien"], check_exit_code=False)) fakeroot = bool(install_venv.run_command(["which", "fakeroot"], check_exit_code=False)) if not alien: raise Exception("You must have alien installed to build debs") return (alien, fakeroot)
def uninstall_packages(options, args=None): """Removes packages""" cmd = ["pip", "uninstall", "-y"] for package in ["quantum-" + x.split("/")[-1] for x in BASE_PACKAGES + PLUGINS]: print "Uninstalling %s" % package # Each package needs its own command list, and it needs the path # in the correct place (after "pip uninstall" pcmd = deepcopy(cmd) pcmd.insert(2, package) print pcmd install_venv.run_command(pcmd) print "done."
def install_packages(options, args=None): """Builds and installs packages""" # Start building a command list cmd = ['python'] # If no options, just a regular install. If venv, create, prepare and # install in venv. If --user install in user's local dir. Usually # ~/.local/ if options.venv: if install_venv.VENV_EXISTS: print "Virtual-env exists" else: install_venv.create_virtualenv(install_pip=False) install_venv.install_dependencies() cmd.insert(0, "tools/with_venv.sh") # Install packages # TODO(Tyler) allow users to pass in packages in cli for package in BASE_PACKAGES + PLUGINS: print "Installing %s" % package # Each package needs its own command list, and it needs the path # in the correct place (after "pip install") pcmd = deepcopy(cmd) pcmd.extend(["setup_%s.py" % package, "install"]) if options.venv: pcmd.append("--root=%s" % install_venv.VENV) if options.user: pcmd.append('--user') if package is 'client': pcmd.append("--install-scripts=%s" % script_dir()) if package is 'server': pcmd.append("--install-scripts=%s" % script_dir()) pcmd.append("--install-data=%s" % etc_dir()) print pcmd install_venv.run_command(pcmd) print "done."
def clean_packages(options, args): """Cleans build packages""" cmd = ["tools/clean.sh"] install_venv.run_command(cmd)