packaging

package
v0.41.5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DarwinBundleTask = &packagingTask{
	packagingFormatName: "darwin-bundle",
	templateFiles: map[string]string{
		"darwin-bundle/Info.plist.tmpl": "{{.applicationName}} {{.version}}.app/Contents/Info.plist.tmpl",
	},
	executableFiles:               []string{},
	buildOutputDirectory:          "{{.applicationName}} {{.version}}.app/Contents/MacOS",
	packagingScriptTemplate:       "mkdir -p \"{{.applicationName}} {{.version}}.app/Contents/Resources\" && png2icns \"{{.applicationName}} {{.version}}.app/Contents/Resources/icon.icns\" \"{{.applicationName}} {{.version}}.app/Contents/MacOS/assets/icon.png\"",
	outputFileExtension:           "app",
	outputFileContainsVersion:     true,
	outputFileUsesApplicationName: true,
}

DarwinBundleTask packaging for darwin as bundle

View Source
var DarwinDmgTask = &packagingTask{
	packagingFormatName: "darwin-dmg",
	dependsOn: map[*packagingTask]string{
		DarwinBundleTask: "dmgdir",
	},
	packagingScriptTemplate:       "ln -sf /Applications dmgdir/Applications && genisoimage -V {{.packageName}} -D -R -apple -no-pad -o \"{{.applicationName}} {{.version}}.dmg\" dmgdir",
	outputFileExtension:           "dmg",
	outputFileContainsVersion:     true,
	outputFileUsesApplicationName: true,
	skipAssertInitialized:         true,
}

DarwinDmgTask packaging for darwin as dmg

View Source
var DarwinPkgTask = &packagingTask{
	packagingFormatName: "darwin-pkg",
	dependsOn: map[*packagingTask]string{
		DarwinBundleTask: "flat/root/Applications",
	},
	templateFiles: map[string]string{
		"darwin-pkg/PackageInfo.tmpl":  "flat/base.pkg/PackageInfo.tmpl",
		"darwin-pkg/Distribution.tmpl": "flat/Distribution.tmpl",
	},
	packagingScriptTemplate:       "(cd flat/root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Payload && mkbom -u 0 -g 80 flat/root flat/base.pkg/Bom && (cd flat && xar --compression none -cf \"../{{.applicationName}} {{.version}}.pkg\" * )",
	outputFileExtension:           "pkg",
	outputFileContainsVersion:     true,
	outputFileUsesApplicationName: true,
}

DarwinPkgTask packaging for darwin as pkg

View Source
var LinuxAppImageTask = &packagingTask{
	packagingFormatName: "linux-appimage",
	templateFiles: map[string]string{
		"linux-appimage/AppRun.tmpl": "AppRun.tmpl",
		"linux/app.desktop.tmpl":     "{{.executableName}}.desktop.tmpl",
	},
	executableFiles: []string{
		"AppRun",
		"{{.executableName}}.desktop",
	},
	linuxDesktopFileIconPath:      "/build/assets/icon",
	buildOutputDirectory:          "build",
	packagingScriptTemplate:       "appimagetool . && mv -n {{.executableName}}-x86_64.AppImage {{.packageName}}-{{.version}}.AppImage",
	outputFileExtension:           "AppImage",
	outputFileContainsVersion:     true,
	outputFileUsesApplicationName: false,
}

LinuxAppImageTask packaging for linux as AppImage

View Source
var LinuxDebTask = &packagingTask{
	packagingFormatName: "linux-deb",
	templateFiles: map[string]string{
		"linux-deb/control.tmpl": "DEBIAN/control.tmpl",
		"linux/bin.tmpl":         "usr/bin/{{.executableName}}.tmpl",
		"linux/app.desktop.tmpl": "usr/share/applications/{{.executableName}}.desktop.tmpl",
	},
	executableFiles: []string{
		"usr/bin/{{.executableName}}",
		"usr/share/applications/{{.executableName}}.desktop",
	},
	linuxDesktopFileExecutablePath: "/usr/lib/{{.packageName}}/{{.executableName}}",
	linuxDesktopFileIconPath:       "/usr/lib/{{.packageName}}/assets/icon.png",
	buildOutputDirectory:           "usr/lib/{{.packageName}}",
	packagingScriptTemplate:        "dpkg-deb --build . {{.packageName}}-{{.version}}.deb",
	outputFileExtension:            "deb",
	outputFileContainsVersion:      true,
	outputFileUsesApplicationName:  false,
}

