Skip to content

Commit 0584b21

Browse files
authored
Merge pull request microsoft#1819 from microsoft/sachinjoseph/normalizeChmodInTarHeader
Normalize chmod field in Tar header
2 parents 6a1cc8e + 18382ee commit 0584b21

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

apps/rush-lib/assets/rush-init/common/config/rush/experiments.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@
1212
* to temporarily restore the old behavior where everything must be rebuilt whenever pnpm-lock.json
1313
* is modified.
1414
*/
15-
/*[LINE "HYPOTHETICAL"]*/ "legacyIncrementalBuildDependencyDetection": true
15+
/*[LINE "HYPOTHETICAL"]*/ "legacyIncrementalBuildDependencyDetection": true,
16+
17+
/**
18+
* If true, the chmod field in temporary project tar headers will not be normalized.
19+
* This normalization can help ensure consistent tarball integrity across platforms.
20+
*/
21+
/*[LINE "HYPOTHETICAL"]*/ "noChmodFieldInTarHeaderNormalization": true
1622
}

apps/rush-lib/src/api/ExperimentsConfiguration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export interface IExperimentsJson {
1919
* instead of project-specific tracking.
2020
*/
2121
legacyIncrementalBuildDependencyDetection?: boolean;
22+
23+
/**
24+
* If true, the chmod field in temporary project tar headers will not be normalized.
25+
* This normalization can help ensure consistent tarball integrity across platforms.
26+
*/
27+
noChmodFieldInTarHeaderNormalization?: boolean;
2228
}
2329

2430
/**

apps/rush-lib/src/logic/InstallManager.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,22 @@ export class InstallManager {
744744
noMtime: true,
745745
noPax: true,
746746
sync: true,
747-
prefix: npmPackageFolder
747+
prefix: npmPackageFolder,
748+
filter: (path: string, stat: tar.FileStat): boolean => {
749+
if (!this._rushConfiguration.experimentsConfiguration.configuration
750+
.noChmodFieldInTarHeaderNormalization) {
751+
752+
stat.mode = (stat.mode & ~0x1FF) | PosixModeBits.AllRead | PosixModeBits.UserWrite
753+
| PosixModeBits.AllExecute;
754+
}
755+
756+
return true;
757+
}
748758
} as CreateOptions, [FileConstants.PackageJson]);
749759

750760
console.log(`Updating ${tarballFile}`);
751761
} catch (error) {
762+
console.log(colors.yellow(error));
752763
// delete everything in case of any error
753764
FileSystem.deleteFile(tarballFile);
754765
FileSystem.deleteFile(tempPackageJsonFilename);
@@ -1288,6 +1299,7 @@ export class InstallManager {
12881299

12891300
// Ensure that Rush's tarball dependencies get synchronized properly with the pnpm-lock.yaml file.
12901301
// See this GitHub issue: https://github.com/pnpm/pnpm/issues/1342
1302+
12911303
if (semver.gte(this._rushConfiguration.packageManagerToolVersion, '3.0.0')) {
12921304
args.push('--no-prefer-frozen-lockfile');
12931305
} else {

apps/rush-lib/src/schemas/experiments.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
"legacyIncrementalBuildDependencyDetection": {
1414
"description": "Rush 5.14.0 improved incremental builds to ignore spurious changes in the pnpm-lock.json file. This optimization is enabled by default. If you encounter a problem where \"rush build\" is neglecting to build some projects, please open a GitHub issue. As a workaround you can uncomment this line to temporarily restore the old behavior where everything must be rebuilt whenever pnpm-lock.json is modified.",
1515
"type": "boolean"
16+
},
17+
18+
"noChmodFieldInTarHeaderNormalization": {
19+
"description": "If true, the chmod field in temporary project tar headers will not be normalized. This normalization can help ensure consistent tarball integrity across platforms.",
20+
"type": "boolean"
1621
}
1722
},
1823
"additionalProperties": false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Fix an issue where the common/temp/*.tgz files resulted in different shrinkwrap files on different operating systems",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "sachinjoseph@users.noreply.github.com"
11+
}

common/reviews/api/rush-lib.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export interface IConfigurationEnvironmentVariable {
134134
// @beta
135135
export interface IExperimentsJson {
136136
legacyIncrementalBuildDependencyDetection?: boolean;
137+
noChmodFieldInTarHeaderNormalization?: boolean;
137138
}
138139

139140
// @public

0 commit comments

Comments
 (0)