Commit d5a30fb3 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

packaging

parent cbea21e1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ Ce dossier contient l'implémentation de `climax`, la CLI utilisée pour gérer
- Outils de packaging optionnels :
  - `pkgbuild` (cible installeur macOS)
  - `makensis` (cible installeur Windows)
  - `dpkg-deb` (cible package Debian)

## Démarrage (Développeur)

+15 −1
Original line number Diff line number Diff line
@@ -8,9 +8,10 @@ MACOS_EXE := $(DIST_DIR)/$(APP_NAME)-darwin-arm64
MACOS_INSTALLER := $(DIST_DIR)/$(APP_NAME)-macos-arm64-unsigned-v$(VERSION).pkg
WINDOWS_EXE := $(DIST_DIR)/$(APP_NAME)-windows-amd64.exe
WINDOWS_INSTALLER := $(DIST_DIR)/$(APP_NAME)-windows-amd64-setup-v$(VERSION).exe
DEB_PACKAGE := $(DIST_DIR)/$(APP_NAME)_$(VERSION)_amd64.deb
NSIS_SCRIPT := packaging/windows-installer.nsi

.PHONY: build test installer-macos installer-windows clean help
.PHONY: build test installer-macos installer-windows installer-deb clean help

build: ## Build cross-platform binaries into dist (linux/amd64, darwin/arm64, windows/amd64)
	mkdir -p $(DIST_DIR)
@@ -45,6 +46,19 @@ installer-windows: ## Build a Windows installer (.exe) with NSIS (requires maken
	makensis -DAPP_NAME="$(APP_NAME)" -DAPP_VERSION="$(VERSION)" -DAPP_EXE_PATH="$(abspath $(WINDOWS_EXE))" -DOUT_PATH="$(abspath $(WINDOWS_INSTALLER))" $(NSIS_SCRIPT)
	@echo "Created $(WINDOWS_INSTALLER)"

installer-deb: ## Build a Debian package (.deb) for linux/amd64 (requires dpkg-deb)
	mkdir -p $(DIST_DIR)
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) -o $(DIST_DIR)/$(APP_NAME)-linux-amd64 .
	@command -v dpkg-deb >/dev/null 2>&1 || { echo "dpkg-deb not found. Install dpkg tooling first."; exit 1; }
	@TMP_DIR=$$(mktemp -d); \
		trap 'rm -rf "$$TMP_DIR"' EXIT; \
		mkdir -p "$$TMP_DIR/DEBIAN" "$$TMP_DIR/usr/local/bin"; \
		cp "$(DIST_DIR)/$(APP_NAME)-linux-amd64" "$$TMP_DIR/usr/local/bin/$(APP_NAME)"; \
		chmod 0755 "$$TMP_DIR/usr/local/bin/$(APP_NAME)"; \
		printf "Package: $(APP_NAME)\nVersion: $(VERSION)\nSection: utils\nPriority: optional\nArchitecture: amd64\nMaintainer: Climax Maintainers\nDescription: Climax CLI for MaX projects\n" > "$$TMP_DIR/DEBIAN/control"; \
		dpkg-deb --build "$$TMP_DIR" "$(DEB_PACKAGE)"; \
		echo "Created $(DEB_PACKAGE)"

clean: ## Remove build artifacts
	rm -rf $(DIST_DIR)

+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ This directory contains the implementation of `climax`, the CLI used to manage [
- Optional packagers:
  - `pkgbuild` (macOS installer target)
  - `makensis` (Windows installer target)
  - `dpkg-deb` (Debian package target)

## Getting Started (Developer)

+33 −10
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@
!include "LogicLib.nsh"
!include "StrFunc.nsh"

!insertmacro StrStr
!insertmacro StrRep
${Using:StrFunc} StrRep
${Using:StrFunc} UnStrRep

!ifndef APP_NAME
  !error "APP_NAME define is required"
@@ -57,13 +57,36 @@ Function AddToUserPath
  ReadRegStr $0 HKCU "Environment" "Path"
  ${If} $0 == ""
    StrCpy $1 "$INSTDIR"
  ${Else}
    StrCpy $2 "$0;"
    ${StrStr} $3 "$2" "$INSTDIR;"
    ${If} $3 == ""
      StrCpy $1 "$0;$INSTDIR"
  ${Else}
    StrCpy $1 "$0"
    ${StrRep} $1 "$1" "$INSTDIR;" ""
    ${StrRep} $1 "$1" ";$INSTDIR" ""
    ${StrRep} $1 "$1" "$INSTDIR" ""

    ; Trim leading semicolons.
    trim_leading_add:
      StrCpy $2 "$1" 1
      ${If} $2 == ";"
        StrCpy $1 "$1" "" 1
        Goto trim_leading_add
      ${EndIf}

    ; Trim trailing semicolons.
    trim_trailing_add:
      StrLen $2 "$1"
      ${If} $2 > 0
        IntOp $3 $2 - 1
        StrCpy $4 "$1" 1 $3
        ${If} $4 == ";"
          StrCpy $1 "$1" $3
          Goto trim_trailing_add
        ${EndIf}
      ${EndIf}

    ${If} $1 == ""
      StrCpy $1 "$INSTDIR"
    ${Else}
      StrCpy $1 "$1;$INSTDIR"
    ${EndIf}
  ${EndIf}
  WriteRegExpandStr HKCU "Environment" "Path" "$1"
@@ -80,9 +103,9 @@ Function un.RemoveFromUserPath
    Return
  ${EndIf}

  ${StrRep} $1 "$0" "$INSTDIR;" ""
  ${StrRep} $1 "$1" ";$INSTDIR" ""
  ${StrRep} $1 "$1" ";;" ";"
  ${UnStrRep} $1 "$0" "$INSTDIR;" ""
  ${UnStrRep} $1 "$1" ";$INSTDIR" ""
  ${UnStrRep} $1 "$1" ";;" ";"

  ; Trim leading semicolons.
  trim_leading: