Exemplo n.º 1
0
    public function testComplex()
    {
        $spec = new Spec();
        $spec->setPackageName('simplepackage')->setVersion('1.0.0')->setRelease('1')->setSummary('test')->setGroup('group')->setLicense('GPL')->setUrl('url')->setBuildRequires('buildRequires')->setBuildArch('noarch')->setRequires('requires')->setDescription('Long..........
Very long')->setPrep('%autosetup -c package')->setBuild('')->setInstall('rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_libdir}/%{name}
cp -p binary %{buildroot}%{_bindir}/binary
cp -p src/* %{buildroot}%{_libdir}/%{name}/')->setFiles('%{buildroot}%{bindir}/binary
%{buildroot}%{_libdir}/%{name}/*')->setChangelog('- 1.0.0.');
        $this->assertEquals(<<<SPEC
Name: simplepackage
Version: 1.0.0
Release: 1
Summary: test
Group: group
License: GPL
URL: url
BuildRequires: buildRequires
BuildArch: noarch
Requires: requires

%description
Long..........
Very long

%prep
%autosetup -c package

%build


%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_libdir}/%{name}
cp -p binary %{buildroot}%{_bindir}/binary
cp -p src/* %{buildroot}%{_libdir}/%{name}/

%files
%{buildroot}%{bindir}/binary
%{buildroot}%{_libdir}/%{name}/*

%changelog
- 1.0.0.

SPEC
, (string) $spec);
    }
Exemplo n.º 2
0
 public function testSimple()
 {
     exec('command -v rpm', $output, $result);
     if (empty($output)) {
         $this->markTestSkipped('This test can not be performed on a system without rpm');
     }
     mkdir(__DIR__ . '/package/test', 0755, true);
     touch(__DIR__ . '/package/test/binary');
     chmod(__DIR__ . '/package/test/binary', 0755);
     mkdir(__DIR__ . '/package/test2');
     touch(__DIR__ . '/package/test2/abc');
     $spec = new Spec();
     $spec->setPackageName('test-s');
     $packager = new Packager();
     $packager->setSpec($spec);
     $packager->setOutputPath(__DIR__ . '/output');
     $packager->addMount(__DIR__ . '/package/', '/usr/share/test/');
     $packager->run();
     $this->assertEquals('%autosetup -c package', $spec->prep);
     $this->assertEquals('rm -rf %{buildroot}' . "\n" . 'mkdir -p %{buildroot}' . "\n" . 'cp -rp * %{buildroot}', $spec->install);
     $this->assertEquals('/usr/share/test/', $spec->files);
     $this->assertTrue(file_exists($_SERVER['HOME'] . '/rpmbuild/SPECS/test-s.spec'));
     $this->assertTrue(file_exists($_SERVER['HOME'] . '/rpmbuild/SOURCES/test-s.tar'));
     $phar = new PharData($_SERVER['HOME'] . '/rpmbuild/SOURCES/test-s.tar');
     $this->assertTrue(isset($phar['usr/share/test/test/binary']));
     $this->assertTrue(isset($phar['usr/share/test/test2/abc']));
     $command = $packager->build();
     $this->assertEquals('rpmbuild -bb ' . $_SERVER['HOME'] . '/rpmbuild/SPECS/test-s.spec', $command);
     exec($command, $_, $result);
     $this->assertEquals(0, $result);
     $this->assertTrue(file_exists($_SERVER['HOME'] . '/rpmbuild/RPMS/noarch/test-s-0.1-1.noarch.rpm'));
     $this->assertTrue($packager->movePackage(__DIR__ . '/test-s-0.1.rpm'));
     $this->assertTrue(file_exists(__DIR__ . '/test-s-0.1.rpm'));
     $expected_files = array('/usr/share/test', '/usr/share/test/test', '/usr/share/test/test/binary', '/usr/share/test/test2', '/usr/share/test/test2/abc');
     exec('rpm -qlp ' . __DIR__ . '/test-s-0.1.rpm', $actual_files, $_);
     $this->assertEquals($expected_files, $actual_files);
     unlink(__DIR__ . '/test-s-0.1.rpm');
     unlink($_SERVER['HOME'] . '/rpmbuild/SPECS/test-s.spec');
     unlink($_SERVER['HOME'] . '/rpmbuild/SOURCES/test-s.tar');
 }