示例#1
0
 public function testDebian()
 {
     $dest = new Dockerfile('debian', 'debian');
     $debian = new Debian($dest->grouping(true));
     $debian->install(array('pkg1'))->repo(['repo1' => null, 'repo2' => '1234'])->install(array('pkg2'))->pmsconf(['conf' => ['conf' => ['val1', 'val2']], 'pref' => ['pref1' => 'val1-1', 'pref2' => 'val2-1']])->install(array('pkg3'))->install(array('pkg4'))->pkgconf('pkg1')->pkgconf('pkg2', 'data')->pkgconf('pkg5', ['data' => 'data'])->ensureBash()->tz('Asia/Taipei');
     $expect = file_get_contents(__DIR__ . '/asset/Debian.update');
     $actual = $dest->generate();
     $this->assertEquals($expect, $actual);
 }
 public function installTo(Dockerfile $file)
 {
     $file->gStart(true);
     // install packages
     $pkgs = array('build-essential', 'php5-cli', 'php-pear', 'curl', 'wget', 'pkg-config');
     $pkgs = array_merge($pkgs, $this->pkgs($this->phpVer, $this->debianVer));
     $file->install($pkgs);
     // init env
     foreach ($this->init($this->phpVer, $this->debianVer) as $acts) {
         list($method, $arg) = $acts;
         call_user_func_array(array($file, $method), $arg);
     }
     $file->wget('https://s3-ap-northeast-1.amazonaws.com/phpbrew/travis-build/phpbrew', '/usr/local/bin/phpbrew')->chmod('a+x', '/usr/local/bin/phpbrew')->uStart($this->user)->shell('phpbrew init')->appendToFile('source ~/.phpbrew/bashrc', '~/.bashrc')->gReset();
     $args = array_unique($this->args());
     $variants = array();
     $extra = array();
     foreach ($args as $arg) {
         if (substr($arg, 0, 1) == '+') {
             $variants[] = $arg;
         } else {
             $extra[] = $arg;
         }
     }
     $opts = implode(' ', $variants);
     if (count($extra) > 0) {
         if ($opts != '') {
             $opts .= ' ';
         }
         $opts .= '-- ' . implode(' ', $extra);
     }
     $cmd = sprintf('phpbrew install %s %s', $this->phpVer, $opts);
     $file->shell('phpbrew update')->shell($cmd)->gReset()->shell('source ~/.phpbrew/bashrc')->shell('phpbrew switch $(phpbrew list|grep -vF system|head -n 1)')->shell('BINDIR=$(phpbrew path bin)')->shell('EXTDIR=$(phpbrew path ext)')->shell('ETCDIR=$(phpbrew path etc)');
     foreach ($this->post() as $entry) {
         list($method, $args) = $entry;
         call_user_func_array(array($file, $method), $args);
     }
     $file->gEnd()->uEnd();
 }