Skip to content

Commit

Permalink
Merge pull request #333 from hubblo-org/311-github-workflow-to-build-…
Browse files Browse the repository at this point in the history
…and-publish-a-exemsi-file-including-signed-rapl-driver-at-each-tagrelease

chore: new iss file to build exe package
  • Loading branch information
bpetit authored Aug 15, 2023
2 parents 454fd3e + 23af286 commit d3e627c
Show file tree
Hide file tree
Showing 14 changed files with 380 additions and 122 deletions.
31 changes: 0 additions & 31 deletions .github/bloat-test.yml

This file was deleted.

87 changes: 0 additions & 87 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/exe-release-prometheuspush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build exe installer for windows for prometheus-push only version

on:
push:
paths-ignore:
- 'docs_src/**'
- 'README.md'
- 'CITATION'
- 'book.toml'
- 'CONTRIBUTING.md'
tags: [ 'v*.*.*', 'dev*.*.*' ]
branches: [ '311-github-workflow-to-build-and-publish-a-exemsi-file-including-signed-rapl-driver-at-each-tagrelease' ]

env:
WRD_VERSION: v0.0.2
WRD_BASE_URL: https://github.com/hubblo-org/windows-rapl-driver/releases/download

jobs:
build_exe_win1011:
name: Build exe installer for windows 10/11/server 2016/server 2019/server 2022
runs-on: "windows-latest"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Innosoft
run: |
$url = "https://jrsoftware.org/download.php/is.exe"
$dest = "is.exe"
Invoke-WebRequest -Uri $url -OutFile $dest
ls
& "D:\a\scaphandre\scaphandre\$dest" /verysilent /suppressmsgbox
ls "C:\Program Files (x86)\Inno Setup 6\"
- name: Get windows-rapl-driver
run: |
$dest = "DriverLoader.exe"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/DriverLoader.exe"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
$dest = "ScaphandreDrv.cat"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrv.cat"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
$dest = "ScaphandreDrv.sys"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrv.sys"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
$dest = "ScaphandreDrv.inf"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrv.inf"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
$dest = "ScaphandreDrvTest.cer"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrvTest.cer"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
$dest = "devcon.exe"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/devcon.exe"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
$dest = "certmgr.exe"
$url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/certmgr.exe"
Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest
ls
- name: Install Rustup
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install rustup.install --ignore-checksums
- name: Install Rust toolchain
run: |
rustup toolchain install stable-x86_64-pc-windows-msvc
- name: Build Scaphandre
run: |
cargo build --release --no-default-features --features "prometheuspush json"
- name: Build package
run: |
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" packaging/windows/installer.iss
- name: Upload artifact #Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
run: |
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Module -Confirm:$False -Name AWS.Tools.Installer
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Import-Module AWS.Tools.Installer
Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp -Confirm:$False
Set-AWSCredential -AccessKey ${{ secrets.S3_ACCESS_KEY_ID }} -SecretKey ${{ secrets.S3_SECRET_ACCESS_KEY }} -StoreAs default
mv packaging/windows/Output/scaphandre_installer.exe scaphandre_${GITHUB_REF_NAME}_installer.exe
$clientconfig=@{
SignatureVersion="s3v4"
ServiceUrl="https://s3.fr-par.scw.cloud"
}
Write-S3Object -EndpointUrl "https://s3.fr-par.scw.cloud" -Region "fr-par" -BucketName "scaphandre" -File scaphandre_${GITHUB_REF_NAME}_installer.exe -key "x86_64/scaphandre_${GITHUB_REF_NAME}_installer.exe" -PublicReadOnly -ClientConfig $clientconfig
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
**/Output/

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ procfs = { version = "0.15.0" }

[target.'cfg(target_os="windows")'.dependencies]
windows = { version = "0.27.0", features = ["alloc","Win32_Storage_FileSystem","Win32_Foundation","Win32_Security","Win32_System_IO","Win32_System_Ioctl"]}
windows-service = { version = "0.6.0" }

[features]
default = ["prometheus", "riemann", "warpten", "json", "containers", "prometheuspush"]
Expand Down
Binary file added docs_src/scaphandre.ico
Binary file not shown.
38 changes: 35 additions & 3 deletions docs_src/tutorials/installation-windows.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Install Scaphandre on Windows (experimental)
# Install Scaphandre on Windows

A better procedure and packaging should come soon.
**!! Warning: This is a first testing version of the package and installation procedure.**
**!! A new version is on its way with proper driver signature and Windows service proper management.**

