diff --git a/.gitignore b/.gitignore index 3ca812444..8edad6f19 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,4 @@ scripts/packer/iso/*.iso scripts/packer/packer_cache scripts/packer/output-* *.box - +*.code-workspace diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 634d2467c..d80fe03a6 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -8,6 +8,47 @@ You will need to make this script executable by setting your Powershell Execution Policy to Remote signed Then unblock the script for execution with UnblockFile .\build.ps1 +.PARAMETER sourcesPath + Path to the vendor sources JSON file. Defaults to vendor/sources.json. + + Use this to point to a custom package manifest. +.PARAMETER saveTo + Destination directory for downloaded and extracted vendor dependencies. + + Defaults to the repository vendor directory. +.PARAMETER launcher + Path to the launcher project directory used when -Compile is set. + + Defaults to the repository launcher directory. +.PARAMETER config + Path to the configuration directory used to back up and restore user-modified + terminal settings during vendor refresh. + + Defaults to the repository config directory. +.PARAMETER noVendor + Skip downloading and extracting all vendors. + + Useful with -Compile when only rebuilding the launcher. +.PARAMETER terminal + Select which terminal packages to include from sources: + - all: include all supported terminal packages (default) + - none: skip terminal vendor downloads + - conemu-maximus5: include only ConEmu package + - windows-terminal: include only Windows Terminal package +.PARAMETER Compile + Build the launcher executable using MSBuild. + + Requires Visual C++ build tools and msbuild in PATH. +.PARAMETER InstallPacman + Install pacman in the bundled Git for Windows environment if it is not present. +.PARAMETER Verbose + Built-in common parameter from CmdletBinding. + + Prints detailed progress output for troubleshooting. +.PARAMETER WhatIf + Built-in common parameter from CmdletBinding (SupportsShouldProcess). + + Does a dry-run of the build process, showing what actions would be taken without making changes. .EXAMPLE .\build.ps1 @@ -21,20 +62,41 @@ Skip all downloads and only build launcher. .EXAMPLE - .\build -verbose + .\build.ps1 -Verbose Execute the build and see what's going on. .EXAMPLE - .\build.ps1 -SourcesPath '~/custom/vendors.json' + .\build.ps1 -SourcesPath 'C:\custom\sources.json' Build Cmder with your own packages. See vendor/sources.json for the syntax you need to copy. +.EXAMPLE + .\build.ps1 -Terminal conemu-maximus5 + + Build Cmder including only ConEmu (skips Windows Terminal). +.EXAMPLE + .\build.ps1 -Terminal windows-terminal + + Build Cmder including only Windows Terminal (skips ConEmu). +.EXAMPLE + .\build.ps1 -Terminal none -Compile + + Build launcher only and skip all terminal vendor downloads. +.EXAMPLE + .\build.ps1 -InstallPacman + + Build vendors and install pacman into the bundled Git for Windows environment if missing. +.EXAMPLE + .\build.ps1 -WhatIf + + Shows what actions would be taken without applying changes. .NOTES AUTHORS - Samuel Vasko, Jack Bennett + Samuel Vasko, Jack Bennett, Dax Games Part of the Cmder project. .LINK http://cmder.app/ - Project Home #> + [CmdletBinding(SupportsShouldProcess = $true)] Param( # CmdletBinding will give us; @@ -60,7 +122,10 @@ Param( [string]$terminal = 'all', # Build launcher if you have MSBuild tools installed - [switch]$Compile + [switch]$Compile, + + # Install pacman if not present + [switch]$InstallPacman ) # Get the scripts and cmder root dirs we are building in. @@ -199,6 +264,19 @@ if (-not $noVendor) { Copy-Item $($saveTo + "git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") } + $gitForWindowsPath = $saveTo + "git-for-windows" + $pacmanPath = $saveTo + "git-for-windows/usr/bin/pacman.exe" + + $shouldInstallPacman = + $InstallPacman -and + (Test-Path $gitForWindowsPath) -and + -not (Test-Path $pacmanPath) + + if ($shouldInstallPacman) { + Write-Verbose "Installing pacman..." + & $($saveTo + "git-for-windows/bin/bash.exe") $($saveTo + "../scripts/install_pacman.sh") + } + Pop-Location } diff --git a/scripts/install_pacman.sh b/scripts/install_pacman.sh new file mode 100644 index 000000000..fa9c1f079 --- /dev/null +++ b/scripts/install_pacman.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bash + +# Based on: https://github.com/mcgitty/pacman-for-git +# Dax T. Games Fork: https://github.com/daxgames/pacman-for-git + +# Disclaimer: Use at your own risk. +# +# This script modifies system files and installs the pacman package manager into your Git for Windows environment. +# +# While it has been tested in various Git for Windows versions, there is always a risk of data loss or system instability when running scripts that alter executable files and shared libraries. +# +# Make sure to back up any important data before proceeding. +# +# Always review and understand scripts from external sources prior to execution. +export bin_source=${1:-https://github.com/daxgames/pacman-for-git/raw/refs/heads/main} +echo "Using binary source: $bin_source" +echo "Using HOME directory: $HOME" +read -rp "Press [Enter] to continue..." + +if [[ "$HOSTTYPE" == "i686" ]]; then + pacman=( + pacman-6.0.0-4-i686.pkg.tar.zst + pacman-mirrors-20210703-1-any.pkg.tar.zst + msys2-keyring-1~20210213-2-any.pkg.tar.zst + ) + + zstd=zstd-1.5.0-1-i686.pkg.tar.xz + zstd_win=https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-v1.5.5-win32.zip +else + pacman=( + pacman-6.0.1-18-x86_64.pkg.tar.zst + pacman-mirrors-20220205-1-any.pkg.tar.zst + msys2-keyring-1~20220623-1-any.pkg.tar.zst + ) + + zstd=zstd-1.5.2-1-x86_64.pkg.tar.xz + zstd_win=https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-v1.5.5-win64.zip +fi + +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Downloading pacman files... +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +for f in "${pacman[@]}"; do + [[ -f "$HOME/Downloads/$f" ]] && continue + echo "Running: curl -sLkf -o \"$HOME/Downloads/$f\" \"${bin_source}/$f\"" + curl -sLkf -o "$HOME/Downloads/$f" "${bin_source}/$f" || exit 1 +done +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Downloading zstd binaries... +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +if [[ ! -f "$HOME/Downloads/$zstd" ]] ; then + echo "Running: curl -sLkf -o \"$HOME/Downloads/$zstd\" \"${bin_source}/$zstd\"" + curl -sLkf -o "$HOME/Downloads/$zstd" "${bin_source}/$zstd" || exit 1 +fi + +if [[ ! -f "$HOME/Downloads/$(basename${zstd_win})" ]] ; then + echo "Running: curl -sLkf -o \"$HOME/Downloads/$(basename \"${zstd_win}\")\" \"$zstd_win\"" + curl -sLkf -o "$HOME/Downloads/$(basename "${zstd_win}")" "$zstd_win" || exit 1 +fi +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Downloading pacman.conf... +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo "Running: curl -Lk https://raw.githubusercontent.com/msys2/MSYS2-packages/7858ee9c236402adf569ac7cff6beb1f883ab67c/pacman/pacman.conf" +curl -sLk https://raw.githubusercontent.com/msys2/MSYS2-packages/7858ee9c236402adf569ac7cff6beb1f883ab67c/pacman/pacman.conf -o /etc/pacman.conf || exit 1 + +pushd "$HOME/Downloads" +[[ -d "$(basename "${zstd_win}" | sed 's/\.zip$//')" ]] && \ + rm -rf "$(basename "${zstd_win}" | sed 's/\.zip$//')" +unzip "$HOME/Downloads/$(basename "${zstd_win}")" +export PATH="$PATH:$HOME/Downloads/$(basename "${zstd_win}" | sed 's/\.zip$//')" +popd +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + +cd / +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Installing pacman files... +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo "Extracting zstd to /usr..." +tar x --xz -vf "$HOME/Downloads/$zstd" usr + +for f in "${pacman[@]}"; do + echo "Extracting $f to /usr and /etc..." + tar x --zstd -vf "$HOME/Downloads/$f" usr etc 2>/dev/null +done +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Initializing pacman... +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +mkdir -p /var/lib/pacman +ln -sf "$(which gettext)" /usr/bin/ +pacman-key --init +pacman-key --populate msys2 +pacman -Syu --noconfirm --disable-download-timeout +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Getting package versions for the installed Git release +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +t=$(grep -E 'mingw-w64-[ix_0-9]+-git ' /etc/package-versions.txt) +echo "Found package version line: $t" + +curl --help >/dev/null 2>&1 || { echo "ERROR: curl is not installed properly."; exit 1; } + +echo "Getting commit ID that matches '$t' from github pacman-for-git..." +t=$(curl -sLk "${bin_source}/version-tags.txt" | grep "$t") +echo "Full line from version-tags.txt: '$t'" + +[[ "$t" == "" ]] && echo "ERROR: Commit ID not logged in github pacman-for-git." && exit 1 +echo -e "Using commit ID: '${t##* }'" +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +echo Downloading package database files for the installed Git release +echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +b=64 && [[ "$t" == *-i686-* ]] && b=32 +URL="https://github.com/git-for-windows/git-sdk-$b/raw/${t##* }" +while read -r p v; do + d="/var/lib/pacman/local/$p-$v" + mkdir -p "$d" + echo "$d" + + for f in desc files mtree; do + curl -fsSL "$URL$d/$f" -o "$d/$f" + done + + [[ ! -f "$d/desc" ]] && rmdir "$d" && echo "Missing $d" +done < /etc/package-versions.txt +echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 00e862592..6147695ba 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -6,14 +6,60 @@ You will need to make this script executable by setting your Powershell Execution Policy to Remote signed Then unblock the script for execution with UnblockFile .\pack.ps1 +.PARAMETER cmderRoot + Path to the Cmder repository root that should be packaged. + + Defaults to the parent directory of this script. +.PARAMETER terminal + Select which terminal package set is included in generated archives: + - all: create all archive variants (default) + - none: exclude both ConEmu and Windows Terminal packages + - conemu-maximus5: include only ConEmu package + - windows-terminal: include only Windows Terminal package +.PARAMETER saveTo + Output directory where archives and hashes.txt are written. + + Defaults to the repository build directory. +.PARAMETER Verbose + Built-in common parameter from CmdletBinding. + + Prints detailed packaging progress and included files. +.PARAMETER WhatIf + Built-in common parameter from CmdletBinding (SupportsShouldProcess). + + Shows what actions would run without making changes. .EXAMPLE .\pack.ps1 Creates default archives for Cmder .EXAMPLE - .\pack.ps1 -verbose + .\pack.ps1 -Verbose Creates default archives for Cmder with plenty of information +.EXAMPLE + .\pack.ps1 -Terminal none + + Create archives without bundled terminal emulator packages. +.EXAMPLE + .\pack.ps1 -Terminal conemu-maximus5 + + Create archives that include ConEmu and exclude Windows Terminal. +.EXAMPLE + .\pack.ps1 -Terminal windows-terminal + + Create archives that include Windows Terminal and exclude ConEmu. +.EXAMPLE + .\pack.ps1 -SaveTo 'C:\temp\cmder-artifacts' + + Write release archives and hashes.txt to a custom output directory. +.EXAMPLE + .\pack.ps1 -CmderRoot 'C:\src\cmder' + + Package a Cmder checkout from a custom repository path. +.EXAMPLE + .\pack.ps1 -WhatIf + + Preview packaging actions without creating or deleting files. .NOTES AUTHORS Samuel Vasko, Jack Bennett, Martin Kemp @@ -56,12 +102,6 @@ if ($terminal -eq "none") { "cmder_wt.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`""; "cmder_wt_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`""; } -} elseif ($terminal -eq "windows-terminal") { - $targets = @{ - "cmder.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\windows-terminal`""; - "cmder.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\windows-terminal`""; - "cmder_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\windows-terminal`""; - } } else { $targets = @{ "cmder_win.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`""; diff --git a/vendor/sources.json b/vendor/sources.json index df1ae3e5f..3f6118fc1 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -1,13 +1,13 @@ [ { "name": "git-for-windows", - "version": "2.52.0.windows.1", - "url": "https://github.com/git-for-windows/git/releases/download/v2.52.0.windows.1/PortableGit-2.52.0-64-bit.7z.exe" + "version": "2.54.0.windows.1", + "url": "https://github.com/git-for-windows/git/releases/download/v2.54.0.windows.1/PortableGit-2.54.0-64-bit.7z.exe" }, { "name": "clink", - "version": "1.9.5", - "url": "https://github.com/chrisant996/clink/releases/download/v1.9.5/clink.1.9.5.ee6b4f.zip" + "version": "1.9.17", + "url": "https://github.com/chrisant996/clink/releases/download/v1.9.17/clink.1.9.17.36e2ca.zip" }, { "name": "conemu-maximus5", @@ -16,8 +16,8 @@ }, { "name": "windows-terminal", - "version": "1.23.12811.0", - "url": "https://github.com/microsoft/terminal/releases/download/v1.23.12811.0/Microsoft.WindowsTerminal_1.23.12811.0_x64.zip" + "version": "1.23.20211.0", + "url": "https://github.com/microsoft/terminal/releases/download/v1.23.20211.0/Microsoft.WindowsTerminal_1.23.20211.0_x64.zip" }, { "name": "clink-completions",