Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compile liblzma for Windows #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions .azure-pipelines-shared.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
steps:
- task: DownloadBuildArtifacts@0
displayName: Download Build Artifacts
inputs:
artifactName: nuget
downloadPath: $(Build.ArtifactStagingDirectory)
- download: current
artifact: nuget
- bash: |
set -e
export PATH="$PATH:/$HOME/.dotnet/tools"

mkdir test-$(command)/
cd test-$(command)

echo "<configuration><packageSources><add key='local' value='$(Build.ArtifactStagingDirectory)/nuget' /></packageSources></configuration>" > NuGet.config
version=$(cat $(Build.ArtifactStagingDirectory)/nuget/version.txt)
echo "<configuration><packageSources><add key='local' value='$(Pipeline.Workspace)/nuget' /></packageSources></configuration>" > NuGet.config
version=$(cat $(Pipeline.Workspace)/nuget/version.txt)

# Install the dotnet-$(command) tool
dotnet tool install --global dotnet-$(command) --version $version --add-source $(Build.ArtifactStagingDirectory)/nuget
dotnet tool install --global dotnet-$(command) --version $version --add-source $(Pipeline.Workspace)/nuget

# Create a new console application
dotnet new console
Expand All @@ -25,7 +22,5 @@ steps:
dotnet $(command) -o $(Build.ArtifactStagingDirectory)/packages/$(container)
workingDirectory: $(Pipeline.Workspace)
displayName: Run dotnet $(command)
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/packages/
artifactName: packages
- publish: $(Build.ArtifactStagingDirectory)/packages/
artifact: packages
51 changes: 32 additions & 19 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ resources:
stages:
- stage: Build
jobs:
- job: build_native
container:
image: ubuntu:18.04
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
steps:
- script: |
/tmp/docker exec -t -u 0 ci-container \
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
displayName: Set up sudo
- bash: |
sudo apt-get update
sudo apt-get install -y wget build-essential mingw-w64
- bash: |
wget http://tukaani.org/xz/xz-5.2.4.tar.gz -O- | tar xfz -
cd xz*
./autogen.sh --host=x86_64-w64-mingw32
./configure --host=x86_64-w64-mingw32
make
DESTDIR=$(Build.ArtifactStagingDirectory) make install
- publish: $(Build.ArtifactStagingDirectory)
artifact: native
- job: build
container: 3.0-buster
steps:
Expand All @@ -24,10 +45,8 @@ stages:
cp demo/Directory.Build.props $(Build.ArtifactStagingDirectory)
cp demo/version.txt $(Build.ArtifactStagingDirectory)
displayName: Build
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: nuget
- publish: $(Build.ArtifactStagingDirectory)
artifact: nuget

- stage: Test
jobs:
Expand Down Expand Up @@ -87,23 +106,20 @@ stages:
molecule --version
ansible --version
displayName: Install molecule
- task: DownloadBuildArtifacts@0
displayName: Download Build Artifacts
inputs:
artifactName: nuget
downloadPath: $(Build.ArtifactStagingDirectory)
- download: current
artifact: nuget
- bash: |
set -e
export PATH="$PATH:/$HOME/.dotnet/tools"

cd $(suite)-app

echo "<configuration><packageSources><add key='local' value='$(Build.ArtifactStagingDirectory)/nuget' /></packageSources></configuration>" > NuGet.config
version=$(cat $(Build.ArtifactStagingDirectory)/nuget/version.txt)
echo "<configuration><packageSources><add key='local' value='$(Pipeline.Workspace)/nuget' /></packageSources></configuration>" > NuGet.config
version=$(cat $(Pipeline.Workspace)/nuget/version.txt)

# Install the dotnet-rpm and dotnet-deb tools
dotnet tool install --global dotnet-deb --version $version --add-source $(Build.ArtifactStagingDirectory)/nuget
dotnet tool install --global dotnet-rpm --version $version --add-source $(Build.ArtifactStagingDirectory)/nuget
dotnet tool install --global dotnet-deb --version $version --add-source $(Pipeline.Workspace)/nuget
dotnet tool install --global dotnet-rpm --version $version --add-source $(Pipeline.Workspace)/nuget

# Create .deb and .rpm packages
dotnet rpm install
Expand Down Expand Up @@ -145,19 +161,16 @@ stages:
vmImage: 'macOS-10.14'
dependsOn: build_macos
steps:
- task: DownloadBuildArtifacts@0
displayName: Download Build Artifacts
inputs:
artifactName: packages
downloadPath: $(Build.ArtifactStagingDirectory)/
- download: current
artifact: packages
- task: UseDotNet@2
displayName: 'Use .NET Core 3.0'
inputs:
packageType: sdk
version: 3.0.100
- bash: |
set -e
tar xvzf $(Build.ArtifactStagingDirectory)/packages/macos/test-tarball.1.0.0.tar.gz
tar xvzf $(Pipeline.Workspace)/packages/macos/test-tarball.1.0.0.tar.gz
displayName: Extract tarball
- bash: |
set -e
Expand Down
2 changes: 1 addition & 1 deletion Packaging.Targets/ArchiveBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected void AddFile(string entry, string relativePath, string prefix, List<Ar
byte[] buffer = new byte[1024];
bool isAscii = true;

var fileMetadata = metadata.SingleOrDefault(m => m.IsPublished() && string.Equals(relativePath, m.GetPublishedPath()));
var fileMetadata = metadata?.SingleOrDefault(m => m.IsPublished() && string.Equals(relativePath, m.GetPublishedPath()));

using (Stream fileStream = File.OpenRead(entry))
{
Expand Down
16 changes: 13 additions & 3 deletions Packaging.Targets/Rpm/RpmPackageCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,10 @@ public void CreatePackage(
byte[] nameBytes = new byte[66];
var nameInLead = includeVersionInName ? $"{name}-{version}-{release}" : name;

Encoding.UTF8.GetBytes(nameInLead, 0, nameInLead.Length, nameBytes, 0);
if (nameInLead != null)
{
Encoding.UTF8.GetBytes(nameInLead, 0, nameInLead.Length, nameBytes, 0);
}

var lead = new RpmLead()
{
Expand Down Expand Up @@ -475,7 +478,7 @@ public void CreatePackage(
{
using (XZOutputStream compressor = new XZOutputStream(
targetStream,
XZOutputStream.DefaultThreads,
this.CompressionThreads,
XZOutputStream.DefaultPreset,
leaveOpen: true))
{
Expand Down Expand Up @@ -894,7 +897,14 @@ protected void CalculateSectionOffsets<T>(Section<T> section, Func<T, int> getSo
break;

case IndexType.RPM_STRING_TYPE:
size = Encoding.UTF8.GetByteCount((string)record.Value.Value) + 1;
if (record.Value.Value == null)
{
size += 1;
}
else
{
size = Encoding.UTF8.GetByteCount((string)record.Value.Value) + 1;
}
break;

case IndexType.RPM_INT16_TYPE:
Expand Down
Binary file modified Packaging.Targets/runtimes/win7-x64/native/lzma.dll
Binary file not shown.