dopler

package module
v0.0.0-...-cfd9981 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: GPL-3.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Dopler

Dopler packs a program into an installable package and installs it. Written in Go; builds with the official Go toolchain only (no cgo, no C compiler).

  • dopler — CLI: init, pack, install, uninstall, info
  • dopler-packer — native GUI packer
  • dopler-installer — native GUI installer; with a package appended it is a self-extracting setup program (dopler pack -installer)

Status: early. Linux GUI (GTK 3) works; Windows (Win32) and macOS (Cocoa) GUIs compile but are untested on real machines.

Output formats (dopler pack -format ...)

Format What it is
dop Dopler package (zip); installed by dopler install or a setup exe
appimage Linux AppImage built in pure Go (embedded type2 runtime + squashfs)
bin the bare executable, for single-file console utilities

dopler install <file> also accepts a bare binary or an AppImage: it is copied to ~/.local/bin (Windows: %LOCALAPPDATA%\Programs\bin) and dopler uninstall <file> removes it. Native OS formats (.deb, .msi, .pkg), Start-menu shortcuts and .app bundles are not planned for now.

Native GUI without cgo

Each OS talks to its own toolkit directly from Go:

OS Toolkit How
Linux GTK 3 loaded at run time with purego (needs libgtk-3)
Windows Win32 golang.org/x/sys/windows
macOS Cocoa purego + Objective-C runtime

As a Go library

Add it to any Go project and write a build script, e.g. cmd/build/main.go:

package main

import "github.com/mefoxdev/dopler-installer"

func main() {
	p := dopler.NewProject("myapp", "1.0.0")
	p.GoPackage = "./cmd/myapp"          // compiled for every target with plain `go build`
	p.Manifest.License = "Proprietary"
	p.Manifest.Targets = map[string]dopler.Target{
		"linux/amd64": {}, "windows/amd64": {}, "darwin/arm64": {},
	}
	dopler.Main(p)
}
go get github.com/mefoxdev/dopler-installer
go run ./cmd/build -format appimage,dop -installer

Per-OS steps are hooks (p.OnBuild("linux", func(ctx *dopler.BuildContext) error {...})), so cmd/build/linux.go, windows.go and darwin.go can each register their own in init(). Use go run ./cmd/build for that; go run ./cmd/build/main.go compiles only that one file. See examples/build/. Setup programs (-installer) are compiled from this module on demand; no prebuilt files needed.

Layout

  • cmd/cli, cmd/packer, cmd/installer — the three programs
  • internal/core — manifest, .dop format, install/uninstall, UI contract
  • internal/linux, internal/windows, internal/macos — OS specifics: install paths, menu/registry integration, native GUI

Build and use

scripts/build.sh                 # dist/dopler, dist/dopler-packer, dist/stubs/*
dist/dopler init                 # writes dopler.json
dist/dopler pack -installer      # out/*.dop and out/*-setup
dist/dopler install out/myapp-1.0.0-linux-amd64.dop
dist/dopler uninstall ~/.local/share/myapp

A .dop is a zip with dopler.json and payload/. Installations keep a receipt in .dopler/, so uninstall removes only what was installed.

License

Dopler's code is licensed under the GNU GPL v3 (LICENSE) with an additional permission (LICENSE-EXCEPTION.md):

  • A program packaged with Dopler keeps its own license — including a proprietary one. Packaging does not make it GPL.
  • Dopler itself stays free: if you modify Dopler, you must provide the source of your modified version under the GPL.

Documentation

Overview

Package dopler is Dopler as a Go library: build, package and install programs from a Go build script in any Go project.

A build script, e.g. cmd/build/main.go:

package main

import "github.com/mefoxdev/dopler-installer"

func main() {
	p := dopler.NewProject("myapp", "1.0.0")
	p.GoPackage = "./cmd/myapp"
	p.Manifest.License = "Proprietary"
	p.Manifest.Targets = map[string]dopler.Target{
		"linux/amd64": {}, "windows/amd64": {}, "darwin/arm64": {},
	}
	dopler.Main(p) // flags: -t -format -o -installer -no-build
}

Run it with "go run ./cmd/build -format appimage,dop". Per-OS steps go into hooks registered with Project.OnBuild, which makes cmd/build/linux.go, windows.go and darwin.go natural places for them.

The package pulls in the Linux, Windows and macOS packages, so every format and platform is available. It needs only the Go toolchain.

Index

Constants

View Source
const ManifestFile = core.FileName

ManifestFile is the default manifest file name.

Variables

This section is empty.

Functions

func FormatNames

func FormatNames() []string

FormatNames lists the available output formats.

func InstallBinary

func InstallBinary(src, dir string) (string, error)

