def process(self): super(BootstrapArgParser, self).process() self.createDir(self.deviceDir) self.config = self.configTreeParser.parseJSON(self.args["base"]) if self.config.get("__config__") is None: sys.stderr.write( "You are using an outdated config tree. Please run 'incept sync -v VARIANT_CODE' or set __config__ (see https://goo.gl/aFWPby)\n" ) sys.exit(1) self.configDir = self.config.getSource(getDir=True) baseCodePath = "/".join(self.args["base"].split(".")[:2]) self.variantDir = os.path.join(self.deviceDir, baseCodePath, self.args["variant"]) logger.info("Writing new config") self.newConfig = self.createNewConfig( self.args["base"] + "." + self.args["variant"], self.args["variant"], self.config) self.setupDirPaths() self.createDirs() #self.unpackimg(bootImg, self.bootDir, self.config["tools"]["unpackbootimg"], "boot") unpackerKey, unpacker = self.config.getHostBinary("unpackbootimg") bootImg = self.config.getProperty("boot.img", None) if bootImg and self.config.get("boot.__make__", False): if type(bootImg.getValue()) is str: logger.info("Unpacking boot img") self.unpackimg( bootImg.getConfig().resolveRelativePath( bootImg.getValue()), self.bootDir, unpacker, "boot") recoveryImg = self.config.getProperty("recovery.img", None) if recoveryImg and self.config.get("recovery.__make__", False): if type(recoveryImg.getValue()) is str: logger.info("Unpacking recovery img") self.unpackimg( recoveryImg.getConfig().resolveRelativePath( recoveryImg.getValue()), self.recoveryDir, unpacker, "recovery") if any((self.args["learn_settings"], self.args["learn_partitions"], self.args["learn_props"], self.args["learn_imgs"])): syncer = ConfigSyncer(self.newConfig) if self.args["learn_settings"]: logger.info("pulling settings") syncer.applyDiff(syncer.pullAndDiff()) if self.args["learn_partitions"]: logger.info("pulling partitions info") syncer.syncPartitions(True) if self.args["learn_props"]: logger.info("pulling props") syncer.syncProps(True) if self.args["learn_imgs"]: imgsDir = os.path.join(self.variantDir, "imgs") os.makedirs(imgsDir) if self.newConfig.getMountConfig("recovery.dev"): logger.info("pulling recovery.img") syncer.syncImg( "recovery.img", self.newConfig.getMountConfig("recovery.dev"), imgsDir, self.variantDir) else: logger.warn( "__config__.target.mount.recovery.dev not set, not syncing recovery.img" ) if self.newConfig.getMountConfig("boot.dev"): logger.info("pulling boot.img") syncer.syncImg("boot.img", self.newConfig.getMountConfig("boot.dev"), imgsDir, self.variantDir) else: logger.warn( "__config__.target.mount.boot.dev not set, not syncing boot.img" ) configPath = self.writeNewConfig(self.args["variant"]) logger.info("Created %s" % configPath) return True
def learnPartitions(self): syncer = ConfigSyncer(self.config) return syncer.syncPartitions()
def process(self): super(BootstrapArgParser, self).process() self.createDir(self.deviceDir) self.config = self.configTreeParser.parseJSON(self.args["base"]) self.configDir = self.config.getSource(getDir=True) baseCodePath= "/".join(self.args["base"].split(".")[:2]) self.variantDir = os.path.join(self.deviceDir, baseCodePath, self.args["variant"]) logger.info("Writing new config") self.newConfig = self.createNewConfig(self.args["base"] + "." + self.args["variant"], self.args["variant"], self.config) self.setupDirPaths() self.createDirs() #self.unpackimg(bootImg, self.bootDir, self.config["tools"]["unpackbootimg"], "boot") unpackerProperty = self.config.getProperty("common.tools.unpackbootimg.bin") unpacker = unpackerProperty.getConfig().resolveRelativePath(unpackerProperty.getValue()) bootImg = self.config.getProperty("boot.img", None) if bootImg and self.config.get("boot.__make__", False): if type(bootImg.getValue()) is str: logger.info("Unpacking boot img") self.unpackimg(bootImg.getConfig().resolveRelativePath(bootImg.getValue()), self.bootDir, unpacker, "boot") recoveryImg = self.config.getProperty("recovery.img", None) if recoveryImg and self.config.get("recovery.__make__", False): if type(recoveryImg.getValue()) is str: logger.info("Unpacking recovery img") self.unpackimg(recoveryImg.getConfig().resolveRelativePath(recoveryImg.getValue()), self.recoveryDir, unpacker, "recovery") if any((self.args["learn_settings"], self.args["learn_partitions"], self.args["learn_props"], self.args["learn_imgs"])): syncer = ConfigSyncer(self.newConfig) if self.args["learn_settings"]: logger.info("pulling settings") syncer.applyDiff(syncer.pullAndDiff()) if self.args["learn_partitions"]: logger.info("pulling partitions info") syncer.syncPartitions(True) if self.args["learn_props"]: logger.info("pulling props") syncer.syncProps(True) if self.args["learn_imgs"]: imgsDir = os.path.join(self.variantDir, "imgs") os.makedirs(imgsDir) if self.newConfig.get("recovery.dev"): logger.info("pulling recovery.img") syncer.syncImg("recovery.img", self.newConfig.get("recovery.dev"), imgsDir, self.variantDir) else: logger.warn("recovery.dev not set, not syncing recovery.img") if self.newConfig.get("boot.dev"): logger.info("pulling boot.img") syncer.syncImg("boot.img", self.newConfig.get("boot.dev"), imgsDir, self.variantDir) else: logger.warn("boot.dev not set, not syncing boot.img") self.writeNewConfig(self.args["variant"]) self.writeCmdLog(os.path.join(self.variantDir, "bootstrap.commands.log")) return True
def process(self): super(BootstrapArgParser, self).process() self.createDir(self.deviceDir) self.config = self.configTreeParser.parseJSON(self.args["base"]) if self.config.get("__config__") is None: sys.stderr.write( "You are using an outdated config tree. Please run 'incept sync -v VARIANT_CODE' or set __config__ (see https://goo.gl/aFWPby)\n" ) sys.exit(1) self.configDir = self.config.getSource(getDir=True) baseCodePath = "/".join(self.args["base"].split(".")[:2]) self.variantDir = os.path.join(self.deviceDir, baseCodePath, self.args["variant"]) logger.info("Writing new config") self.newConfig = self.createNewConfig( self.args["base"] + "." + self.args["variant"], self.args["variant"], self.config ) self.setupDirPaths() self.createDirs() # self.unpackimg(bootImg, self.bootDir, self.config["tools"]["unpackbootimg"], "boot") unpackerKey, unpacker = self.config.getHostBinary("unpackbootimg") bootImg = self.config.getProperty("boot.img", None) if bootImg and self.config.get("boot.__make__", False): if type(bootImg.getValue()) is str: logger.info("Unpacking boot img") self.unpackimg( bootImg.getConfig().resolveRelativePath(bootImg.getValue()), self.bootDir, unpacker, "boot" ) recoveryImg = self.config.getProperty("recovery.img", None) if recoveryImg and self.config.get("recovery.__make__", False): if type(recoveryImg.getValue()) is str: logger.info("Unpacking recovery img") self.unpackimg( recoveryImg.getConfig().resolveRelativePath(recoveryImg.getValue()), self.recoveryDir, unpacker, "recovery", ) if any( ( self.args["learn_settings"], self.args["learn_partitions"], self.args["learn_props"], self.args["learn_imgs"], ) ): syncer = ConfigSyncer(self.newConfig) if self.args["learn_settings"]: logger.info("pulling settings") syncer.applyDiff(syncer.pullAndDiff()) if self.args["learn_partitions"]: logger.info("pulling partitions info") syncer.syncPartitions(True) if self.args["learn_props"]: logger.info("pulling props") syncer.syncProps(True) if self.args["learn_imgs"]: imgsDir = os.path.join(self.variantDir, "imgs") os.makedirs(imgsDir) if self.newConfig.getMountConfig("recovery.dev"): logger.info("pulling recovery.img") syncer.syncImg( "recovery.img", self.newConfig.getMountConfig("recovery.dev"), imgsDir, self.variantDir ) else: logger.warn("__config__.target.mount.recovery.dev not set, not syncing recovery.img") if self.newConfig.getMountConfig("boot.dev"): logger.info("pulling boot.img") syncer.syncImg("boot.img", self.newConfig.getMountConfig("boot.dev"), imgsDir, self.variantDir) else: logger.warn("__config__.target.mount.boot.dev not set, not syncing boot.img") configPath = self.writeNewConfig(self.args["variant"]) logger.info("Created %s" % configPath) return True