@@ -121,16 +121,14 @@ function package($pkgfile = 'package.xml')
121
121
return $ pkginfo ;
122
122
}
123
123
// TMP DIR -------------------------------------------------
124
- $ pwd = getcwd ();
125
- $ new_pwd = dirname ($ pkgfile );
126
- // We allow calls like "pear package /home/cox/mypack/package.xml"
127
- if ($ new_pwd != '. ' ) {
128
- chdir ($ new_pwd );
129
- $ new_pwd = getcwd ();
130
- $ orig_pwd = $ pwd ;
131
- $ pwd = $ new_pwd ;
132
- $ pkgfile = basename ($ pkgfile );
124
+ $ orig_pwd = getcwd ();
125
+ // We allow calls like "pear package /home/user/mypack/package.xml"
126
+ if (!@chdir (dirname ($ pkgfile ))) {
127
+ return $ this ->raiseError ('Couldn \'t chdir to package.xml dir ' ,
128
+ null , PEAR_ERROR_TRIGGER , E_USER_ERROR );
133
129
}
130
+ $ pwd = getcwd ();
131
+ $ pkgfile = basename ($ pkgfile );
134
132
$ pkgver = $ pkginfo ['package ' ] . '- ' . $ pkginfo ['version ' ];
135
133
// don't want strange characters
136
134
$ pkgver = ereg_replace ('[^a-zA-Z0-9._-] ' , '_ ' , $ pkgver );
@@ -172,15 +170,15 @@ function package($pkgfile = 'package.xml')
172
170
173
171
// TAR the Package -------------------------------------------
174
172
chdir (dirname ($ this ->tmpdir ));
173
+ $ dest_package = $ orig_pwd . DIRECTORY_SEPARATOR . "$ {pkgver}.tgz " ;
175
174
// XXX FIXME Windows and non-GNU tar
176
- $ pwd = ( isset ( $ orig_pwd )) ? $ orig_pwd : $ pwd ;
177
- $ cmd = " tar -cvzf $ pwd / $ {pkgver} .tgz $ pkgver " ;
175
+ $ cmd = " tar -cvzf $ dest_package $ pkgver " ;
176
+ $ this -> log ( 2 , " + launched cmd: $ cmd " ) ;
178
177
// XXX TODO: add an extra param where to leave the package?
179
178
$ this ->log (1 , `$ cmd `);
180
- $ this ->log (1 , "Package $ pwd/ $ {pkgver}.tgz done " );
181
- if (isset ($ orig_pwd )) {
182
- chdir ($ orig_pwd );
183
- }
179
+ $ this ->log (1 , "Package $ dest_package done " );
180
+ chdir ($ orig_pwd );
181
+ return $ dest_package ;
184
182
}
185
183
186
184
/* XXXX REMOVEME: this is the old code
0 commit comments