@@ -16,11 +16,6 @@ interface CaptureOptions {
16
16
silent ?: boolean
17
17
}
18
18
19
- interface DpkgConfig {
20
- excludes : RegExp [ ] ;
21
- includes : RegExp [ ] ;
22
- }
23
-
24
19
async function capture ( cmd : string , options ?: CaptureOptions ) : Promise < string > {
25
20
let output = ''
26
21
@@ -175,90 +170,6 @@ export async function latest_version(version_prefix: string): Promise<string> {
175
170
} )
176
171
}
177
172
178
- function glob_to_regex ( glob : string ) : RegExp {
179
- return new RegExp ( glob
180
- . replace ( / \. / g, '\\.' )
181
- . replace ( / \* / g, '.*' )
182
- . replace ( / \? / g, '.' )
183
- ) ;
184
- }
185
-
186
- function list_files_in_dir ( directory : string , files : string [ ] = [ ] ) : string [ ] {
187
- fs . readdirSync ( directory ) . forEach ( file => {
188
- const p = path . join ( directory , file ) ;
189
- if ( fs . statSync ( p ) . isDirectory ( ) ) {
190
- return list_files_in_dir ( p , files ) ;
191
- } else {
192
- return files . push ( p ) ;
193
- }
194
- } ) ;
195
-
196
- return files ;
197
- }
198
-
199
- function dpkg_read_config ( ) : DpkgConfig {
200
- const dpkgConfigFilepath = 'excludes' ;
201
- const dpkgConfigDirPath = 'excludes.d' ;
202
-
203
- const configs = list_files_in_dir ( dpkgConfigDirPath , [ dpkgConfigFilepath ] ) ;
204
-
205
- const dpkgConfig : DpkgConfig = {
206
- excludes : [ ] ,
207
- includes : [ ] ,
208
- } ;
209
-
210
- configs . forEach ( ( config ) => {
211
- try {
212
- const dpkgExcludesFile = fs . readFileSync ( config , 'utf8' ) ;
213
- dpkgExcludesFile . split ( '\n' ) . forEach ( ( line ) => {
214
- // Exclude
215
- const excludePattern = 'path-exclude=' ;
216
- if ( line . startsWith ( excludePattern ) ) {
217
- const regex = glob_to_regex ( line . substring ( excludePattern . length ) ) ;
218
- dpkgConfig . excludes . push ( regex ) ;
219
- return ;
220
- }
221
-
222
- // Include
223
- const includePattern = 'path-include=' ;
224
- if ( line . startsWith ( includePattern ) ) {
225
- const regex = glob_to_regex ( line . substring ( includePattern . length ) ) ;
226
- dpkgConfig . includes . push ( regex ) ;
227
- return ;
228
- }
229
- } ) ;
230
- } catch ( err ) {
231
- core . info ( `dpkg excludes file not available: ${ err } ` ) ;
232
- }
233
- } ) ;
234
-
235
- return dpkgConfig ;
236
- }
237
-
238
- function dpkg_is_file_included ( dpkgConfig : DpkgConfig , filepath : string ) : boolean {
239
- var included = true ;
240
-
241
- dpkgConfig . excludes . forEach ( ( exclude ) => {
242
- if ( exclude . test ( filepath ) ) {
243
- included = false ;
244
- return ;
245
- }
246
- } ) ;
247
-
248
- if ( included ) {
249
- return true ;
250
- }
251
-
252
- dpkgConfig . includes . forEach ( ( include ) => {
253
- if ( include . test ( filepath ) ) {
254
- included = true ;
255
- return ;
256
- }
257
- } ) ;
258
-
259
- return included ;
260
- } ;
261
-
262
173
async function run_linux ( ) : Promise < void > {
263
174
try {
264
175
const distro = await lsb_release ( )
@@ -323,12 +234,10 @@ async function run_linux(): Promise<void> {
323
234
core . info ( 'Caching APT packages: ' + dpkg_diff . join ( ', ' ) )
324
235
325
236
for ( const pkg of dpkg_diff ) {
326
- const dpkgConfig = dpkg_read_config ( ) ;
327
237
const output = await capture ( `sudo dpkg -L ${ pkg } ` , { silent : true } )
328
238
const files : Array < string > = output
329
239
. split ( '\n' )
330
240
. filter ( f => fs . statSync ( f ) . isFile ( ) )
331
- . filter ( f => dpkg_is_file_included ( dpkgConfig , f ) )
332
241
for ( const f of files ) {
333
242
const dest = path . join ( cache_dir , path . dirname ( f ) )
334
243
await io . mkdirP ( dest )
0 commit comments