This repository has been archived by the owner on Mar 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initializeoffline.sh
executable file
·117 lines (101 loc) · 4.31 KB
/
initializeoffline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Run from root directory of linux-offline-packaging-roslyn
# Script variables
generate_essentials_tar_xz=false
# Check if user needs to generate Essentials.tar.xz
if [ "$1" == "--generate-essentials-archive" ]; then
generate_essentials_tar_xz=true
echo "--generate-essentials-archive invoked"
fi
# Source ./eng/common/tools.sh
echo "- Sourcing ./roslyn/eng/common/tools.sh..."
echo " - . ./roslyn/eng/common/tools.sh"
. ./roslyn/eng/common/tools.sh
# Check for components inside ./offline folder
echo "- Checking ./offline/ folder to see if required components exist..."
# .dotnet
echo " - .dotnet/..."
if [ ! -e "./offline/.dotnet" ]; then
echo " - .dotnet/ not found. creating..."
mkdir "./offline/.dotnet"
fi
# .dotnet/dotnet-install.sh
echo " - .dotnet/dotnet-install.sh"
if [ ! -e "./offline/.dotnet/dotnet-install.sh" ]; then
echo " - .dotnet/dotnet-install.sh not found. downloading..."
wget --continue --output-document="./offline/.dotnet/dotnet-install.sh" "https://dot.net/v1/dotnet-install.sh"
fi
# .dotnet/dep/
echo " - .dotnet/dep/..."
if [ ! -e "./offline/.dotnet/dep/" ]; then
echo " - .dotnet/dep/ not found. creating..."
mkdir "./offline/.dotnet/dep"
fi
# .dotnet/dep/Sdk
echo " - .dotnet/dep/Sdk/..."
if [ ! -e "./offline/.dotnet/dep/Sdk/" ]; then
echo " - .dotnet/dep/Sdk/ not found. creating..."
mkdir "./offline/.dotnet/dep/Sdk"
fi
# .dotnet/dep/Sdk/${dotnet_sdk_version}
ReadGlobalVersion "dotnet"
dotnet_sdk_version=$_ReadGlobalVersion
echo " - .dotnet/dep/Sdk/${dotnet_sdk_version}..."
if [ ! -e "./offline/.dotnet/dep/Sdk/${dotnet_sdk_version}/" ]; then
echo " - .dotnet/dep/Sdk/${dotnet_sdk_version} not found. creating..."
mkdir "./offline/.dotnet/dep/Sdk/${dotnet_sdk_version}"
fi
# Check for required files
echo "- Determining what files to download..."
# .dotnet/dep/Sdk/${dotnet_sdk_version}/dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz
echo " - .dotnet/dep/Sdk/${dotnet_sdk_version}/dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz..."
if [ ! -e "./offline/.dotnet/dep/Sdk/${dotnet_sdk_version}/dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz" ]; then
echo " - dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz not found. downloading..."
wget --continue --output-document="./offline/.dotnet/dep/Sdk/${dotnet_sdk_version}/dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz" "https://dotnetcli.azureedge.net/dotnet/Sdk/${dotnet_sdk_version}/dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz"
fi
# Copy required files from offline to roslyn
echo "- Copying .dotnet..."
echo " - cp -R offline/.dotnet roslyn/"
cp -R offline/.dotnet roslyn/
# Patch tools.sh to use "--azure-feed "$root/dep" --uncached-feed "$root/dep""
echo "- Patching tools.sh..."
echo " - patch -i offline/offline.patch roslyn/eng/common/tools.sh"
patch -i offline/offline.patch roslyn/eng/common/tools.sh
# Restore packages
echo "- Restoring packages..."
echo " - cd roslyn"
cd roslyn
echo " - HOME=`pwd`/nuget ./build.sh --restore --configuration Release"
HOME=`pwd`/nuget ./build.sh --restore --configuration Release
if [ "$?" -ne 0 ]; then
exit $?
fi
# Copy dependencies to roslyn/deps
echo "- Copying dependencies to roslyn/deps..."
echo " - mkdir deps"
mkdir deps
echo " - cp -R ./nuget/.nuget/packages/* ./deps/"
cp -R ./nuget/.nuget/packages/* ./deps/
# Compressing essential packages
if [ ${generate_essentials_tar_xz} == true ]; then
echo "- Compressing essential packages to Essentials.tar..."
echo " - tar cfv ../Essentials.tar deps"
tar cfv ../Essentials.tar deps
echo " - xz -9 ../Essentials.tar"
xz -9 ../Essentials.tar
fi
# Patch NuGet.config for offline use
echo "- Patching NuGet.config..."
echo " - patch -i ../offline/nuget.patch NuGet.config"
patch -i ../offline/nuget.patch NuGet.config
# Cleaning up
echo "- Cleaning up..."
echo " - rm -R artifacts"
rm -R artifacts
echo " - rm -R nuget"
rm -R nuget
echo "- Build using \"./roslyn/build.sh --restore --configuration Release\" from the \"roslyn\" directory."
echo "- For Launchpad PPAs and general Ubuntu package builds, change \"preview\" in \"debian/changelog\" to \"focal\" or any Ubuntu codename."
echo "- You may want to run \"dch -U\" to sign your custom roslyn package changelog."
echo "- Use \"debuild -S -sa\" to build source package for \"sbuild\"."
echo "- Undo patches once done."