...
 
Commits (3)
  • Yuanle Song's avatar
    WIP build msi using wix. · d2bd4ec4
    Yuanle Song authored
    - introduced wix, make
    - rsync-mingw64.msi works
    - I decide to include rsync inside mbackup.msi, and install it in
      the same app dir. So this working rsync-mingw64.msi config will
      be removed in next commit.
    d2bd4ec4
  • Yuanle Song's avatar
    mbackup.msi works on dev node. · a00a1c3c
    Yuanle Song authored
    - renmaed mbackup-for-windows.fsproj to mbackup.fsproj
      this file name is the project name. now exe is named mbackup.exe
    - use framework dependent release.
    - include rsync-mingw in one msi
    - use installed rsync and ssh path in Program.fs
    a00a1c3c
  • Yuanle Song's avatar
    bugfix: create runtime dir before generating · 0ada5c66
    Yuanle Song authored
    mbackup.list file; create dir should use windows format dir string.
    0ada5c66
obj/
bin/
.ionide/
*.wixobj
*.wixpdb
*.msi
*-files.wxs
WIX_DIR := C:\Program Files (x86)\WiX Toolset v3.11\bin
HEAT := "$(WIX_DIR)\heat.exe"
CANDLE := "$(WIX_DIR)\candle.exe" -arch x64 -nologo
LIGHT := "$(WIX_DIR)\light.exe" -nologo
RSYNC_MINGW_DIR := D:\downloads\apps\rsync-w64
MBACKUP_PUBLISH_DIR := bin\Release\netcoreapp3.0\publish
default: build
help:
@cmd /C echo 'Usage: make [build|test|release|clean|dist|all]'
all: test release dist
dist: mbackup.msi
release:
dotnet publish --nologo -c Release --self-contained false
test:
dotnet test --nologo mbackup-tests
check: test
build:
dotnet build --nologo
clean:
dotnet clean --nologo
cmd /C 'del *.wixobj *.wixpdb *.msi rsync-mingw64-files.wxs'
%.wixobj: %.wxs
$(CANDLE) $<
rsync-mingw64-files.wxs:
$(HEAT) dir $(RSYNC_MINGW_DIR) -cg RsyncHeatGenerated -dr MBACKUP_PROGRAM_FILES -var var.RsyncSourceDir -gg -nologo -out [email protected] -sw5150
rsync-mingw64-files.wixobj: rsync-mingw64-files.wxs
$(CANDLE) -dRsyncSourceDir=$(RSYNC_MINGW_DIR) $<
mbackup-files.wxs: release
$(HEAT) dir $(MBACKUP_PUBLISH_DIR) -cg MbackupHeatGenerated -dr MBACKUP_PROGRAM_FILES -var var.MbackupPublishDir -gg -nologo -out [email protected] -sw5150
mbackup-files.wixobj: mbackup-files.wxs
$(CANDLE) -dMbackupPublishDir=$(MBACKUP_PUBLISH_DIR) $<
mbackup.msi: mbackup.wixobj rsync-mingw64-files.wixobj mbackup-files.wixobj
$(LIGHT) $^ -o [email protected]
.PHONY: default help all dist release test check build clean rsync-mingw64-files.wxs mbackup-files.wxs
......@@ -44,6 +44,11 @@ with
| Node_Name _ -> "local node's name, used in remote logging"
| Ssh_Key _ -> "ssh private key, used when backup to remote ssh node"
let programFilesDirWin = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) |> ensureWinDir
let programFilesDir = toMingwPath programFilesDirWin
let mbackupProgramDirWin = programFilesDirWin + "mbackup\\"
let mbackupProgramDir = toMingwPath mbackupProgramDirWin
let appDataRoamingDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) |> toMingwPath |> ensureDir
let programDataDirWin = getEnv "PROGRAMDATA" |> ensureWinDir
let programDataDir = toMingwPath programDataDirWin
......@@ -115,7 +120,7 @@ let generateMbackupList (logger: Logger) =
let lines = readMbackupListFile mbackupLocalList |> Seq.map toMingwPath
(true, lines)
with
| :? System.IO.FileNotFoundException ->
| :? FileNotFoundException ->
(true, Seq.empty)
| ex ->
logger.Error "Read mbackupLocalList failed: %s" ex.Message
......@@ -128,6 +133,7 @@ let generateMbackupList (logger: Logger) =
// For mbackup-default.list and local.list, exclude empty lines and comment lines.
// skip and give a warning on non-absolute path.
// For user-default.list, auto prefix user's home dir, auto expand Documents, Downloads etc special folder.
Directory.CreateDirectory(runtimeDirWin) |> ignore
File.WriteAllLines(mbackupList, allLines)
logger.Info "mbackup.list file written: %s" mbackupList
true
......@@ -151,6 +157,7 @@ let main argv =
logger.Info "user config dir: %s" userConfigDirWin
logger.Info "runtime dir: %s" runtimeDirWin
logger.Debug "program dir: %s" mbackupProgramDirWin
let rsyncCmd: string list = []
let rsyncCmd = appendWhen dryRun rsyncCmd "--dry-run"
......@@ -170,13 +177,10 @@ let main argv =
let localLogFile = runtimeDir + "mbackup.log"
let rsyncCmd = List.append rsyncCmd [sprintf "--log-file=%s" localLogFile]
// TODO remove usage of test dir.
let mbackupInstallDirWinTest = "D:\\downloads\\apps\\mbackupTest\\"
let mbackupInstallDirTest = mbackupInstallDirWinTest |> toMingwPath |> ensureDir
let sshExeFile = mbackupInstallDirTest + "rsync-w64/usr/bin/ssh.exe"
let sshExeFile = mbackupProgramDir + "rsync-w64/usr/bin/ssh.exe"
let sshConfigFile = userHome + ".ssh/config"
let sshPrivateKeyFile = results.GetResult(Ssh_Key, defaultValue = userHome + ".ssh/id_rsa") |> toMingwPath
let rsyncCmd = List.append rsyncCmd [sprintf "-e \"%s -F %s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFile sshPrivateKeyFile]
let rsyncCmd = List.append rsyncCmd [sprintf "-e \"'%s' -F %s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFile sshPrivateKeyFile]
// precedence: command line argument > environment variable > config file
let normalizeTarget target =
......@@ -211,13 +215,12 @@ let main argv =
let rsyncCmd = List.append rsyncCmd ["/"]
let rsyncCmd = List.append rsyncCmd [backupTarget]
let rsyncArgs = rsyncCmd |> String.concat " "
let rsyncExe = mbackupInstallDirWinTest + "rsync-w64\\usr\\bin\\rsync.exe"
let echoExe = "C:\\Program Files\\Git\\usr\\bin\\echo.exe"
let rsyncExe = mbackupProgramDirWin + "rsync-w64\\usr\\bin\\rsync.exe"
try
IO.Directory.CreateDirectory(runtimeDir) |> ignore
IO.Directory.CreateDirectory(userConfigDir) |> ignore
let proc = Process.Start(rsyncExe, rsyncArgs)
Directory.CreateDirectory(runtimeDirWin) |> ignore
Directory.CreateDirectory(userConfigDirWin) |> ignore
logger.Info "Note: if you run the following rsync command yourself, make sure the generated file list (%s) is up-to-date.\n%s" mbackupFile (rsyncExe + " " + rsyncArgs)
let proc = Process.Start(rsyncExe, rsyncArgs)
if proc.WaitForExit Int32.MaxValue then
logger.Info "mbackup exit"
proc.ExitCode
......@@ -225,7 +228,7 @@ let main argv =
logger.Error "mbackup timed out while waiting for rsync to complete"
ExitTimeout
with
| :? System.IO.IOException as ex ->
| :? IOException as ex ->
logger.Error "IO Error: %s %s" ex.Source ex.Message
ExitIOError
| ex ->
......
......@@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\mbackup-for-windows.fsproj" />
<ProjectReference Include="..\mbackup.fsproj" />
</ItemGroup>
</Project>
......@@ -3,7 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<RootNamespace>Mbackup</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
......
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="3030B91E-5E3E-4151-9A69-B53B72690430" Version="0.1.0.0" Language="1033" Name="mbackup" Manufacturer="Yuanle Song">
<Package InstallerVersion="300" Compressed="yes"/>
<Media Id="1" Cabinet="mbackup.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="MBACKUP_PROGRAM_FILES" Name="mbackup" />
</Directory>
<Directory Id="CommonAppDataFolder">
<Directory Id="MBACKUP_DATA" Name="mbackup"/>
</Directory>
</Directory>
<DirectoryRef Id="MBACKUP_DATA">
<Component Id="mbackup_default.exclude" Guid="*">
<File Id="mbackup_default.exclude" Source="mbackup-config\mbackup-default.exclude" KeyPath="yes"/>
</Component>
<Component Id="mbackup_default.list" Guid="*">
<File Id="mbackup_default.list" Source="mbackup-config\mbackup-default.list" KeyPath="yes"/>
</Component>
<Component Id="user_default.list" Guid="*">
<File Id="user_default.list" Source="mbackup-config\user-default.list" KeyPath="yes"/>
</Component>
<Component Id="mbackup.txt" NeverOverwrite="yes" Permanent="yes" Guid="*">
<!-- do not overwrite this component/file if it already exists on target system -->
<File Id="mbackup.txt" Source="mbackup-config\mbackup.txt" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentGroupRef Id="MbackupHeatGenerated" />
<ComponentGroupRef Id="RsyncHeatGenerated" />
<ComponentRef Id="mbackup_default.exclude" />
<ComponentRef Id="mbackup_default.list" />
<ComponentRef Id="user_default.list" />
<ComponentRef Id="mbackup.txt" />
</Feature>
</Product>
</Wix>
This diff is collapsed.