Changeset 2566:9bf417837888 for debian/mkdcl.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
debian/mkdcl.php
r0 r2566 5 5 { 6 6 public $f = 'debian/changelog'; 7 7 8 8 public function __construct() 9 9 { … … 12 12 } 13 13 } 14 14 15 15 private function readLastRevision() 16 16 { … … 18 18 $res = array(); 19 19 $done = false; 20 20 21 21 foreach ($f as $v) 22 22 { 23 23 $v = rtrim($v,"\n"); 24 24 25 25 # First line of a change 26 26 if (strpos($v,' ') !== 0 && trim($v) != '') … … 29 29 break; 30 30 } 31 31 32 32 $done = true; 33 33 $res = $this->getPackageInfo($v,$res[$i]); … … 44 44 } 45 45 } 46 46 47 47 return $res; 48 48 } 49 49 50 50 public function writeChangelog() 51 51 { 52 52 $ch = $this->readLastRevision(); 53 53 54 54 # Get debian revision 55 55 $rev = 1; … … 59 59 } 60 60 $rev++; 61 61 62 62 # Get SVN revision 63 63 $svnrev = isset($ch['keywords']['svnrev']) ? (integer) $ch['keywords']['svnrev'] : 1; 64 64 65 65 # Get current SVN revision 66 66 $currev = svnInfo::getCurrentRevision(); … … 68 68 return; 69 69 } 70 70 71 71 $changelog = ''; 72 72 $changes = svnInfo::getChangeLog($svnrev+1,$currev); … … 77 77 ', on '.date('r',strtotime($v['date']))."\n". 78 78 ' '.trim(preg_replace('/\n/ms',"\n ",$v['msg']))."\n\n"; 79 80 } 81 79 80 } 81 82 82 $res = 83 83 $ch['package'].' ('.$ch['version'].'-'.$rev.') '.$ch['dist'].'; urgency='.$ch['keywords']['urgency']. … … 87 87 ' -- '.$ch['maintainer']['name'].' <'.$ch['maintainer']['email'].'> '.date('r')."\n". 88 88 "\n"; 89 89 90 90 $old_changelog = file_get_contents($this->f); 91 91 $fp = fopen($this->f,'wb'); … … 93 93 fclose($fp); 94 94 } 95 95 96 96 private function getPackageInfo($l) 97 97 { … … 104 104 'maintainer' => array() 105 105 ); 106 106 107 107 $l = explode(';',$l); 108 108 109 109 # Info 110 110 $info = array_shift($l); … … 112 112 $res['version'] = strtok('()'); 113 113 $res['dist'] = trim(strtok(';')); 114 114 115 115 # Keywords 116 116 foreach ($l as $v) { … … 120 120 } 121 121 } 122 122 123 123 return $res; 124 124 } 125 125 126 126 private function getMaintainerInfo($l) 127 127 { … … 131 131 'date' => '' 132 132 ); 133 133 134 134 if (preg_match('/^ -- (.+?) <(.+?)> (.+?)$/',$l,$m)) { 135 135 $res['name'] = $m[1]; … … 137 137 $res['date'] = $m[3]; 138 138 } 139 139 140 140 return $res; 141 141 } … … 147 147 { 148 148 $info = `LANG=C svn info --xml`; 149 149 150 150 $x = @simplexml_load_string($info); 151 151 if (!$x) { 152 152 throw new Exception('Unable to get current SVN revision'); 153 153 } 154 154 155 155 $rev = $x->entry->commit['revision']; 156 156 157 157 if (!$rev) { 158 158 throw new Exception('Last revision number is invalid'); 159 159 } 160 160 161 161 return (integer) $rev; 162 162 } 163 163 164 164 public static function getChangeLog($fromrev,$torev) 165 165 { 166 166 $log = `LANG=C svn log --xml -r $fromrev:$torev`; 167 167 168 168 $x = @simplexml_load_string($log); 169 169 if (!$x) { 170 170 throw new Exception('Unable to open SVN log'); 171 171 } 172 172 173 173 $res = array(); 174 174 foreach ($x->logentry as $change) … … 180 180 ); 181 181 } 182 182 183 183 return $res; 184 184 }
Note: See TracChangeset
for help on using the changeset viewer.