def create(self): """ Creates the repository on disk including the keystore. This also sets the public key and fingerprint for :param repo. Because some keystore types (e.g. PKCS12) don't support different passwords for store and key, we give them the same password. We still treat them differently to support former versions of Repomaker which used different passwords but did not work with all types of keystores. """ self.key_store_pass = common.genpassword() self.key_pass = self.key_store_pass self.chdir() config = self.get_config() # Ensure icon directories exist for icon_dir in update.get_all_icon_dirs(REPO_DIR): if not os.path.exists(icon_dir): os.makedirs(icon_dir) # Generate keystore pubkey, fingerprint = common.genkeystore(config) self.public_key = pubkey self.fingerprint = fingerprint.replace(" ", "") # Generate and save QR Code self._generate_qrcode() # Generate repository website self._generate_page() self.save()
def create(self): """ Creates the repository on disk including the keystore. This also sets the public key and fingerprint for :param repo. """ self.key_store_pass = common.genpassword() self.key_pass = common.genpassword() self.chdir() config = self.get_config() # Ensure icon directories exist for icon_dir in update.get_all_icon_dirs(REPO_DIR): if not os.path.exists(icon_dir): os.makedirs(icon_dir) # Generate keystore pubkey, fingerprint = common.genkeystore(config) self.public_key = pubkey self.fingerprint = fingerprint.replace(" ", "") # Generate and save QR Code self._generate_qrcode() # Generate repository website self._generate_page() self.save()
def test_icons_get_deleted_from_repo(self): # create the repository environment fake_repo_create(self.apk_pointer.repo) self.apk_pointer.apk = self.apk self.apk_pointer.apk.version_code = 1137 # List with icon directories icon_name = \ self.apk_pointer.apk.package_id + "." + str(self.apk_pointer.apk.version_code) + ".png" for icon_directory in get_all_icon_dirs(self.repo.get_repo_path()): icon = os.path.join(icon_directory, icon_name) with open(icon, 'wb') as f: f.write(b'foo') # Check that icons exist self.assertTrue(os.path.isfile(icon)) # Delete app icons self.apk_pointer.delete() for icon_directory in get_all_icon_dirs(self.repo.get_repo_path()): icon = os.path.join(icon_directory, icon_name) # Check that icons do not exist self.assertFalse(os.path.isfile(icon))
def fake_repo_create(repo): # copy existing keystore src = os.path.join(settings.TEST_FILES_DIR, 'keystore.jks') dest = os.path.join(repo.get_private_path(), 'keystore.jks') if not os.path.isdir(repo.get_private_path()): os.makedirs(repo.get_private_path()) copyfile(src, dest) repo.key_store_pass = '******' repo.key_pass = '******' # make sure that icon directories exist for icon_dir in update.get_all_icon_dirs(repo.get_repo_path()): if not os.path.exists(icon_dir): os.makedirs(icon_dir)
def delete_app_icons_from_repo(self): # Build icon name icon_name = self.apk.package_id + "." + str( self.apk.version_code) + ".png" # Get path of repository path = self.repo.get_repo_path() # List with icon directories icon_directories = get_all_icon_dirs(path) for icon_directory in icon_directories: icon = os.path.join(icon_directory, icon_name) try: if self.app and self.app.icon and icon == self.app.icon.path: continue # do not delete current app icon except App.DoesNotExist: pass # if the app already was deleted, we need to remove the icons if os.path.isfile(icon): os.remove(icon)