How to use prepare_installation method in localstack

Best Python code snippet using localstack_python

osxpkg.py

Source:osxpkg.py Github

copy

Full Screen

...274 output = os.path.join(PACKAGES_DIR, f"{name}.pkg")275 args += [output]276 check_call(args)277 return output278def pkgbuild_prepare_installation(info):279 pkg = pkgbuild(280 "prepare_installation",281 identifier=info.get("reverse_domain_identifier"),282 version=info["version"],283 install_location=info.get("default_location_pkg"),284 )285 approx_pkgs_size_kb = approx_size_kb(info, "pkgs")286 if approx_pkgs_size_kb <= 0:287 return pkg288 # We need to patch the estimated install size because it's initially289 # set to the sum of the compressed tarballs, which is not representative290 try:291 # expand to apply patches292 check_call(["pkgutil", "--expand", pkg, f"{pkg}.expanded"])293 payload_xml = os.path.join(f"{pkg}.expanded", "PackageInfo")294 tree = ET.parse(payload_xml)295 root = tree.getroot()296 payload = root.find("payload")297 payload.set("installKBytes", str(approx_pkgs_size_kb))298 tree.write(payload_xml)299 # repack300 check_call(["pkgutil", "--flatten", f"{pkg}.expanded", pkg])301 return pkg302 finally:303 shutil.rmtree(f"{pkg}.expanded")304def pkgbuild_script(name, info, src, dst='postinstall', **kwargs):305 fresh_dir(SCRIPTS_DIR)306 fresh_dir(PACKAGE_ROOT)307 move_script(join(OSX_DIR, src), join(SCRIPTS_DIR, dst), info, **kwargs)308 pkgbuild(309 name,310 identifier=info.get("reverse_domain_identifier"),311 install_location=info.get("default_location_pkg"),312 )313 rm_rf(SCRIPTS_DIR)314def create(info, verbose=False):315 global CACHE_DIR, PACKAGE_ROOT, PACKAGES_DIR, SCRIPTS_DIR316 CACHE_DIR = info['_download_dir']317 SCRIPTS_DIR = join(CACHE_DIR, "scripts")318 PACKAGE_ROOT = join(CACHE_DIR, "package_root")319 PACKAGES_DIR = join(CACHE_DIR, "built_pkgs")320 fresh_dir(PACKAGES_DIR)321 prefix = join(PACKAGE_ROOT, info.get("pkg_name", info['name']).lower())322 # We need to split tasks in sub-PKGs so the GUI allows the user to enable/disable323 # the ones marked as optional. Optionality is controlled in modify_xml() by324 # patching the XML blocks corresponding to each sub-PKG name.325 # See http://stackoverflow.com/a/11487658/161801 for how all this works.326 # 1. Prepare installation327 # The 'prepare_installation' package contains the prepopulated package cache, the modified328 # conda-meta metadata staged into pkgs/conda-meta, conda.exe,329 # Optionally, extra files and the user-provided scripts.330 # We first populate PACKAGE_ROOT with everything needed, and then run pkg build on that dir331 fresh_dir(PACKAGE_ROOT)332 fresh_dir(SCRIPTS_DIR)333 pkgs_dir = join(prefix, 'pkgs')334 os.makedirs(pkgs_dir)335 preconda.write_files(info, pkgs_dir)336 preconda.copy_extra_files(info, prefix)337 # These are the user-provided scripts, maybe patched to have a shebang338 # They will be called by a wrapping script added later, if present339 if info.get('pre_install'):340 move_script(341 abspath(info['pre_install']),342 abspath(join(pkgs_dir, 'user_pre_install')),343 info,344 ensure_shebang=True,345 )346 if info.get('post_install'):347 move_script(348 abspath(info['post_install']),349 abspath(join(pkgs_dir, 'user_post_install')),350 info,351 ensure_shebang=True,352 )353 all_dists = info["_dists"].copy()354 for env_info in info.get("_extra_envs_info", {}).values():355 all_dists += env_info["_dists"]356 all_dists = list({dist: None for dist in all_dists}) # de-duplicate357 for dist in all_dists:358 os.link(join(CACHE_DIR, dist), join(pkgs_dir, dist))359 shutil.copyfile(info['_conda_exe'], join(prefix, "conda.exe"))360 # Sign conda-standalone so it can pass notarization361 notarization_identity_name = info.get('notarization_identity_name')362 if notarization_identity_name:363 with NamedTemporaryFile(suffix=".plist", delete=False) as f:364 plist = {365 "com.apple.security.cs.allow-jit": True,366 "com.apple.security.cs.allow-unsigned-executable-memory": True,367 "com.apple.security.cs.disable-executable-page-protection": True,368 "com.apple.security.cs.disable-library-validation": True,369 "com.apple.security.cs.allow-dyld-environment-variables": True,370 }371 plist_dump(plist, f)372 check_call(373 [374 # hardcode to system location to avoid accidental clobber in PATH375 "/usr/bin/codesign",376 "--verbose",377 '--sign', notarization_identity_name,378 "--prefix", info.get("reverse_domain_identifier", info['name']),379 "--options", "runtime",380 "--force",381 "--entitlements", f.name,382 join(prefix, "conda.exe"),383 ]384 )385 os.unlink(f.name)386 # This script checks to see if the install location already exists and/or contains spaces387 # Not to be confused with the user-provided pre_install!388 move_script(join(OSX_DIR, 'checks_before_install.sh'), join(SCRIPTS_DIR, 'preinstall'), info)389 # This script populates the cache, mainly390 move_script(join(OSX_DIR, 'prepare_installation.sh'), join(SCRIPTS_DIR, 'postinstall'), info)391 pkgbuild_prepare_installation(info)392 names = ['prepare_installation']393 # 2. (Optional) Run user-provided pre-install script394 # The preinstall script is run _after_ the tarballs have been extracted!395 if info.get('pre_install'):396 pkgbuild_script(397 'user_pre_install', info, 'run_user_script.sh', user_script_type='pre_install'398 )399 names.append('user_pre_install')400 # 3. Run the installation401 # This script-only package will run conda to link and install the packages402 pkgbuild_script('run_installation', info, 'run_installation.sh')403 names.append('run_installation')404 # 4. The user-supplied post-install script405 if info.get('post_install'):...