The release 0.5.0 of Scaphandre can be tested on windows by compiling both the kernel driver and Scaphandre. See [Compilation for Windows (experimental)](compilation-windows.md)
## Using the installer

In this first itration of the package, you'll need to enable Test Mode on Windows prior to proceed to this installation, then reboot. (Next version will have an officially signed version of the driver, so this won't be ncessaerry anymore.)

bcdedit.exe -set TESTSIGNING ON
bcdedit.exe -set nointegritychecks on

The installer will ensure that test mode is enabled and fail otherwise, but activation of test mode **and a reboot** is needed before anyway.

Then download the [package](https://scaphandre.s3.fr-par.scw.cloud/x86_64/scaphandre_0.5.0_installer.exe) and install it **as an administrator**.

Once installed, you should be able to run scaphandre from Powershell, by running :

& 'C:\Program Files (x86)\scaphandre\scaphandre.exe' stdout

## Troubleshooting

An error such as

scaphandre::sensors::msr_rapl: Failed to open device : HANDLE(-1)

means that the driver is not properly setup. Check it's state by running:

driverquery /v | findstr capha

If there is not item returned, the installation of the driver encountered an issue.

If the service is STOPPED, there is also something wrong.

## Compilation

If you look for compiling Scaphandre and its driver yourself, see [Compilation for Windows](compilation-windows.md)
75 changes: 75 additions & 0 deletions packaging/windows/dev_installer.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "scaphandre"
#define MyAppVersion "0.5.0"
#define MyAppPublisher "Hubblo"
#define MyAppURL "https://hubblo-org.github.io/scaphandre-documentation"
#define MyAppExeName "scaphandre.exe"
#define MyAppSourceFolder "C:\Users\bpeti\Documents\GitHub\scaphandre"
#define RaplDriverSourceFolder "C:\Users\bpeti\Documents\GitHub\windows-rapl-driver"
#define SystemFolder "C:\Windows\System32"
#define System64Folder "C:\Windows\SysWOW64"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{7DB7B851-1DD2-4FF5-BFC7-282FEBA3B28D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
LicenseFile=C:\Users\bpeti\Documents\GitHub\scaphandre\LICENSE
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename={#MyAppName}_{#MyAppVersion}_installer
Compression=lzma
SolidCompression=yes
WizardStyle=modern
Uninstallable=yes
SetupIconFile=C:\Users\bpeti\Documents\GitHub\scaphandre\docs_src\scaphandre.ico

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "{#MyAppSourceFolder}\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#RaplDriverSourceFolder}\x64\Release\DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.inf"; DestDir: "{app}"; Flags: ignoreversion
; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#SystemFolder}";
; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#System64Folder}";
Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{app}";
Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{app}";
; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#SystemFolder}";
; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#System64Folder}";
Source: "C:\Program Files (x86)\Windows Kits\10\Tools\10.0.22621.0\x64\devcon.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\certmgr.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppSourceFolder}\README.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppSourceFolder}\CHANGELOG.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#RaplDriverSourceFolder}\ScaphandreDrvTest.cer"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"

[Run]
Filename: "C:\windows\System32\WindowsPowershell\v1.0\powershell.exe"; Parameters: "Import-Certificate -FilePath {app}\ScaphandreDrvTest.cer -CertStoreLocation Cert:\LocalMachine\Root"; Description: "Register test certificate"; Flags: waituntilidle shellexec
Filename: "{app}/devcon.exe"; Parameters: "install {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Install Driver"; Flags: waituntilidle
Filename: "{app}/devcon.exe"; Parameters: "enable {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Enable Driver"; Flags: waituntilidle
Filename: "{app}/DriverLoader.exe"; Parameters: "install"; WorkingDir: "{app}"; Description: "Install Driver Service";
Filename: "{app}/DriverLoader.exe"; Parameters: "start"; WorkingDir: "{app}"; Description: "Start Driver Service";
; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}";
; Filename: "schtasks.exe"; Parameters: "/Create /SC ONSTART {app}\scaphandre.exe prometheus-push "

[UninstallRun]
Filename: "{app}/DriverLoader.exe"; Parameters: "stop"; WorkingDir: "{app}"; RunOnceId: "StopService";
Filename: "{app}/DriverLoader.exe"; Parameters: "remove"; WorkingDir: "{app}"; RunOnceId: "RemoveService";
Filename: "{app}/devcon.exe"; Parameters: "disable ScaphandreDrv"; RunOnceId: "DisableDrier";
Filename: "{app}/devcon.exe"; Parameters: "remove ScaphandreDrv"; RunOnceId: "RemoveService";


Loading

0 comments on commit d3e627c

Please sign in to comment.