diff --git a/.travis.yml b/.travis.yml index a9a77b4..6654a9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,12 @@ before_script: script: - "git clone https://github.com/phil-harmoniq/Hello $TRAVIS_BUILD_DIR/Hello" - - "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -v -n Hello.AppImage" + - "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -v" - "$HOME/Hello.AppImage one two thr33 --npk-v four" - - "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME --scd --keep -c" + - "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -c --scd --keep --noext" - "$HOME/Hello one two thr33 --npk-v four" + - "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -c --scd --keep -n HelloApp" + - "$HOME/HelloApp one two thr33 --npk-v four" deploy: provider: releases diff --git a/Program.cs b/Program.cs index 72fd34c..15de994 100644 --- a/Program.cs +++ b/Program.cs @@ -29,6 +29,7 @@ class Program static bool CustomAppName = false; static bool SelfContainedDeployment = false; static bool KeepTempFiles = false; + static string Extension = ".AppImage"; static void Main(string[] args) { @@ -49,11 +50,19 @@ static void Main(string[] args) static void CheckPaths(string[] args) { if (args.Length < 2 || !Directory.Exists(args[0]) && !Directory.Exists(args[1])) + { ExitWithError("You must specify a valid .NET project AND Destination folder.", 6); + } if (Directory.Exists(args[0]) && !Directory.Exists(args[1])) - ExitWithError($"{args[1]} is not a valid folder", 7); + { + if (Bash.Command($"mkdir -p {args[1]}").ExitCode != 0) + ExitWithError($"{args[1]} is not a valid folder", 7); + } if (!Directory.Exists(args[0]) && Directory.Exists(args[1])) - ExitWithError($"{args[0]} is not a valid folder", 8); + { + if (Bash.Command($"mkdir -p {args[0]}").ExitCode != 0) + ExitWithError($"{args[0]} is not a valid folder", 8); + } ProjectDir = GetRelativePath(args[0]); Destination = GetRelativePath(args[1]); @@ -96,6 +105,10 @@ static void ParseArgs(string[] args) { HelpMenu(); } + else if (args[i] == "--noext") + { + Extension = ""; + } } } @@ -116,13 +129,13 @@ static void FindCsproj(string project) DllName = string.Join('.', nameSplit.Take(nameSplit.Length - 1)); if (!CustomAppName) - AppName = DllName; + AppName = $"{DllName}{Extension}"; if (SingleRuntimeIdentifier() && !SelfContainedDeployment) { SelfContainedDeployment = true; Printer.WriteLine( - $"{Clr.Yellow}Caution: runtime identifier detected. Making self-contained app.{Clr.Default}"); + $"{Clr.Yellow}Caution: Single runtime identifier detected. Using --scd{Clr.Default}"); } } @@ -253,7 +266,8 @@ static void HelpMenu() + @" --name or -n: Set ouput file to a custom name\n" + @" --scd or -s: Self-Contained Deployment (SCD)\n" + @" --keep or -k: Keep /tmp/{AppName}.temp directory\n" - + @" --help or -h: Help menu (this page)\n\n" + + @" --help or -h: Help menu (this page)\n" + + @" --clear-log: Delete error log at ~/.netpkg-tool\n\n" + @" More information & source code available on github:\n" + @" https://github.com/phil-harmoniq/netpkg-tool\n" + @" Copyright (c) 2017 - MIT License\n" @@ -264,9 +278,19 @@ static void HelpMenu() static void ClearLogs() { - Console.Write($"Clear log at {GetRelativePath(ConfigDir)}/error.log"); - Bash.Rm($"{ConfigDir}/error.log", "-f"); - CheckCommandOutput(errorCode: 5); + Console.Write($"Clear error log at {GetRelativePath(ConfigDir)}/error.log..."); + + if (File.Exists($"{ConfigDir}/error.log")) + { + Bash.Rm($"{ConfigDir}/error.log"); + CheckCommandOutput(errorCode: 5); + } + else + { + SayCaution(); + Printer.WriteLine($"{Clr.Yellow}Error log file already removed.{Clr.Default}"); + } + SayBye(); Environment.Exit(0); } @@ -291,16 +315,16 @@ static void WriteToErrorLog(string message, int code) if (!Directory.Exists(ConfigDir)) Directory.CreateDirectory(ConfigDir); - using (var tw = new StreamWriter($"{ConfigDir}/error.log", true)) + using (var log = new StreamWriter($"{ConfigDir}/error.log", true)) { var now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); var dir = Directory.GetCurrentDirectory(); - tw.WriteLine($"{new string('-', Width)}"); - tw.WriteLine($"{GetRelativePath(dir)}$ netpkg-tool {string.Join(' ', Args)}"); - tw.WriteLine($"Errored with code {code} - ({now}):\n"); - tw.WriteLine(message.TrimEnd('\n')); - tw.WriteLine($"{new string('-', Width)}"); + log.WriteLine($"{new string('-', Width)}"); + log.WriteLine($"{GetRelativePath(dir)}$ netpkg-tool {string.Join(' ', Args)}"); + log.WriteLine($"Errored with code {code} - ({now}):\n"); + log.WriteLine(message.TrimEnd('\n')); + log.WriteLine($"{new string('-', Width)}"); } } @@ -336,6 +360,9 @@ static void SayFinished(string message) => static void SayPass() => Printer.WriteLine($" {Frmt.Bold}[ {Clr.Green}PASS{Clr.Default} ]{Reset.Code}"); + static void SayCaution() => + Printer.WriteLine($" {Frmt.Bold}[ {Clr.Yellow}PASS{Clr.Default} ]{Reset.Code}"); + static void SayFail() => Printer.WriteLine($" {Frmt.Bold}[ {Clr.Red}FAIL{Clr.Default} ]{Reset.Code}"); } diff --git a/README.md b/README.md index de9515e..472f2b3 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Pre-packaged versions of *netpkg-tool* are available from the [releases tab](https://github.com/phil-harmoniq/netpkg-tool/releases): ```bash -# Github releases are tagged with their version (ex: 0.3.9) -wget https://github.com/phil-harmoniq/netpkg-tool/releases/download/0.3.9/netpkg-tool +# Github releases are tagged with their version (ex: 0.3.10) +wget https://github.com/phil-harmoniq/netpkg-tool/releases/download/0.3.10/netpkg-tool chmod a+x ./netpkg-tool # Place netpkg-tool somewhere on your $PATH (Optional) diff --git a/build.sh b/build.sh index a9889ad..1012c2a 100755 --- a/build.sh +++ b/build.sh @@ -19,5 +19,5 @@ else mv "$PWD/squashfs-root" "$HERE/appimagetool" rm "$HERE/appimagetool.AppImage" fi - dotnet run --project "$HERE" "$HERE" "$1" + dotnet run --project "$HERE" "$HERE" "$1" --noext --keep fi diff --git a/file-transfer.sh b/file-transfer.sh index ed9f517..73b9725 100755 --- a/file-transfer.sh +++ b/file-transfer.sh @@ -25,7 +25,7 @@ fi # Create an AppRun launcher touch /tmp/"$APP_NAME".temp/AppRun { - echo '#! /usr/bin/env bash' + echo '#!/usr/bin/env bash' echo echo 'export HERE=$(dirname "$(readlink -f "${0}")")' echo 'export NET_PKG='\""$NET_PKG"\" diff --git a/netpkg-tool.csproj b/netpkg-tool.csproj index 05c00ec..a45d284 100644 --- a/netpkg-tool.csproj +++ b/netpkg-tool.csproj @@ -7,7 +7,7 @@ Phil Hawkins Exe netcoreapp2.0 - 0.3.9 + 0.3.10 alpha Bundle .NET Core applications into convenient Linux binaries using appimagetool MIT @@ -17,8 +17,8 @@ - - + +