Full Screen

Full Screen

command.py

Source:command.py Github

copy

Full Screen

...106 def restore_partitions(self):107 """108 Override this to restore the backup performed earlier.109 """110 def prepare_installation(self):111 # TODO: migrate to here the miscellaneous steps in112 # do_first_install up to running the actions113 # tune2fs wants /etc/mtaFirst install a in order to run:114 # creating it if it is missing115 self.hardware.create_mtab()116 # In case booting detected a swap partition and enabled it,117 # disable all swap now so hard disks are not used anymore118 self.hardware.disable_swap()119 # Umount all partitions from the target drives120 self.system.umount_partitions_target_drives()121 def add_additional_environment(self) -> Dict[str, str]:122 """123 Override this method to add extra environment variables when running124 actions125 """126 return {}127 def run_actions(self):128 # TODO: as a first step, write a script that loads common.sh and129 # runs all actions and run it with subprocess130 env = os.environ.copy()131 env["DISK_ROOT"] = self.system.disk_root.name132 env["DISK_INST"] = self.system.disk_inst.name133 if self.system.LABELS["root"] in self.system.partitions:134 env["PART_ROOT"] = self.system.partitions[135 self.system.LABELS["root"]].dev136 if self.system.LABELS["log"] in self.system.partitions:137 env["PART_LOG"] = self.system.partitions[138 self.system.LABELS["log"]].dev139 if self.system.LABELS["esp"] in self.system.partitions:140 env["PART_ESP"] = self.system.partitions[141 self.system.LABELS["esp"]].dev142 env["ACTIONS"] = "{}".format(" ".join(self.action_list))143 env.update(self.add_additional_environment())144 for action in self.action_list:145 try:146 self.actions.run_action(action)147 except exceptions.ActionNotImplementedError:148 subprocess.run([149 '/usr/sbin/modian-run-action',150 action151 ], env=env, check=True)152 def main(self):153 self.setup()154 self.system.detect()155 self.log_detection_report()156 self.action_list = self.system.compute_actions()157 self.backup_partitions()158 self.prepare_installation()159 self.run_actions()...

Full Screen

Full Screen

installClam.py

Source:installClam.py Github

copy

Full Screen

...28def install_clam(args):29 app.print_verbose("Install antivirus (clamav and freshclam).")30 version_obj = version.Version("InstallClamAntiVirus", SCRIPT_VERSION)31 version_obj.check_executed()32 prepare_installation()33 download_and_install()34 setup_clam_and_freshclam()35 setup_crontab()36 setup_autostart_and_start()37 version_obj.mark_executed()38def is_user_installed(username):39 '''40 Check if linux user is installed.41 '''42 for line in open("/etc/passwd"):43 if username in line:44 return True45 return False46def prepare_installation():47 #48 app.print_verbose(" Create user")49 if not is_user_installed("clamav"):50 x("/usr/sbin/adduser clamav --shell=/dev/null")51 #52 app.print_verbose("Make the Pid and Socket directory")53 x("mkdir -p /var/run/clamav")54 x("chown clamav:clamav /var/run/clamav")55 x("chmod 700 /var/run/clamav")56 #57 app.print_verbose(" Create log diretories")58 x("mkdir -p /var/log/clamav")59 x("touch /var/log/clamav/freshclam.log")60 x("touch /var/log/clamav/clamd.log")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful