Skip to content

Commit

Permalink
Merge pull request #17 from IT-Service/hotfix/1.0.3
Browse files Browse the repository at this point in the history
Hotfix/1.0.3
+ добавлен расчёт контрольных сумм внешних файлов при сборке (#16)
+ добавлена проверка контрольных сумм для загружаемых файлов при установке (#16)
  • Loading branch information
sergey-s-betke authored Aug 11, 2016
2 parents 71eadf0 + 775cdf7 commit f2e4eae
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 30 deletions.
2 changes: 1 addition & 1 deletion ITG.MakeUtils/appveyor.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include $(ITG_MAKEUTILS_DIR)/nuget.mk

ifeq ($(APPVEYOR),True)

APPVEYORTOOL := appveyor
APPVEYORTOOL ?= appveyor

# $(call pushDeploymentArtifactFile, DeploymentName, Path)
pushDeploymentArtifactFile = for file in $2; do $(APPVEYORTOOL) PushArtifact $$file -DeploymentName '$(1)'; done
Expand Down
46 changes: 44 additions & 2 deletions ITG.MakeUtils/chocolatey.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,43 @@ include $(realpath $(ITG_MAKEUTILS_DIR)/tests.mk)

CHOCO ?= choco
NUGET ?= nuget
FILEHASHALGORITHM ?= md5

# $(call getExternalFileId,externalFileXml)
getExternalFileId = $(patsubst %.externalfile.xml,%,$(notdir $1))

# $(call getChocoPackageWebFileChecksumTarget,externalFileXml,bitsPrefix)
getChocoPackageWebFileChecksumTarget = $(call getExternalFileId,$1)_CHECKSUM$(2)

# $(call getChocoPackageWebFileChecksumAuxFile,externalFileXml,bitsPrefix)
getChocoPackageWebFileChecksumAuxFile = $(call getExternalFileId,$1)_AUXFILE$(2)

# $(call getChocoPackageWebFileChecksumFile,externalFileXml,bitsPrefix)
getChocoPackageWebFileChecksumFile = $(dir $1)$(call getExternalFileId,$1)$(if $(2),($2)).$(FILEHASHALGORITHM).checksum.txt

%.externalfile.tmp: %.externalfile.xml
$(MAKETARGETDIR)
$(call psExecuteCommand, \
Invoke-WebRequest \
-Uri ( ( Select-Xml -LiteralPath '$<' -XPath '/package/files/file[@fileid=\"$(call getExternalFileId,$*)\"]/@url').Node.Value ) \
-OutFile '$@' \
-Verbose \
; \
)
@touch $@

clean::
shopt -s globstar; rm -rf **/*.externalfile.tmp

%.$(FILEHASHALGORITHM).checksum.txt: %.externalfile.tmp %.externalfile.xml
$(MAKETARGETDIR)
$(call psExecuteCommand, \
( Get-FileHash -LiteralPath '$<' -Algorithm $(FILEHASHALGORITHM) -Verbose ).Hash \
| Out-File -LiteralPath '$@' -Encoding utf8 -Force \
; \
)

# checksum -t=$(FILEHASHALGORITHM) -f="$<" >> "$@"

# $(call calcChocoPackageFileName, packageId, packageVersion)
calcChocoPackageFileName = $1.$2.nupkg
Expand All @@ -21,7 +58,12 @@ $(1)TOOLS ?= $(wildcard $(SOURCESDIR)/$2/chocolatey*.ps1)
$(1)VERSION ?= $4
$(1)VERSIONSUFFIX ?= $5

$$($(1)TARGETS): $$($(1)NUSPEC) $$($(1)TOOLS) $6
$$($(1)TARGETS): \
$$($(1)NUSPEC) \
$$($(1)TOOLS) \
$(wildcard $(SOURCESDIR)/$2/*.ignore) \
$(patsubst %.externalfile.xml,%.$(FILEHASHALGORITHM).checksum.txt,$(wildcard $(SOURCESDIR)/$2/*.externalfile.xml)) \
$6
$$(info Generate chocolatey package file "$$@"...)
$$(MAKETARGETDIR)
cd $$(@D) && $$(CHOCO) \
Expand All @@ -48,7 +90,7 @@ packChocoWebPackage = $(call packChocoPackageAux,$1,$2,,$3,$4,$5)
define defineInstallTestForChocoPackage

$(call defineTest,install,$1,\
$(CHOCO) install $2 --force --confirm -pre --source "$$(<D)", \
$(CHOCO) install $2 --force --confirm -pre --version $$($(1)VERSION) --source "$$(<D)", \
$$($(1)TARGETS) \
)

Expand Down
4 changes: 3 additions & 1 deletion ITG.MakeUtils/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ psExecuteCommand = \
-NonInteractive \
-NoProfile \
-ExecutionPolicy unrestricted \
-Command "& { $(1) }"
-Command "\
Set-Variable -Name ErrorActionPreference -Value Stop; \
& { $(1) }"

#
# subprojects
Expand Down
2 changes: 1 addition & 1 deletion ITG.MakeUtils/gitversion.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ITG_MAKEUTILS_DIR ?= $(MAKE_GITVERSION_DIR)

include $(realpath $(ITG_MAKEUTILS_DIR)/common.mk)

GITVERSION ?= gitversion.bat
GITVERSION ?= gitversion

export GITVERSIONMAKEFILE ?= $(abspath $(AUXDIR)/version.mk)

Expand Down
9 changes: 5 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
image: WMF 5
version: 1.0.0 (Build {build})

branches:
except:
- /^modules\/.*$/

environment:
CODE_SIGNING_CERTIFICATE_PASSWORD:
secure: +Dn/WhvBx1rVgenyg7x+Bg==

branches:
except:
- /^modules\/.*$/

install:
- cmd: GitVersion /output buildserver
- ps: .\install.ps1 -ErrorAction Stop -InformationAction Continue -Verbose

build_script:
- cmd: set PATH=%PATH%;%ProgramFiles%/AppVeyor/BuildAgent
- cmd: make

before_test:
Expand Down
3 changes: 2 additions & 1 deletion chocolatey/signcode.install/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/*.ignore
*.ignore
*.tmp
1 change: 0 additions & 1 deletion chocolatey/signcode.install/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ CHOCO_PACKAGE_NAME = signcode.install
$(eval $(call packChocoWebPackage,package,$(CHOCO_PACKAGE_NAME),\
$(MajorMinorPatch),\
$(PreReleaseLabel),\
$(wildcard $(SOURCESDIR)/$(CHOCO_PACKAGE_NAME)/*.ignore)\
$(SOURCESDIR)/$(CHOCO_PACKAGE_NAME)/signcodepwd.cmd \
))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
$ErrorActionPreference = 'Stop';
$fileHashAlgorithm = 'md5';

$packageName = 'signcode.install';
$toolsDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition);

$DSigUrl = 'http://download.microsoft.com/download/4/7/e/47e8e7fb-9441-4887-988f-e259a443052d/Dsig.EXE';
$signcodePwdUrl = 'http://www.stephan-brenner.com/downloads/signcode-pwd/signcode-pwd_1_02.zip';

$dsigMetadata = ( Select-Xml `
-LiteralPath ( Join-Path -Path $toolsDir -ChildPath 'dsig.externalfile.xml' ) `
-XPath '/package/files/file[@fileid="dsig"]'
).Node;
Install-ChocolateyPackage `
-packageName 'DSig' `
-url $DSigUrl `
-url ( $dsigMetadata.url ) `
-silentArgs "/Q /T:`"$toolsDir`"" `
-checksum ( Get-Content -LiteralPath ( Join-Path -Path $toolsDir -ChildPath "dsig.$fileHashAlgorithm.checksum.txt" ) ) `
-checksumType $fileHashAlgorithm `
;

$signcodepwdMetadata = ( Select-Xml `
-LiteralPath ( Join-Path -Path $toolsDir -ChildPath 'signcodepwd.externalfile.xml' ) `
-XPath '/package/files/file[@fileid="signcodepwd"]'
).Node;
Install-ChocolateyZipPackage `
-packageName 'signcode-pwd' `
-unzipLocation $toolsDir `
-url $signcodePwdUrl `
-url ( $signcodepwdMetadata.url ) `
-checksum ( Get-Content -LiteralPath ( Join-Path -Path $toolsDir -ChildPath "signcodepwd.$fileHashAlgorithm.checksum.txt" ) ) `
-checksumType $fileHashAlgorithm `
;

$exitCode = Start-ChocolateyProcessAsAdmin `
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<files>
<file fileid="dsig" filename="dsig.exe" target="tools" url="http://download.microsoft.com/download/4/7/e/47e8e7fb-9441-4887-988f-e259a443052d/Dsig.EXE"/>
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
95A604E5E716FDC32AF38E936E42C06D
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ All release notes can be found on the GitHub site - https://github.com/IT-Servic
</metadata>
<files>
<file src="chocolatey*.ps1" target="tools"/>
<file src="*.*" target="tools"/>
<file src="*.ignore" target="tools"/>
<file src="*.externalfile.xml" target="tools"/>
<file src="*.checksum.txt" target="tools"/>
<file src="signcodepwd.cmd" target="tools"/>
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<files>
<file fileid="signcodepwd" filename="signcode-pwd.zip" target="tools" url="http://www.stephan-brenner.com/downloads/signcode-pwd/signcode-pwd_1_02.zip"/>
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C9C25444500C732AB58ACC7855D39CF7
31 changes: 15 additions & 16 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,38 +70,37 @@ $ToPath = @();

Import-Module -Name PackageManagement;

$null = Install-PackageProvider -Name NuGet -Force;
$null = Import-PackageProvider -Name NuGet -Force;
$null = (
Get-PackageSource -ProviderName NuGet `
| Set-PackageSource -Trusted `
);
$null = Install-PackageProvider -Name Chocolatey -Force;
$null = Import-PackageProvider -Name Chocolatey -Force;
$null = (
Get-PackageSource -ProviderName Chocolatey `
| Set-PackageSource -Trusted `
);
$null = Install-Package -Name chocolatey -MinimumVersion 0.9.10.3 -ProviderName Chocolatey;
$null = Import-PackageProvider -Name Chocolatey -Force;
$null = (
Get-PackageSource -ProviderName NuGet `
Get-PackageSource -ProviderName Chocolatey `
| Set-PackageSource -Trusted `
);
$ToPath += "$env:ChocolateyPath\bin";

$null = Install-Package -Name 'GitVersion.Portable' -ProviderName Chocolatey;
$env:GitVersion = "$env:ChocolateyPath\lib\GitVersion.Portable.$(( Get-Package -Name GitVersion.Portable -ProviderName Chocolatey ).Version)\tools\GitVersion.exe";
Write-Verbose "GitVersion path: $env:GitVersion";
if ($PSCmdLet.ShouldProcess('GitVersion', 'Установить переменную окружения')) {
[System.Environment]::SetEnvironmentVariable( 'GitVersion', $env:GitVersion, [System.EnvironmentVariableTarget]::User );
};

$null = Install-Package -Name 'GitReleaseNotes.Portable' -ProviderName Chocolatey;
& choco install GitVersion.Portable --confirm --failonstderr | Out-String -Stream | Write-Verbose;
& choco install GitReleaseNotes.Portable --confirm --failonstderr | Out-String -Stream | Write-Verbose;

if ( -not ( $env:APPVEYOR -eq 'True' ) ) {

$null = Install-Package -Name chocolatey -ProviderName Chocolatey;

if ( ( Get-Package -Name Git -ErrorAction SilentlyContinue ).count -eq 0 ) {
$null = Install-Package -Name 'git' -MinimumVersion '2.8' -ProviderName Chocolatey;
};
& choco install git --confirm --failonstderr | Out-String -Stream | Write-Verbose;

};

$null = Install-Package -Name 'cygwin' -ProviderName Chocolatey;
& choco install checksum --confirm --failonstderr | Out-String -Stream | Write-Verbose;

& choco install cygwin --confirm --failonstderr | Out-String -Stream | Write-Verbose;
$env:CygWin = Get-ItemPropertyValue `
-Path HKLM:\SOFTWARE\Cygwin\setup `
-Name rootdir `
Expand Down

0 comments on commit f2e4eae

Please sign in to comment.