InstallBinary copies a bare binary or AppImage into dir (empty = the platform's bin directory).

func Main

func Main(p *Project)

Main is a ready-made command line for a build script: it parses flags, runs the project and prints the artifacts. It exits the process on error.

-t os/arch,...   targets (default: all in the manifest, or the host)
-format a,b      output formats (default dop)
-o dir           output directory
-installer       also build self-extracting installers
-no-build        do not compile, reuse the staging dirs

func PackageName

func PackageName(m *Manifest, target string) string

PackageName is the file name of the .dop for a target.

func RunUI

func RunUI(spec UISpec, h UIHandler) error

RunUI shows the native window of the host OS and blocks until it closes.

func Uninstall

func Uninstall(dir string, progress Progress) error

Uninstall removes an installation made by Package.Install.

func UninstallBinary

func UninstallBinary(path string) error

UninstallBinary removes a file installed by InstallBinary.

Types

type BuildContext

type BuildContext struct {
	Project *Project
	Target  string // "os/arch"
	GOOS    string
	GOARCH  string
	Dir     string // directory whose contents will be packaged
	Exec    string // main executable, relative to Dir
}

BuildContext is passed to build hooks.

func (*BuildContext) GoBuild

func (c *BuildContext) GoBuild(pkg, name, ldflags string, goFlags ...string) error

GoBuild compiles the Go package pkg (relative to the project's BaseDir) for this target into ctx.Dir as name (".exe" is added on Windows). Extra ldflags are appended to Project.Ldflags; use it from hooks to build several programs into one package, or to vary flags per OS.

type BuildInput

type BuildInput = core.BuildInput

BuildInput is what a Format receives.

type Format

type Format = core.Format

Format is an output format of packing (dop, appimage, bin).

type HookFunc

type HookFunc func(ctx *BuildContext) error

HookFunc runs after a target was compiled and before it is packaged. Use it to add files (assets, licenses, config) to ctx.Dir.

type InstallOptions

type InstallOptions = core.InstallOptions

InstallOptions tunes Package.Install.

type Manifest

type Manifest = core.Manifest

Manifest describes a program (the contents of dopler.json).

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads and validates a dopler.json.

type Package

type Package = core.Package

Package is an opened .dop package or self-extracting installer.

func OpenPackage

func OpenPackage(path string) (*Package, error)

OpenPackage opens a .dop file or a self-extracting installer.

type Progress

type Progress = core.Progress

Progress reports installation progress.

type Project

type Project struct {
	// Manifest describes the program. Targets may be empty (then the
	// requested targets, or the host, are used) and individual Target
	// values may be empty when GoPackage is set.
	Manifest *Manifest

	// BaseDir resolves relative paths; default ".".
	BaseDir string
	// OutDir receives the artifacts; default "out".
	OutDir string
	// BuildDir holds per-target staging dirs and stubs; default ".dopler".
	BuildDir string

	// GoPackage, when set (e.g. "./cmd/myapp"), is compiled with the Go
	// toolchain for every target. When empty, Manifest must name existing
	// directories.
	GoPackage string

	// Ldflags and GoFlags are passed to "go build".
	Ldflags string
	GoFlags []string
	// Env is added to the environment of "go build". CGO_ENABLED defaults
	// to 0 so cross-compilation needs no C compiler.
	Env []string
	// contains filtered or unexported fields
}

Project is a build: a manifest plus how to produce the files to package.

func NewProject

func NewProject(name, version string) *Project

NewProject returns a project for a program called name.

func (*Project) OnBuild

func (p *Project) OnBuild(goos string, f HookFunc)

OnBuild registers a hook for targets of goos ("linux", "windows", "darwin"); an empty goos runs it for every target. Hooks run in the order of registration.

func (*Project) Run

func (p *Project) Run(o RunOptions) ([]string, error)

Run builds every selected target and returns the artifacts written.

type Receipt

type Receipt = core.Receipt

Receipt records what an installation created.

type RunOptions

type RunOptions struct {
	Targets   []string // "os/arch"; empty = all targets of the manifest (or the host)
	Formats   []string // empty = ["dop"]; see FormatNames
	Installer bool     // also build self-extracting installers
	SkipBuild bool     // do not run "go build" (use what is in the staging dirs)
}

RunOptions selects what Project.Run does.

type Target

type Target = core.Target

Target overrides the source dir / executable for one "os/arch".

type UI

type UI = core.UI

RunUI shows a native window described by spec (see core.UISpec).

type UIAction

type UIAction = core.Action

RunUI shows a native window described by spec (see core.UISpec).

type UIField

type UIField = core.Field

RunUI shows a native window described by spec (see core.UISpec).

type UIHandler

type UIHandler = core.UIHandler

RunUI shows a native window described by spec (see core.UISpec).

type UISpec

type UISpec = core.UISpec

RunUI shows a native window described by spec (see core.UISpec).

Directories

Path Synopsis
cmd
cli command
Command cli (built as "dopler") is the command-line client:
Command cli (built as "dopler") is the command-line client:
installer command
Command installer (built as "dopler-installer") is the graphical installer.
Command installer (built as "dopler-installer") is the graphical installer.
packer command
Command packer (built as "dopler-packer") is the graphical packager: pick a manifest and an output folder, get .dop packages and installers.
Command packer (built as "dopler-packer") is the graphical packager: pick a manifest and an output folder, get .dop packages and installers.
examples
build command
Example build script.
Example build script.
build/cmd/hello command
internal
core
Package core holds the OS-independent part of Dopler: the manifest, the .dop package format, install/uninstall logic, the platform registry and the UI contract implemented natively by each OS package.
Package core holds the OS-independent part of Dopler: the manifest, the .dop package format, install/uninstall logic, the platform registry and the UI contract implemented natively by each OS package.
linux
Package linux holds the Linux-specific part of Dopler: install paths, desktop-menu integration and the native (GTK) GUI.
Package linux holds the Linux-specific part of Dopler: install paths, desktop-menu integration and the native (GTK) GUI.
macos
Package macos holds the macOS-specific part of Dopler: install paths, command-line integration and the native (Cocoa) GUI.
Package macos holds the macOS-specific part of Dopler: install paths, command-line integration and the native (Cocoa) GUI.
windows
Package windows holds the Windows-specific part of Dopler: install paths, Add/Remove Programs integration and the native (Win32) GUI.
Package windows holds the Windows-specific part of Dopler: install paths, Add/Remove Programs integration and the native (Win32) GUI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL