def configure(self): self.db = self.require_one('pfa::database') self.postfix = self.require_one('postfix') self.provide('pfa', self) self.basedir = self.map('postfixadmin') download = Download( 'http://downloads.sourceforge.net/project/postfixadmin/' 'postfixadmin/postfixadmin-{}/postfixadmin-{}.tar.gz'.format( self.release, self.release), target='postfixadmin-{}.tar.gz'.format(self.release), checksum=self.checksum) self += download self += Extract(download.target, target='postfixadmin.orig') self += SyncDirectory(self.basedir, source=self.map( 'postfixadmin.orig/postfixadmin-{}'.format( self.release))) self += File(self.basedir + '/config.local.php', source=self.config) self.fpm = FPM('postfixadmin', adress=self.address) self += self.fpm
def test_dmg_does_not_support_strip(root): extract = Extract(resource_filename(__name__, "example.dmg"), strip=1, target="example") with pytest.raises(ValueError) as e: root.component += extract assert e.value.args[0] == "Strip is not supported by DMGExtractor"
def test_untar_can_strip_paths_off_archived_files(root): extract = Extract(resource_filename(__name__, "example.tar.gz"), target="example", strip=1) root.component += extract root.component.deploy() assert os.listdir(str(extract.target)) == ["bar"]
def test_missing_archive_predicts_change(root): extract = Extract("example.tar.gz") root.component += extract extractor = extract.sub_components[0] with pytest.raises(AssertionError): extractor.verify()
def configure(self): # This will manage central, version-specific virtualenv base # installations for multiple components to share. self.workdir = self.environment.workdir_base + '/.virtualenv' self += Download( self.expand(self.download_url), target=self.version + '.tar.gz', # so Extract knows what to do checksum=self.checksum) download = self._ extracted_dir = 'virtualenv-' + self.version self += Extract(download.target, target=extracted_dir, strip=1) self.venv_cmd = (self.workdir + '/' + extracted_dir + '/virtualenv.py')
def configure(self): download = Download( self.uri, checksum=self.checksum) self += download extract = Extract(download.target, strip=1) self += extract self += Configure(extract.target, args=self.configure_args, prefix=self.prefix, build_environment=self.build_environment) self += Make(extract.target, build_environment=self.build_environment)
def test_zip_overwrites_existing_files(root): extract = Extract(resource_filename(__name__, "example.zip"), target="example") root.component += extract target = "%s/mycomponent/example/foo/bar" % root.environment.workdir_base os.makedirs(target) filename = target + "/qux" open(filename, "w").write("foo") # Bypass verify (which would do nothing since the just written files # are newer than the zip file). XXX The API is a little kludgy here. extract.sub_components[0].update() assert "" == open(filename).read()
def configure(self): for name in self.packages: self += Package(name) self += Download(self.url.format(version=self.version), checksum=self.checksum) self += Extract(self._.target, strip=2, create_target_dir=False) self += Symlink('/usr/local/bin/soundjack', source=self.map('SJC%s' % self.version)) self += File('/lib/systemd/system/soundjack.service', source='soundjack.conf', is_template=False) self += SystemdConfig(self._)
def configure(self): self += Package('libssl-dev') self += Package('libcurl4-gnutls-dev') self += Download( self.url.format(version=self.version), checksum=self.checksum) src = self._.target.replace('.zip', '') self += Extract(self._.target, create_target_dir=False) self += Patch( src + '/esniper.c', source='#define MIN_BIDTIME 5', target='#define MIN_BIDTIME 2') self += Configure(src, prefix='/usr/local') self += Make(src)
def test_dmg_extracts_archive_to_target_directory(root): extract = Extract( resource_filename(__name__, "example.dmg"), target="example") root.component += extract root.component.deploy() assert sorted(os.listdir(str(extract.target))) == [ " ", "a\u0308sdf.txt", "example.app",] # ' ' is a symlink which stays one after copying: assert os.path.islink(extract.target + "/ ") start_bin = extract.target + "/example.app/MacOS/start.bin" with open(start_bin) as start_bin: assert start_bin.read() == "I start the example app! ;)"
def configure(self): self.db = self.require_one('roundcube::database') postfix = self.require_one('postfix') self.imap_host = postfix.connect.host self.smtp_server = postfix.connect.host self.smtp_port = postfix.connect.port self.basedir = self.map('roundcube') self.provide('roundcube', self) self += Directory('download') download = Download( 'http://downloads.sourceforge.net/project/roundcubemail/' 'roundcubemail/{}/roundcubemail-{}-complete.tar.gz'.format( self.release, self.release), target='download/roundcube-{}.tar.gz'.format(self.release), checksum=self.checksum) self += download self += Extract(download.target, target='roundcube.orig') self += SyncDirectory( self.basedir, source=self.map( 'roundcube.orig/roundcubemail-{}'.format(self.release))) self.db_dsnw = '{}://{}:{}@{}/{}'.format( self.db.dbms, self.db.username, self.db.password, self.db.address.connect.host, self.db.database) self += File( self.basedir + '/config/config.inc.php', source=self.config) self.fpm = FPM('roundcube', address=self.address) self += self.fpm self += RoundcubeInit(self)
def test_ignores_ctime_for_directories(root): # This is hard to test: ctime can not be changed directly, # we thus have to perform a somewhat elaborate dance to align # the starts as we wish. archive = resource_filename(__name__, "example.tar.gz") extract = Extract(archive, target="example") root.component += extract root.component.deploy() # No assertion raised, nothing to extract extract.extractor.verify() # Make the archive's ctime newer than the directories, but ensure # that the file is current (so only the archives _would_ trigger) # if we didn't filter them out properly. time.sleep(1.1) now = (time.time(), time.time()) os.utime(archive, now) os.utime(str(extract.target) + "/foo/bar/qux", now) # No assertion raised, still nothing to extract extract.extractor.verify()
def test_unknown_extension_raises(): extract = Extract("example.unknown") extract.workdir = "" with pytest.raises(ValueError): extract.configure()
def test_zip_extracts_archive_to_target_directory(root): extract = Extract(resource_filename(__name__, "example.zip"), target="example") root.component += extract root.component.deploy() assert os.listdir(str(extract.target)) == ["foo"]
def configure(self): self.provide('elasticsearch', self) download = Download(self.uri, checksum=self.checksum) self += download self += Extract(download.target, create_target_dir=False, strip=1)
def configure(self): self += Download(self.url, checksum=self.checksum) self += Extract(self._.target, strip=1, create_target_dir=False) for name in self.names: self += Symlink('/srv/prometheus/bin/%s' % name, source=self.map(name))