| from steps import step |
| import sh |
| |
| class GsutilSetup(step.Step): |
| def create_sstate_cache_dir(self): |
| """Creates the directory sstate-cache for fast cached builds""" |
| sh.mkdir("-p", f"build/{self.firmware_machine}/sstate-cache") |
| |
| def create_sources_dir(self): |
| """Creates the directory sources for mirror urls used for do_fetch during bitbake build""" |
| sh.mkdir("-p", "build/sources") |
| |
| def fetch_sstate_cache(self): |
| """Fetches the sstate_cache from Google Cloud Storage""" |
| cmd = "rsync" |
| bucket = f"gs://{self.gcs_bucket}/cache-unzip/{self.firmware_machine}" |
| sstate_cache_dir = f"build/{self.firmware_machine}/sstate-cache" |
| |
| self.gsutil(cmd, bucket, sstate_cache_dir) |
| |
| def fetch_sources(self): |
| """Fetches the mirror url sources from Google Cloud Storage""" |
| cmd = "rsync" |
| bucket = f"gs://{self.gcs_bucket}/sources" |
| sources_dir = "build/sources" |
| |
| self.gsutil(cmd, bucket, sources_dir) |
| |
| def chown_sstate_cache(self): |
| """Changes ownership of sstate-cache directory to user build""" |
| sh.chown("-R", "build", f"build/{self.firmware_machine}/sstate-cache") |
| |
| def run_script(self): |
| if self.use_cache: |
| self.create_sstate_cache_dir() |
| self.fetch_sstate_cache() |
| self.chown_sstate_cache() |
| |
| self.create_sources_dir() |
| self.fetch_sources() |