LinuxDebTask packaging for linux as deb

View Source
var LinuxPkgTask = &packagingTask{
	packagingFormatName: "linux-pkg",
	templateFiles: map[string]string{
		"linux-pkg/PKGBUILD.tmpl": "PKGBUILD.tmpl",
		"linux/bin.tmpl":          "src/usr/bin/{{.executableName}}.tmpl",
		"linux/app.desktop.tmpl":  "src/usr/share/applications/{{.executableName}}.desktop.tmpl",
	},
	executableFiles: []string{
		"src/usr/bin/{{.executableName}}",
		"src/usr/share/applications/{{.executableName}}.desktop",
	},
	linuxDesktopFileExecutablePath: "/usr/lib/{{.packageName}}/{{.executableName}}",
	linuxDesktopFileIconPath:       "/usr/lib/{{.packageName}}/assets/icon.png",
	buildOutputDirectory:           "src/usr/lib/{{.packageName}}",
	packagingScriptTemplate:        "makepkg && mv -n {{.packageName}}-{{.version}}-{{.release}}-x86_64.pkg.tar.xz {{.packageName}}-{{.version}}.pkg.tar.xz",
	outputFileExtension:            "pkg.tar.xz",
	outputFileContainsVersion:      true,
	outputFileUsesApplicationName:  false,
}

LinuxPkgTask packaging for linux as pacman pkg

View Source
var LinuxRpmTask = &packagingTask{
	packagingFormatName: "linux-rpm",
	templateFiles: map[string]string{
		"linux-rpm/app.spec.tmpl": "SPECS/{{.packageName}}.spec.tmpl",
		"linux/bin.tmpl":          "BUILDROOT/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/bin/{{.executableName}}.tmpl",
		"linux/app.desktop.tmpl":  "BUILDROOT/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/share/applications/{{.executableName}}.desktop.tmpl",
	},
	executableFiles: []string{
		"BUILDROOT/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/bin/{{.executableName}}",
		"BUILDROOT/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/share/applications/{{.executableName}}.desktop",
	},
	linuxDesktopFileExecutablePath: "/usr/lib/{{.packageName}}/{{.executableName}}",
	linuxDesktopFileIconPath:       "/usr/lib/{{.packageName}}/assets/icon.png",
	buildOutputDirectory:           "BUILD/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/lib/{{.packageName}}",
	packagingScriptTemplate:        "rpmbuild --define \"_topdir $(pwd)\" --define \"_unpackaged_files_terminate_build 0\" -ba ./SPECS/{{.packageName}}.spec && mv -n RPMS/x86_64/{{.packageName}}-{{.version}}-{{.release}}.x86_64.rpm {{.packageName}}-{{.version}}.rpm",
	outputFileExtension:            "rpm",
	outputFileContainsVersion:      true,
	outputFileUsesApplicationName:  false,
}

LinuxRpmTask packaging for linux as rpm

View Source
var LinuxSnapTask = &packagingTask{
	packagingFormatName: "linux-snap",
	templateFiles: map[string]string{
		"linux-snap/snapcraft.yaml.tmpl": "snap/snapcraft.yaml.tmpl",
		"linux/app.desktop.tmpl":         "snap/local/{{.executableName}}.desktop.tmpl",
	},
	linuxDesktopFileExecutablePath: "/{{.executableName}}",
	linuxDesktopFileIconPath:       "/icon.png",
	buildOutputDirectory:           "build",
	packagingScriptTemplate:        "snapcraft && mv -n {{.packageName}}_{{.version}}_{{.arch}}.snap {{.packageName}}-{{.version}}.snap",
	outputFileExtension:            "snap",
	outputFileContainsVersion:      true,
	outputFileUsesApplicationName:  false,
}

LinuxSnapTask packaging for linux as snap

