OSDN Git Service

- package.xml生成スクリプト改善(ethnaコマンドインストール対応など)
[ethna/ethna.git] / bin / ethna_make_package.php
1 <?php
2 /**
3  *      make_package.php
4  *
5  *  package.xml generator for Ethna
6  *
7  *      @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
8  *      @package        Ethna
9  *      @version        $Id$
10  */
11 include_once('PEAR.php');
12 include_once('Console/Getopt.php');
13 include_once('PEAR/PackageFileManager2.php');
14 include_once('PEAR/PackageFileManager/File.php');   // avoid bugs
15
16 // args
17 $getopt =& new Console_Getopt();
18 $arg_list = $getopt->readPHPArgv();
19 $state = "stable";
20 $is_old_package = false;
21 $get_version = false;
22
23 $r = $getopt->getopt($arg_list, "abov", array("alpha", "beta", "old-package", "version"));
24 foreach ($r[0] as $opt) {
25     if ($opt[0] == "a" || $opt[0] == "--alpha") {
26         $state = "alpha";
27     }
28     if ($opt[0] == "b" || $opt[0] == "--beta") {
29         $state = "beta";
30     }
31     if ($opt[0] == "o" || $opt[0] == "--old-package") {
32         $is_old_package = true;
33     }
34     if ($opt[0] == "v" || $opt[0] == "--version") {
35         $get_version = true;
36     }
37 }
38
39 $description = 'Ethna Web Application Framework';
40 $package = 'Ethna';
41
42 // x.0.y -> beta
43 // x.1.y -> stable
44 $major_version = "2.0";
45 $minor_version = "1";
46
47 if ($state == 'alpha' || $state == 'beta') {
48     $version = $major_version . strftime('.%Y%m%d%H');
49 } else {
50     $version = $major_version . "." . $minor_version;
51 }
52
53 if ($get_version) {
54     print $version;
55     exit();
56 }
57
58 $config = array(
59     'baseinstalldir' => 'Ethna',
60     'packagedirectory' => dirname(dirname(__FILE__)),
61     'filelistgenerator' => 'file',
62     'ignore' => array('CVS/', 'package.xml', 'ethna_make_package.php', 'ethna_make_package.sh'),
63     'changelogoldtonew' => false,
64     'exceptions' => array('README' => 'doc', 'LICENSE' => 'doc', 'CHANGES' => 'doc'),
65     'description' => $description,
66     'installexceptions' => array('bin/ethna.sh' => '/', 'bin/ethna.bat' => '/'),
67     'installas' => array('bin/ethna.sh' => 'ethna'),
68 );
69  
70 $packagexml = new PEAR_PackageFileManager2();
71 $packagexml->setOptions($config);
72 $packagexml->setPackage($package);
73 $packagexml->setSummary('Ethna PHP Framework Package');
74 $packagexml->setDescription($description);
75 $packagexml->setChannel('pear.ethna.jp');
76 $packagexml->setAPIVersion($version);
77 $packagexml->setReleaseVersion($version);
78 $packagexml->setReleaseStability($state);
79 $packagexml->setAPIStability($state);
80 $packagexml->setNotes('2.0.1 would be brand-new package');
81 $packagexml->setPackageType('php');
82
83 $packagexml->addRole('tpl', 'php');
84 $packagexml->addRole('ethna', 'php');
85 $packagexml->addRole('sh', 'script');
86 $packagexml->addRole('bat', 'script');
87
88 $packagexml->setPhpDep('4.1.0');
89 $packagexml->setPearinstallerDep('1.3.5');
90
91 $packagexml->addMaintainer('lead', 'fujimoto' , 'Masaki Fujimoto', 'fujimoto@php.net');
92 $packagexml->addMaintainer('lead', 'halt' , 'halt feits', 'halt.hde@gmail.com');
93 $packagexml->addMaintainer('lead', 'cocoitiban', 'Keita Arai', 'cocoiti@comio.info');
94
95 $packagexml->setLicense('The BSD License', 'http://www.opensource.org/licenses/bsd-license.php');
96
97 $packagexml->addReplacement('bin/ethna.bat', 'pear-config', '@PHP-BIN@', 'php_bin');
98 $packagexml->addReplacement('bin/ethna.sh', 'pear-config', '@PHP-BIN@', 'php_bin');
99
100 $packagexml->addRelease();
101 $packagexml->setOSInstallCondition('windows');
102 $packagexml->addInstallAs('bin/ethna.bat', 'ethna');
103 $packagexml->addIgnoreToRelease('bin/ethna.sh');
104 $packagexml->addRelease();
105 $packagexml->addInstallAs('bin/ethna.sh', 'ethna');
106 $packagexml->addIgnoreToRelease('bin/ethna.bat');
107
108 $packagexml->generateContents();
109
110 if ($is_old_package) {
111     $pkg =& $packagexml->exportCompatiblePackageFile1();
112     $pkg->writePackageFile();
113 } else {
114     $packagexml->writePackageFile();
115 }
116 ?>