/** * Clean-up the fixture */ public function cleanup() { Util::rm_rf($this->root); }
/** * Create a build instance * * @param string $cmVersion CyanogenMod version * @param string $device device codename * @param string $date build date in YYYYmmdd format * @param int $apiLevel build Android API level */ protected function createBuild($cmVersion, $device, $date, $apiLevel = 23) { $buildFilename = sprintf(self::BUILD_FILENAME_TEMPLATE, $cmVersion, $date, $device); $buildUrl = $this->urlBase . '/' . $device . '/' . $buildFilename; $changesPath = str_replace(".zip", ".changes", $buildUrl); // create the build md5sum $md5Sum = md5(Util::getRandomString(32)); // random timestamp on the build date $dateStamp = strtotime($date); $randomSeconds = mt_rand(0, 24 * 3600 - 1); $timestamp = $dateStamp + $randomSeconds; // random incremental $incremental = substr(md5($md5Sum), 0, 10); $channel = Api::CHANNEL_NIGHTLY; $build = new Build($buildUrl, $buildFilename, $timestamp, $md5Sum, $incremental, $changesPath, $channel, $apiLevel); $this->addBuild($device, $build); }
/** * Find builds for a device * * @param string $device device codename * @param string $channel update channel (nightly/snapshot/stable) */ protected function findBuilds($device, $channel = Api::CHANNEL_NIGHTLY) { $deviceDir = $this->root . DIRECTORY_SEPARATOR . $device; if (is_dir($deviceDir)) { $files = scandir($deviceDir); } else { $files = []; } $this->builds[$device] = []; foreach ($files as $filename) { $filePathRel = $device . DIRECTORY_SEPARATOR . $filename; $filePathFull = $this->getAbsPath($filePathRel); // only process ZIP files with the CM build prefix if (is_file($filePathFull) && substr($filename, 0, strlen(self::BUILD_PREFIX)) == self::BUILD_PREFIX && substr($filename, -4) == '.zip') { $buildUrl = $this->getUrl($filePathRel); $timestamp = Util::getTimeStamp($filePathFull); $md5sum = self::getMd5Sum($filePathFull); $apiLevel = self::getApiLevel($filePathFull); // incremental updates not implemented - using a random incremental hash $incremental = substr(md5($md5sum), 0, 10); $changesUrl = $this->getUrl($device . DIRECTORY_SEPARATOR . self::getChangesFilename($filename)); $build = new Build($buildUrl, $filename, $timestamp, $md5sum, $incremental, $changesUrl, $channel, $apiLevel); $this->builds[$device][] = $build; } } }