daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def install_package(self, *args):
  2.     """
  3.     Builds and installs the package via makepkg and pacman.
  4.     Pass additional parameters for pacman via *args.
  5.  
  6.     Exceptions: Exceptions.InvalidInput,
  7.                 Exceptions.ConnectionProblem
  8.  
  9.     :param args:    e.g. "--asdeps", "--needed"
  10.     """
  11.  
  12.     pacman_prefix = " ".join(args)
  13.     if self.package_base_name is None:
  14.         logging.info("base package name not known")
  15.         raise Exceptions.InvalidInput("base package name not known")
  16.  
  17.     package_dir = os.path.join(Package.cache_dir, self.package_base_name)
  18.  
  19.     # if new pkgbuild
  20.     if self.fetch_pkgbuild():
  21.         if not self.show_pkgbuild_to_user():
  22.             logging.info("PKGBUILD not okay!")
  23.             raise Exceptions.InvalidInput("PKGBUILD not okay!")
  24.  
  25.     # check if build needed
  26.     build_version = self.version_from_srcinfo()
  27.     files_in_build_dir = [f for f in os.listdir(package_dir) if os.path.isfile(os.path.join(package_dir, f))]
  28.     install_file = None
  29.     for file in files_in_build_dir:
  30.         if file.startswith(self.name + "-" + build_version) and file.endswith(".pkg.tar"):
  31.             install_file = file
  32.             break
  33.  
  34.     if install_file is None:
  35.         build_needed = True
  36.     else:
  37.         build_needed = False
  38.  
  39.     # build
  40.     if build_needed:
  41.         if subprocess.run("makepkg -Cc --noconfirm", shell=True, cwd=package_dir).returncode != 0:
  42.             logging.info("build failed")
  43.             raise Exceptions.InvalidInput("build failed")
  44.  
  45.         # get name of install file
  46.         build_version = self.version_from_srcinfo()
  47.         files_in_build_dir = [f for f in os.listdir(package_dir) if os.path.isfile(os.path.join(package_dir, f))]
  48.         install_file = None
  49.         for file in files_in_build_dir:
  50.             if file.startswith(self.name + "-" + build_version) and file.endswith(".pkg.tar"):
  51.                 install_file = file
  52.                 break
  53.  
  54.         if install_file is None:
  55.             logging.info("install file not available")
  56.             raise Exceptions.InvalidInput("install file not available")
  57.  
  58.     # install
  59.     if subprocess.run("sudo pacman --noconfirm " + pacman_prefix + " -U " + install_file, shell=True,
  60.                       cwd=package_dir).returncode != 0:
  61.         logging.info("install failed")
  62.         raise Exceptions.InvalidInput("install failed")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top