View Source
var WindowsMsiTask = &packagingTask{
	packagingFormatName: "windows-msi",
	templateFiles: map[string]string{
		"windows-msi/app.wxs.tmpl": "{{.packageName}}.wxs.tmpl",
	},
	buildOutputDirectory:          "build",
	packagingScriptTemplate:       "convert -resize x16 build/assets/icon.png build/assets/icon.ico && wixl -v {{.packageName}}.wxs && mv -n {{.packageName}}.msi \"{{.applicationName}} {{.version}}.msi\"",
	outputFileExtension:           "msi",
	outputFileContainsVersion:     true,
	outputFileUsesApplicationName: true,
	generateBuildFiles: func(packageName, tmpPath string) {
		directoriesFilePath, err := filepath.Abs(filepath.Join(tmpPath, "directories.wxi"))
		if err != nil {
			log.Errorf("Failed to resolve absolute path for directories.wxi file %s: %v", packageName, err)
			os.Exit(1)
		}
		directoriesFile, err := os.Create(directoriesFilePath)
		if err != nil {
			log.Errorf("Failed to create directories.wxi file %s: %v", packageName, err)
			os.Exit(1)
		}
		directoryRefsFilePath, err := filepath.Abs(filepath.Join(tmpPath, "directory_refs.wxi"))
		if err != nil {
			log.Errorf("Failed to resolve absolute path for directory_refs.wxi file %s: %v", packageName, err)
			os.Exit(1)
		}
		directoryRefsFile, err := os.Create(directoryRefsFilePath)
		if err != nil {
			log.Errorf("Failed to create directory_refs.wxi file %s: %v", packageName, err)
			os.Exit(1)
		}
		componentRefsFilePath, err := filepath.Abs(filepath.Join(tmpPath, "component_refs.wxi"))
		if err != nil {
			log.Errorf("Failed to resolve absolute path for component_refs.wxi file %s: %v", packageName, err)
			os.Exit(1)
		}
		componentRefsFile, err := os.Create(componentRefsFilePath)
		if err != nil {
			log.Errorf("Failed to create component_refs.wxi file %s: %v", packageName, err)
			os.Exit(1)
		}
		directoriesFileContent = append(directoriesFileContent, `<Include>`)
		directoryRefsFileContent = append(directoryRefsFileContent, `<Include>`)
		componentRefsFileContent = append(componentRefsFileContent, `<Include>`)
		windowsMsiProcessFiles(filepath.Join(tmpPath, "build", "flutter_assets"))
		directoriesFileContent = append(directoriesFileContent, `</Include>`)
		directoryRefsFileContent = append(directoryRefsFileContent, `</Include>`)
		componentRefsFileContent = append(componentRefsFileContent, `</Include>`)

		for _, line := range directoriesFileContent {
			if _, err := directoriesFile.WriteString(line + "\n"); err != nil {
				log.Errorf("Could not write directories.wxi: %v", packageName, err)
				os.Exit(1)
			}
		}
		err = directoriesFile.Close()
		if err != nil {
			log.Errorf("Could not close directories.wxi: %v", packageName, err)
			os.Exit(1)
		}
		for _, line := range directoryRefsFileContent {
			if _, err := directoryRefsFile.WriteString(line + "\n"); err != nil {
				log.Errorf("Could not write directory_refs.wxi: %v", packageName, err)
				os.Exit(1)
			}
		}
		err = directoryRefsFile.Close()
		if err != nil {
			log.Errorf("Could not close directory_refs.wxi: %v", packageName, err)
			os.Exit(1)
		}
		for _, line := range componentRefsFileContent {
			if _, err := componentRefsFile.WriteString(line + "\n"); err != nil {
				log.Errorf("Could not write component_refs.wxi: %v", packageName, err)
				os.Exit(1)
			}
		}
		err = componentRefsFile.Close()
		if err != nil {
			log.Errorf("Could not close component_refs.wxi: %v", packageName, err)
			os.Exit(1)
		}
	},
}

WindowsMsiTask packaging for windows as msi

Functions

This section is empty.

Types

type Task added in v0.40.0

type Task interface {
	Name() string
	Init()
	IsInitialized() bool
	AssertInitialized()
	Pack(buildVersion string)
}

Task contains all configuration options for a given packaging method. TODO: Rename to something that suits it more? Mabe Executor?

var NoopTask Task = &noopTask{}

Jump to

Keyboard shortcuts

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