Skip to content

Commit 8ebb121

Browse files
authored
Remove prebuilt nupkgs from the tarball. (#1348)
- Keep a list of packages that are detected as prebuilts even though they aren't used in the tarball build. - Delete these packages after doing the normal filtering. - Enforce zero prebuilts in build-source-tarball, with a whitelist in case we need to regress on prebuilts. * Add an option to skip zero prebuilt enforcement. * Don't fail on missing prebuilts
1 parent 379d4c7 commit 8ebb121

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

build-source-tarball.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ shift
1818
SKIP_BUILD=0
1919
INCLUDE_LEAK_DETECTION=0
2020
MINIMIZE_DISK_USAGE=0
21+
SKIP_PREBUILT_ENFORCEMENT=0
2122
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
2223

2324
while :; do
@@ -36,6 +37,9 @@ while :; do
3637
--minimize-disk-usage)
3738
MINIMIZE_DISK_USAGE=1
3839
;;
40+
--skip-prebuilt-check)
41+
SKIP_PREBUILT_ENFORCEMENT=1
42+
;;
3943
--)
4044
shift
4145
echo "Detected '--': passing remaining parameters '$@' as build.sh arguments."
@@ -173,6 +177,14 @@ find $TARBALL_ROOT/src \( -type f \( \
173177
-iname *.zip -o \
174178
-iname *.nupkg \) \) -exec rm {} \;
175179

180+
if [ $MINIMIZE_DISK_USAGE -eq 1 ]; then
181+
pushd "$TARBALL_ROOT/src"
182+
echo 'Removing unneeded files to trim tarball...'
183+
# we don't build CoreCLR tests right now and they have a lot of them - ~380MB
184+
rm -rf coreclr.*/tests
185+
popd
186+
fi
187+
176188
echo 'Copying sourcelink metadata to tarball...'
177189
pushd $SCRIPT_ROOT
178190
for srcDir in `find bin/src -name '.git' -type d`; do
@@ -289,6 +301,29 @@ do
289301
fi
290302
done
291303

304+
echo 'Removing known extra packages from tarball prebuilts...'
305+
while IFS= read -r packagePattern
306+
do
307+
if [[ "$packagePattern" =~ ^# ]]; then
308+
continue
309+
fi
310+
rm -f $TARBALL_ROOT/packages/prebuilt/$packagePattern
311+
done < $SCRIPT_ROOT/support/additional-prebuilts-to-delete.txt
312+
313+
if [ $SKIP_PREBUILT_ENFORCEMENT -ne 1 ]; then
314+
echo 'Checking for extra prebuilts...'
315+
for package in `ls -A $TARBALL_ROOT/packages/prebuilt`
316+
do
317+
if grep -q "$package" $SCRIPT_ROOT/support/allowed-prebuilts.txt; then
318+
echo "Allowing prebuilt $package"
319+
else
320+
echo "ERROR: $package is not in the allowed prebuilts list ($SCRIPT_ROOT/support/allowed-prebuilts.txt)"
321+
echo "Either remove this prebuilt, add it to the known extras list ($SCRIPT_ROOT/support/additional-prebuilts-to-delete.txt) or add it to the allowed prebuilts list."
322+
exit 1
323+
fi
324+
done
325+
fi
326+
292327
echo 'Removing source-built, previously source-built packages and reference packages from il pkg src...'
293328
OLDIFS=$IFS
294329

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# this is a list of packages that end up in the tarball's prebuilts folder but are not actually needed.
2+
# this is typically because part of the build are turned off for DotNetBuildOffline but not DotNetBuildFromSource.
3+
microsoft.dotnet.arcade.sdk.*.nupkg
4+
microsoft.diasymreader.pdb2pdb.*.nupkg
5+
microsoft.dotnet.signtool.*.nupkg
6+
sn.1.0.0.nupkg
7+
vswhere.2.6.7.nupkg
8+
system.text.encoding.codepages.4.3.0.nupkg
9+
system.text.encoding.codepages.4.5.1.nupkg
10+
system.threading.tasks.dataflow.4.5.24.nupkg
11+
runtime.*.runtime.native.system.security.cryptography.apple.*.nupkg
12+
runtime.*.runtime.native.system.security.cryptography.openssl.*.nupkg
13+
system.text.json.1.0.0.nupkg
14+
system.xml.xpath.4.3.0.nupkg
15+
microsoft.codeanalysis.csharp.2.9.0.nupkg
16+
system.xml.xpath.xdocument.4.3.0.nupkg
17+
microsoft.codeanalysis.common.2.9.0.nupkg
18+
microsoft.codeanalysis.analyzers.2.6.1.nupkg
19+
system.valuetuple.4.3.0.nupkg
20+
microsoft.dotnet.genapi.*.nupkg
21+
system.runtime.compilerservices.unsafe.4.5.0.nupkg
22+
runtime.linux-x64.microsoft.netcore.dotnetapphost.*.nupkg
23+
runtime.linux-x64.microsoft.netcore.dotnethostresolver.*.nupkg
24+
runtime.linux-x64.microsoft.netcore.dotnethostpolicy.*.nupkg
25+
runtime.linux-x64.microsoft.netcore.dotnethost.*.nupkg
26+
microsoft.netcore.app.host.linux-x64.3.0.0.nupkg
27+
system.composition.runtime.1.0.31.nupkg
28+
system.composition.hosting.1.0.31.nupkg
29+
system.composition.typedparts.1.0.31.nupkg
30+
system.composition.convention.1.0.31.nupkg
31+
system.composition.attributedmodel.1.0.31.nupkg
32+
microsoft.visualstudio.setup.configuration.interop.1.16.30.nupkg
33+
microsoft.net.compilers.toolset.*.nupkg

support/allowed-prebuilts.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)