Merge branch 'master' of github.com:jedisct1/libsodium

* 'master' of github.com:jedisct1/libsodium:
  Hard to keep track of everyone
  Remove extra character in the list of sumo symbols for the js builds
  Update packaging for .NET Core (#566)
This commit is contained in:
Frank Denis 2017-07-12 20:31:55 +02:00
commit b456ff2886
7 changed files with 126 additions and 54 deletions

16
THANKS
View File

@ -1,13 +1,17 @@
@alethia7 @alethia7
@artemisc
@carblue @carblue
@dnaq @dnaq
@ektrah @ektrah
@graxrabble
@harleqin @harleqin
@joshjdevl @joshjdevl
@jrmarino @jrmarino
@jshahbazi @jshahbazi
@lvh @lvh
@neheb @neheb
Adam Caudill (@adamcaudill)
Alexander Morris (@alexpmorris) Alexander Morris (@alexpmorris)
Amit Murthy (@amitmurthy) Amit Murthy (@amitmurthy)
Andrew Bennett (@potatosalad) Andrew Bennett (@potatosalad)
@ -16,6 +20,8 @@ Bruce Mitchener (@waywardmonkeys)
Bruno Oliveira (@abstractj) Bruno Oliveira (@abstractj)
Caolan McMahon (@caolan) Caolan McMahon (@caolan)
Chris Rebert (@cvrebert) Chris Rebert (@cvrebert)
Christian Hermann (@bitbeans)
Christian Wiese (@morfoh)
Christian Wiese (@morfoh) Christian Wiese (@morfoh)
Colm MacCárthaigh (@colmmacc) Colm MacCárthaigh (@colmmacc)
David Parrish (@dmp1ce) David Parrish (@dmp1ce)
@ -29,7 +35,9 @@ Farid Hajji (@fhajji)
Frank Siebenlist (@franks42) Frank Siebenlist (@franks42)
Gabriel Handford (@gabriel) Gabriel Handford (@gabriel)
Geo Carncross (@geocar) Geo Carncross (@geocar)
Henrik Gassmann (BurningEnlightenment)
Jachym Holecek (@freza) Jachym Holecek (@freza)
Jack Wink (@jackwink)
James Ruan (@jamesruan) James Ruan (@jamesruan)
Jan de Muijnck-Hughes (@jfdm) Jan de Muijnck-Hughes (@jfdm)
Jason McCampbell (@jasonmccampbell) Jason McCampbell (@jasonmccampbell)
@ -53,17 +61,21 @@ Rudolf Von Krugstein (@rudolfvonkrugstein)
Samuel Neves (@sneves) Samuel Neves (@sneves)
Scott Arciszewski (@paragonie-scott) Scott Arciszewski (@paragonie-scott)
Stanislav Ovsiannikov (@naphaso) Stanislav Ovsiannikov (@naphaso)
Stefan Marsiske Stefan Marsiske (@stef)
Stephan Touset (@stouset) Stephan Touset (@stouset)
Stephen Chavez (@redragonx)
Steve Gibson (@sggrc) Steve Gibson (@sggrc)
Tony Arcieri (@bascule) Tony Arcieri (@bascule)
Tony Garnock-Jones (@tonyg) Tony Garnock-Jones (@tonyg)
Y. T. Chung (@zonyitoo) Y. T. Chung (@zonyitoo)
Bytecurry Software Bytecurry Software
Cisco
Coverity, Inc. Coverity, Inc.
Cryptotronix Cryptotronix
FSF France FSF France
MaidSafe MaidSafe
OVH OVH
OpenDNS, Inc. Paragonie Initiative Enterprises
Python Cryptographic Authority

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,9 @@
This directory contains scripts and files to package libsodium for .NET Core. This directory contains scripts and files to package libsodium for .NET Core.
*Note:* The NuGet package is intended for the implementation of language
bindings such as [NSec](https://github.com/ektrah/nsec). It does not provide a
.NET API itself.
In .NET Core, it is customary to provide pre-compiled binaries for all platforms In .NET Core, it is customary to provide pre-compiled binaries for all platforms
as NuGet packages. The purpose of the `prepare.py` script in this directory is as NuGet packages. The purpose of the `prepare.py` script in this directory is
to generate a `Makefile` that downloads and builds libsodium binaries for a to generate a `Makefile` that downloads and builds libsodium binaries for a
@ -17,25 +21,39 @@ See `prepare.py` for the complete list of supported platforms.
The metadata for the NuGet package is located in `libsodium.props`. The metadata for the NuGet package is located in `libsodium.props`.
**Making a pre-release** **Versioning**
1. Run `python3 prepare.py 1.0.13-preview-01` to generate the `Makefile`. Version numbers for the packages for .NET Core consist of three components:
`1.0.13` is the libsodium version number; `01` is the pre-release
number and needs to be incremented for each pre-release. * *libsodium version*
2. Take a look at the generated `Makefile`. It uses `sudo` a few times. The libsodium version is in the format `X.Y.Z`.
3. Run `make` to download and build the binaries and create the NuGet * *package revision*
package. You may need to install `docker`, `make`, `curl`, `tar` and It may be necessary to release more than one package for a libsodium version,
`unzip` first. The NuGet package is output as a `.nupkg` file in the e.g., when adding support for a new platform or if a release contains a broken
`build` directory. binary. In this case, a package revision number is added as a fourth part to
4. Grab a cup of coffee. Downloading the Docker images and compiling the the libsodium version, starting at `1`. For example, `1.0.13` is the initial
Linux binaries takes a while. release of the package for libsodium 1.0.13 and `1.0.13.5` is the fifth
5. Verify that everything in the `.nupkg` file is in place. revision (sixth release) of that package.
6. Publish the release by uploading the `.nupkg` file to * *pre-release label*
[nuget.org](https://nuget.org/). If a package is a pre-release, a label is appended to the version number in
`-preview-##` format where `##` is the number of the pre-release, starting at
`01`. For example, `1.0.13-preview-01` is the first pre-release of the package
for libsodium 1.0.13 and `1.0.13.5-preview-02` the second pre-release of the
fifth revision of the package for libsodium 1.0.13.
**Making a release** **Making a release**
1. Run `python3 prepare.py 1.0.13` to generate the `Makefile`. 1. Update any existing Docker images.
2. Run `python3 prepare.py <version>` to generate the `Makefile`, where
The remaining steps are the same. `<version>` is the package version number in the format described above.
3. Take a look at the generated `Makefile`. It uses `sudo` a few times.
4. Run `make` to download and build the binaries and create the NuGet package.
You may need to install `docker`, `make`, `curl`, `tar` and `unzip` first.
5. Grab a cup of coffee. Downloading the Docker images and compiling the Linux
binaries takes a while. When done, the NuGet package is output as a `.nupkg`
file in the `build` directory.
6. Run `make test` to perform a quick test of the NuGet package. Verify that
everything else in the `.nupkg` file is in place.
7. Publish the release by uploading the `.nupkg` file to
[nuget.org](https://nuget.org/).

View File

@ -1,5 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard1.1;net46</TargetFrameworks> <TargetFrameworks>netstandard1.1;net46</TargetFrameworks>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
@ -8,6 +9,7 @@
<PackageOutputPath>$(MSBuildProjectDirectory)</PackageOutputPath> <PackageOutputPath>$(MSBuildProjectDirectory)</PackageOutputPath>
<ProjectFileToPack>$(MSBuildProjectFullPath)</ProjectFileToPack> <ProjectFileToPack>$(MSBuildProjectFullPath)</ProjectFileToPack>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PackageId>libsodium</PackageId> <PackageId>libsodium</PackageId>
<Version><!-- set by prepare.py --></Version> <Version><!-- set by prepare.py --></Version>
@ -17,7 +19,9 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseUrl>https://raw.githubusercontent.com/jedisct1/libsodium/master/LICENSE</PackageLicenseUrl> <PackageLicenseUrl>https://raw.githubusercontent.com/jedisct1/libsodium/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://libsodium.org/</PackageProjectUrl> <PackageProjectUrl>https://libsodium.org/</PackageProjectUrl>
<MinClientVersion>4.0</MinClientVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include="LICENSE" PackagePath="" /> <Content Include="LICENSE" PackagePath="" />
<Content Include="AUTHORS" PackagePath="" /> <Content Include="AUTHORS" PackagePath="" />
@ -25,9 +29,5 @@
<Content Include="runtimes\**\*.*" PackagePath="runtimes\" /> <Content Include="runtimes\**\*.*" PackagePath="runtimes\" />
<Content Include="build\**\*.*" PackagePath="build\" /> <Content Include="build\**\*.*" PackagePath="build\" />
</ItemGroup> </ItemGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>advapi32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project> </Project>

View File

@ -24,19 +24,19 @@ MACOS = [
] ]
LINUX = [ LINUX = [
# --------------------- ------------------ # --------------------- ----------------- #
# Runtime ID Docker Image # Runtime ID Docker Image #
# --------------------- ------------------ # --------------------- ----------------- #
( 'alpine.3-x64', 'alpine:3.4' ),
( 'centos.7-x64', 'centos:7.1.1503' ), ( 'centos.7-x64', 'centos:7.1.1503' ),
( 'debian.8-x64', 'debian:8.2' ), ( 'debian.8-x64', 'debian:8.2' ),
( 'fedora.24-x64', 'fedora:24' ), ( 'fedora.24-x64', 'fedora:24' ),
( 'fedora.25-x64', 'fedora:25' ), ( 'fedora.25-x64', 'fedora:25' ),
( 'fedora.26-x64', 'fedora:26' ),
( 'opensuse.42.1-x64', 'opensuse:42.1' ), ( 'opensuse.42.1-x64', 'opensuse:42.1' ),
( 'ubuntu.14.04-x64', 'ubuntu:trusty' ), ( 'ubuntu.14.04-x64', 'ubuntu:trusty' ),
( 'ubuntu.16.04-x64', 'ubuntu:xenial' ), ( 'ubuntu.16.04-x64', 'ubuntu:xenial' ),
( 'ubuntu.16.10-x64', 'ubuntu:yakkety' ), ( 'ubuntu.16.10-x64', 'ubuntu:yakkety' ),
# --------------------- ------------------ # --------------------- ----------------- #
] ]
EXTRAS = [ 'LICENSE', 'AUTHORS', 'ChangeLog' ] EXTRAS = [ 'LICENSE', 'AUTHORS', 'ChangeLog' ]
@ -55,22 +55,21 @@ DOCKER = 'sudo docker'
class Version: class Version:
def __init__(self, prefix, suffix): def __init__(self, libsodium_version, package_version):
self.prefix = prefix self.libsodium_version = libsodium_version
self.suffix = suffix self.package_version = package_version
self.version = prefix + '-' + suffix if suffix is not None else prefix
self.builddir = os.path.join(BUILDDIR, prefix) self.builddir = os.path.join(BUILDDIR, libsodium_version)
self.tempdir = os.path.join(TEMPDIR, prefix) self.tempdir = os.path.join(TEMPDIR, libsodium_version)
self.projfile = os.path.join(self.builddir, '{0}.pkgproj'.format(PACKAGE)) self.projfile = os.path.join(self.builddir, '{0}.{1}.pkgproj'.format(PACKAGE, package_version))
self.propsfile = os.path.join(self.builddir, '{0}.props'.format(PACKAGE)) self.propsfile = os.path.join(self.builddir, '{0}.props'.format(PACKAGE))
self.pkgfile = os.path.join(BUILDDIR, '{0}.{1}.nupkg'.format(PACKAGE, self.version)) self.pkgfile = os.path.join(BUILDDIR, '{0}.{1}.nupkg'.format(PACKAGE, package_version))
self.desktoptargetsfile = os.path.join(self.builddir, 'build', 'net46', '{0}.targets'.format(PACKAGE)) self.desktoptargetsfile = os.path.join(self.builddir, 'build', 'net46', '{0}.targets'.format(PACKAGE))
class WindowsItem: class WindowsItem:
def __init__(self, version, rid, platform): def __init__(self, version, rid, platform):
self.url = 'https://download.libsodium.org/libsodium/releases/libsodium-{0}-msvc.zip'.format(version.prefix) self.url = 'https://download.libsodium.org/libsodium/releases/libsodium-{0}-msvc.zip'.format(version.libsodium_version)
self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url)) self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url))
self.packfile = os.path.join(version.builddir, 'runtimes', rid, 'native', LIBRARY + '.dll') self.packfile = os.path.join(version.builddir, 'runtimes', rid, 'native', LIBRARY + '.dll')
self.itemfile = '{0}/Release/v140/dynamic/libsodium.dll'.format(platform) self.itemfile = '{0}/Release/v140/dynamic/libsodium.dll'.format(platform)
@ -94,10 +93,10 @@ class WindowsItem:
class MacOSItem: class MacOSItem:
def __init__(self, version, rid, codename): def __init__(self, version, rid, codename):
self.url = 'https://bintray.com/homebrew/bottles/download_file?file_path=libsodium-{0}.{1}.bottle.tar.gz'.format(version.prefix, codename) self.url = 'https://bintray.com/homebrew/bottles/download_file?file_path=libsodium-{0}.{1}.bottle.tar.gz'.format(version.libsodium_version, codename)
self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url)) self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url))
self.packfile = os.path.join(version.builddir, 'runtimes', rid, 'native', LIBRARY + '.dylib') self.packfile = os.path.join(version.builddir, 'runtimes', rid, 'native', LIBRARY + '.dylib')
self.itemfile = 'libsodium/{0}/lib/libsodium.dylib'.format(version.prefix) self.itemfile = 'libsodium/{0}/lib/libsodium.dylib'.format(version.libsodium_version)
self.tempdir = os.path.join(version.tempdir, rid) self.tempdir = os.path.join(version.tempdir, rid)
self.tempfile = os.path.join(self.tempdir, os.path.normpath(self.itemfile)) self.tempfile = os.path.join(self.tempdir, os.path.normpath(self.itemfile))
@ -118,9 +117,11 @@ class MacOSItem:
class LinuxItem: class LinuxItem:
def __init__(self, version, rid, docker_image): def __init__(self, version, rid, docker_image):
self.url = 'https://download.libsodium.org/libsodium/releases/libsodium-{0}.tar.gz'.format(version.prefix) self.url = 'https://download.libsodium.org/libsodium/releases/libsodium-{0}.tar.gz'.format(version.libsodium_version)
self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url)) self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url))
self.packfile = os.path.join(version.builddir, 'runtimes', rid, 'native', LIBRARY + '.so') self.packfile = os.path.join(version.builddir, 'runtimes', rid, 'native', LIBRARY + '.so')
self.tempdir = os.path.join(version.tempdir, rid)
self.tempfile = os.path.join(self.tempdir, 'libsodium.so')
self.docker_image = docker_image self.docker_image = docker_image
self.recipe = rid self.recipe = rid
@ -137,7 +138,11 @@ class LinuxItem:
recipe = m.group(1) + m.group(3) + m.group(5) recipe = m.group(1) + m.group(3) + m.group(5)
f.write('\n') f.write('\n')
f.write('{0}: {1}\n'.format(self.packfile, self.cachefile)) f.write('{0}: {1}\n'.format(self.packfile, self.tempfile))
f.write('\t@mkdir -p $(dir $@)\n')
f.write('\tcp -f $< $@\n')
f.write('\n')
f.write('{0}: {1}\n'.format(self.tempfile, self.cachefile))
f.write('\t@mkdir -p $(dir $@)\n') f.write('\t@mkdir -p $(dir $@)\n')
f.write('\t{0} run --rm '.format(DOCKER) + f.write('\t{0} run --rm '.format(DOCKER) +
'-v $(abspath recipes):/io/recipes ' + '-v $(abspath recipes):/io/recipes ' +
@ -148,11 +153,11 @@ class LinuxItem:
class ExtraItem: class ExtraItem:
def __init__(self, version, filename): def __init__(self, version, filename):
self.url = 'https://download.libsodium.org/libsodium/releases/libsodium-{0}.tar.gz'.format(version.prefix) self.url = 'https://download.libsodium.org/libsodium/releases/libsodium-{0}.tar.gz'.format(version.libsodium_version)
self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url)) self.cachefile = os.path.join(CACHEDIR, re.sub(r'[^A-Za-z0-9.]', '-', self.url))
self.packfile = os.path.join(version.builddir, filename) self.packfile = os.path.join(version.builddir, filename)
self.itemfile = 'libsodium-{0}/{1}'.format(version.prefix, filename) self.itemfile = 'libsodium-{0}/{1}'.format(version.libsodium_version, filename)
self.tempdir = version.tempdir self.tempdir = os.path.join(version.tempdir, 'extras')
self.tempfile = os.path.join(self.tempdir, os.path.normpath(self.itemfile)) self.tempfile = os.path.join(self.tempdir, os.path.normpath(self.itemfile))
def make(self, f): def make(self, f):
@ -170,20 +175,23 @@ class ExtraItem:
)) ))
def main(args): def main(args):
m = re.fullmatch(r'(\d+(?:\.\d+){1,3})(?:-(\w+(?:[_.-]\w+)*))?', args[1]) if len(args) == 2 else None m = re.fullmatch(r'((\d+\.\d+\.\d+)(\.\d+)?)(?:-(\w+(?:[_.-]\w+)*))?', args[1]) if len(args) == 2 else None
if m is None: if m is None:
print('Usage:') print('Usage:')
print(' python3 prepare.py <version>[-preview-##]') print(' python3 prepare.py <version>')
print() print()
print('Examples:') print('Examples:')
print(' python3 prepare.py 1.0.13-preview-01') print(' python3 prepare.py 1.0.13-preview-01')
print(' python3 prepare.py 1.0.13-preview-02') print(' python3 prepare.py 1.0.13-preview-02')
print(' python3 prepare.py 1.0.13-preview-03') print(' python3 prepare.py 1.0.13-preview-03')
print(' python3 prepare.py 1.0.13') print(' python3 prepare.py 1.0.13')
print(' python3 prepare.py 1.0.13.1-preview-01')
print(' python3 prepare.py 1.0.13.1')
print(' python3 prepare.py 1.0.13.2')
return 1 return 1
version = Version(m.group(1), m.group(2)) version = Version(m.group(2), m.group(0))
items = [ WindowsItem(version, rid, platform) for (rid, platform) in WINDOWS ] + \ items = [ WindowsItem(version, rid, platform) for (rid, platform) in WINDOWS ] + \
[ MacOSItem(version, rid, codename) for (rid, codename) in MACOS ] + \ [ MacOSItem(version, rid, codename) for (rid, codename) in MACOS ] + \
@ -221,7 +229,7 @@ def main(args):
'<Project Sdk="Microsoft.NET.Sdk">' + '<Project Sdk="Microsoft.NET.Sdk">' +
'<Import Project="{0}" />'.format(os.path.relpath(version.propsfile, os.path.dirname(version.projfile))) + '<Import Project="{0}" />'.format(os.path.relpath(version.propsfile, os.path.dirname(version.projfile))) +
'<PropertyGroup>' + '<PropertyGroup>' +
'<VersionPrefix>{0}</VersionPrefix>'.format(version.prefix) + '<Version>{0}</Version>'.format(version.package_version) +
'</PropertyGroup>' + '</PropertyGroup>' +
'</Project>\' > $@\n') '</Project>\' > $@\n')
@ -238,9 +246,16 @@ def main(args):
'-v $(abspath recipes):/io/recipes ' + '-v $(abspath recipes):/io/recipes ' +
'-v $(abspath $(dir $<)):/io/input ' + '-v $(abspath $(dir $<)):/io/input ' +
'-v $(abspath $(dir $@)):/io/output ' + '-v $(abspath $(dir $@)):/io/output ' +
'{0} sh -x -e /io/recipes/{1} "{2}"\n'.format('microsoft/dotnet:latest', 'pack', version.suffix if version.suffix is not None else '')) '{0} sh -x -e /io/recipes/{1} {2}\n'.format('microsoft/dotnet:1.1-sdk', 'pack', os.path.relpath(version.projfile, version.builddir)))
print('prepared', MAKEFILE, 'to make', version.pkgfile) f.write('\n')
f.write('test: {0}\n'.format(version.pkgfile))
f.write('\t{0} run --rm '.format(DOCKER) +
'-v $(abspath recipes):/io/recipes ' +
'-v $(abspath $(dir $<)):/io/packages ' +
'{0} sh -x -e /io/recipes/{1} "{2}"\n'.format('microsoft/dotnet:1.1-sdk', 'test', version.package_version))
print('prepared', MAKEFILE, 'to make', version.pkgfile, 'for libsodium', version.libsodium_version)
return 0 return 0
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,5 +1,5 @@
cp -r /io/input ~/build cp -r /io/input ~/build
cd ~/build cd ~/build
dotnet restore dotnet restore $1
dotnet pack --version-suffix "$1" dotnet pack $1
cp *.nupkg /io/output cp *.nupkg /io/output

View File

@ -0,0 +1,27 @@
TEST_PROGRAM='using System;
using System.Runtime.InteropServices;
static class Program
{
[DllImport("libsodium")]
static extern int sodium_init();
static int Main()
{
int error = sodium_init();
Console.WriteLine(error == 0
? "ok"
: "error: sodium_init() returned {0}", error);
return error == 0 ? 0 : 1;
}
}
'
dotnet --info
cd ~
dotnet new console --name Test
cd Test
echo "$TEST_PROGRAM" > Program.cs
dotnet add package libsodium --version $1 --source /io/packages
dotnet restore
dotnet run