@@ -2,12 +2,19 @@ import { constants, promises as fs } from 'fs';
2
2
import path from 'path' ;
3
3
import rimraf from 'rimraf' ;
4
4
import { promisify } from 'util' ;
5
- import { execFile as execFileFn , generateDirFromTemplate , sanitizeVersion } from './helpers' ;
5
+ import { execFile as execFileFn , generateDirFromTemplate , sanitizeVersion , getManSection } from './helpers' ;
6
6
import { PackageInformation } from './package-information' ;
7
7
import { Arch , getRPMArchName } from '../../config' ;
8
8
9
9
const { COPYFILE_FICLONE } = constants ;
10
10
11
+ interface InstallFile {
12
+ fromFilename : string ;
13
+ toFilename : string ;
14
+ category : 'man' | 'bin' | 'libexec' ;
15
+ mode : string ;
16
+ }
17
+
11
18
/**
12
19
* Creates an RPM archive.
13
20
*/
@@ -23,10 +30,26 @@ export async function createRedhatPackage(
23
30
// this package contains both Apache-2.0 and non-free software.
24
31
// https://fedoraproject.org/wiki/Packaging:LicensingGuidelines#Multiple_Licensing_Scenarios
25
32
const licenseRpm = pkg . binaries . map ( ( { license } ) => license . rpmIdentifier ) . join ( ' and ' ) ;
26
- // Put the binaries in their expected locations.
27
- const installscriptRpm = pkg . binaries . map ( ( { sourceFilePath, category } ) =>
28
- `mkdir -p %{buildroot}/%{_${ category } dir}\n` +
29
- `install -m 755 ${ path . basename ( sourceFilePath ) } %{buildroot}/%{_${ category } dir}/${ path . basename ( sourceFilePath ) } ` )
33
+ // Put buildroot files in their expected locations. This includes the binary files
34
+ // and the man page.
35
+ const installFiles : InstallFile [ ] = pkg . binaries . map ( ( { sourceFilePath, category } ) =>
36
+ ( {
37
+ fromFilename : path . basename ( sourceFilePath ) ,
38
+ toFilename : path . basename ( sourceFilePath ) ,
39
+ category,
40
+ mode : '755'
41
+ } ) ) ;
42
+ if ( pkg . manpage ) {
43
+ installFiles . push ( {
44
+ fromFilename : pkg . manpage . packagedFilePath ,
45
+ toFilename : `man${ getManSection ( pkg . manpage . packagedFilePath ) } /${ pkg . manpage . packagedFilePath } ` ,
46
+ category : 'man' ,
47
+ mode : '644'
48
+ } ) ;
49
+ }
50
+ const installscriptRpm = installFiles . map ( ( { fromFilename, toFilename, category, mode } ) =>
51
+ `mkdir -p %{buildroot}/%{_${ category } dir}/${ path . dirname ( toFilename ) } \n` +
52
+ `install -m ${ mode } ${ fromFilename } %{buildroot}/%{_${ category } dir}/${ toFilename } ` )
30
53
. join ( '\n' ) ;
31
54
// Add binaries to the package, and list license and other documentation files.
32
55
// rpm will automatically put license and doc files in the directories where
@@ -38,7 +61,7 @@ export async function createRedhatPackage(
38
61
...pkg . otherDocFilePaths . map ( ( { packagedFilePath } ) => `%doc ${ packagedFilePath } ` ) ,
39
62
] ;
40
63
if ( pkg . manpage ) {
41
- filelistRpm . push ( `%doc ${ pkg . manpage . packagedFilePath } ` ) ;
64
+ filelistRpm . push ( `%{_mandir}/man ${ getManSection ( pkg . manpage . packagedFilePath ) } / ${ pkg . manpage . packagedFilePath } ` ) ;
42
65
}
43
66
const version = sanitizeVersion ( pkg . metadata . version , 'rpm' ) ;
44
67
const dir = await generateDirFromTemplate ( templateDir , {
0 commit comments