@@ -128,54 +128,28 @@ function package($pkgfile = null)
128
128
$ pkgversion = ereg_replace ('[^a-zA-Z0-9._\-] ' , '_ ' , $ pkginfo ['version ' ]);
129
129
$ pkgver = $ pkgname . '- ' . $ pkgversion ;
130
130
131
- $ tmpdir = $ pwd . DIRECTORY_SEPARATOR . $ pkgver ;
132
- if (file_exists ($ tmpdir )) {
133
- return $ this ->raiseError ('Tmpdir: ' . $ tmpdir .' already exists ' ,
134
- null , PEAR_ERROR_TRIGGER , E_USER_ERROR );
135
- }
136
- if (!mkdir ($ tmpdir , 0700 )) {
137
- return $ this ->raiseError ("Unable to create temporary directory $ tmpdir. " ,
138
- null , PEAR_ERROR_TRIGGER , E_USER_ERROR );
139
- } else {
140
- $ this ->log (2 , "+ tmp dir created at: " . $ tmpdir );
141
- }
142
- $ this ->addTempFile ($ tmpdir );
131
+ // ----- Create the package file list
132
+ $ filelist = array ();
133
+ $ i = 0 ;
134
+
135
+ // ----- Add the package XML file
136
+ $ filelist [$ i ++] = $ pkgfile ;
143
137
144
138
// Copy files -----------------------------------------------
145
139
foreach ($ pkginfo ['filelist ' ] as $ fname => $ atts ) {
146
- $ file = $ tmpdir . DIRECTORY_SEPARATOR . $ fname ;
147
- $ dir = dirname ($ file );
148
- if (!@is_dir ($ dir )) {
149
- if (!$ this ->mkDirHier ($ dir )) {
150
- return $ this ->raiseError ("could not mkdir $ dir " );
151
- }
152
- }
153
- //Maintain original file perms
154
- $ orig_perms = @fileperms ($ fname );
155
- if (!@copy ($ fname , $ file )) {
156
- $ this ->log (0 , "could not copy $ fname to $ file " );
140
+ if (!file_exists ($ fname )) {
141
+ return $ this ->raiseError ("File $ fname does not exists " );
157
142
} else {
158
- $ this ->log (2 , "+ copying $ fname to $ file " );
159
- @chmod ($ file , $ orig_perms );
143
+ $ filelist [$ i ++] = $ fname ;
160
144
}
161
145
}
162
146
// XXX TODO: Rebuild the package file as the old method did?
163
147
164
- // This allows build packages from different pear pack def files
165
- $ dest_pkgfile = $ tmpdir . DIRECTORY_SEPARATOR . 'package.xml ' ;
166
- $ this ->log (2 , "+ copying package $ pkgfile to $ dest_pkgfile " );
167
- if (!@copy ($ pkgfile , $ dest_pkgfile )) {
168
- return $ this ->raiseError ("could not copy $ pkgfile to $ dest_pkgfile " );
169
- }
170
- @chmod ($ dest_pkgfile , 0644 );
171
-
172
148
// TAR the Package -------------------------------------------
173
- chdir (dirname ($ tmpdir ));
174
149
$ dest_package = $ this ->orig_pwd . DIRECTORY_SEPARATOR . "{$ pkgver }.tgz " ;
175
- $ this ->log (2 , "Attempting to pack $ tmpdir dir in $ dest_package " );
176
150
$ tar = new Archive_Tar ($ dest_package , true );
177
151
$ tar ->setErrorHandling (PEAR_ERROR_PRINT );
178
- if (!$ tar ->create ( $ pkgver )) {
152
+ if (!$ tar ->createModify ( $ filelist , $ pkgver )) {
179
153
return $ this ->raiseError ('an error ocurred during package creation ' );
180
154
}
181
155
$ this ->log (1 , "Package $ dest_package done " );
@@ -185,4 +159,4 @@ function package($pkgfile = null)
185
159
// }}}
186
160
}
187
161
188
- ?>
162
+ ?>
0 commit comments