packaging

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DarwinBundlePackagingTask = &packagingTask{
	packagingFormatName: "darwin-bundle",
	templateFiles: map[string]string{
		"darwin-bundle/Info.plist.tmpl.tmpl": "{{.projectName}}-{{`{{.version}}`}}.app/Contents/Info.plist.tmpl",
	},
	executableFiles: []string{},
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
		"RUN apt-get update && apt-get install icnsutils -y",
	},
	buildOutputDirectory:    "{{.projectName}}-{{.version}}.app/Contents/MacOS",
	packagingScriptTemplate: "mkdir -p {{.projectName}}-{{.version}}.app/Contents/Resources && png2icns {{.projectName}}-{{.version}}.app/Contents/Resources/icon.icns {{.projectName}}-{{.version}}.app/Contents/MacOS/assets/icon.png",
	outputFileExtension:     "app",
}

DarwinBundlePackagingTask packaging for darwin as bundle

View Source
var DarwinDmgPackagingTask = &packagingTask{
	packagingFormatName: "darwin-dmg",
	dependsOn: map[*packagingTask]string{
		DarwinBundlePackagingTask: "dmgdir",
	},
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
		"RUN apt-get update && apt-get install genisoimage -y ",
	},
	packagingScriptTemplate: "genisoimage -V '{{.projectName}}' -D -R -apple -no-pad -o '{{.projectName}}-{{.version}}.dmg' dmgdir",
	outputFileExtension:     "dmg",
}

DarwinDmgPackagingTask packaging for darwin as dmg

View Source
var DarwinPkgPackagingTask = &packagingTask{
	packagingFormatName: "darwin-pkg",
	dependsOn: map[*packagingTask]string{
		DarwinBundlePackagingTask: "flat/root/Applications",
	},
	templateFiles: map[string]string{
		"darwin-pkg/PackageInfo.tmpl.tmpl":  "flat/base.pkg/PackageInfo.tmpl",
		"darwin-pkg/Distribution.tmpl.tmpl": "flat/Distribution.tmpl",
	},
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
		"RUN apt-get update && apt-get install cpio git make g++ wget libxml2-dev libssl1.0-dev zlib1g-dev -y",
		"WORKDIR /tmp",
		"RUN git clone https://github.com/hogliux/bomutils && cd bomutils && make > /dev/null && make install > /dev/null",
		"RUN wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/xar/xar-1.5.2.tar.gz && tar -zxvf xar-1.5.2.tar.gz > /dev/null && cd xar-1.5.2 && ./configure > /dev/null && make > /dev/null && make install > /dev/null",
	},
	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 '../{{.projectName}}-{{.version}}.pkg' * )",
	outputFileExtension:     "pkg",
}

DarwinPkgPackagingTask packaging for darwin as pkg

View Source
var LinuxAppImagePackagingTask = &packagingTask{
	packagingFormatName: "linux-appimage",
	templateFiles: map[string]string{
		"linux-appimage/AppRun.tmpl": "AppRun",
		"linux/app.desktop.tmpl":     "{{.projectName}}.desktop",
	},
	executableFiles: []string{
		"AppRun",
		"{{.projectName}}.desktop",
	},
	linuxDesktopFileIconPath: "/build/assets/icon",
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
		"WORKDIR /opt",
		"RUN apt-get update && \\",
		"apt-get install libglib2.0-0 curl file -y",
		"RUN curl -LO https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage && \\",
		"chmod a+x appimagetool-x86_64.AppImage && \\",
		"./appimagetool-x86_64.AppImage --appimage-extract && \\",
		"mv squashfs-root appimagetool && \\",
		"rm appimagetool-x86_64.AppImage",
		"ENV PATH=/opt/appimagetool/usr/bin:$PATH",
	},
	buildOutputDirectory:    "build",
	packagingScriptTemplate: "appimagetool . && mv {{.projectName}}-x86_64.AppImage {{.projectName}}-{{.version}}.AppImage",
	outputFileExtension:     "AppImage",
}

LinuxAppImagePackagingTask packaging for linux as AppImage

View Source
var LinuxDebPackagingTask = &packagingTask{
	packagingFormatName: "linux-deb",
	templateFiles: map[string]string{
		"linux-deb/control.tmpl.tmpl": "DEBIAN/control.tmpl",
		"linux/bin.tmpl":              "usr/bin/{{.projectName}}",
		"linux/app.desktop.tmpl":      "usr/share/applications/{{.projectName}}.desktop",
	},
	executableFiles: []string{
		"usr/bin/{{.projectName}}",
		"usr/share/applications/{{.projectName}}.desktop",
	},
	linuxDesktopFileExecutablePath: "/usr/lib/{{.projectName}}/{{.projectName}}",
	linuxDesktopFileIconPath:       "/usr/lib/{{.projectName}}/assets/icon.png",
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
	},
	buildOutputDirectory:    "usr/lib/{{.projectName}}",
	packagingScriptTemplate: "dpkg-deb --build . {{.projectName}}-{{.version}}.deb",
	outputFileExtension:     "deb",
}

LinuxDebPackagingTask packaging for linux as deb

View Source
var LinuxRpmPackagingTask = &packagingTask{
	packagingFormatName: "linux-rpm",
	templateFiles: map[string]string{
		"linux-rpm/app.spec.tmpl.tmpl": "rpmbuild/SPECS/{{.projectName}}.spec.tmpl",
		"linux/bin.tmpl":               "rpmbuild/BUILDROOT/{{.projectName}}{{`-{{.version}}-{{.version}}`}}.x86_64/usr/bin/{{.projectName}}",
		"linux/app.desktop.tmpl":       "rpmbuild/BUILDROOT/{{.projectName}}{{`-{{.version}}-{{.version}}`}}.x86_64/usr/share/applications/{{.projectName}}.desktop",
	},
	executableFiles: []string{
		"rpmbuild/BUILDROOT/{{.projectName}}-{{.version}}-{{.version}}.x86_64/usr/bin/{{.projectName}}",
		"rpmbuild/BUILDROOT/{{.projectName}}-{{.version}}-{{.version}}.x86_64/usr/share/applications/{{.projectName}}.desktop",
	},
	linuxDesktopFileExecutablePath: "/usr/lib/{{.projectName}}/{{.projectName}}",
	linuxDesktopFileIconPath:       "/usr/lib/{{.projectName}}/assets/icon.png",
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
		"RUN apt-get update && apt-get install rpm file -y",
	},
	buildOutputDirectory:    "rpmbuild/BUILDROOT/{{.projectName}}-{{.version}}-{{.version}}.x86_64/usr/lib/{{.projectName}}",
	packagingScriptTemplate: "rpmbuild --define '_topdir /app/rpmbuild' -ba /app/rpmbuild/SPECS/{{.projectName}}.spec && rm /root/.rpmdb -r && mv rpmbuild/RPMS/x86_64/{{.projectName}}-{{.version}}-{{.version}}.x86_64.rpm {{.projectName}}-{{.version}}.rpm",
	outputFileExtension:     "rpm",
}

LinuxRpmPackagingTask packaging for linux as rpm

View Source
var LinuxSnapPackagingTask = &packagingTask{
	packagingFormatName: "linux-snap",
	templateFiles: map[string]string{
		"linux-snap/snapcraft.yaml.tmpl.tmpl": "snap/snapcraft.yaml.tmpl",
		"linux/app.desktop.tmpl":              "snap/local/{{.projectName}}.desktop",
	},
	linuxDesktopFileExecutablePath: "/{{.projectName}}",
	linuxDesktopFileIconPath:       "/icon.png",
	dockerfileContent: []string{
		"FROM snapcore/snapcraft",
	},
	buildOutputDirectory:    "build",
	packagingScriptTemplate: "snapcraft && mv {{.strippedProjectName}}_{{.version}}_{{.arch}}.snap {{.projectName}}-{{.version}}.snap",
	outputFileExtension:     "snap",
}

LinuxSnapPackagingTask packaging for linux as snao

View Source
var WindowsMsiPackagingTask = &packagingTask{
	packagingFormatName: "windows-msi",
	templateFiles: map[string]string{
		"windows-msi/app.wxs.tmpl.tmpl": "{{.projectName}}.wxs.tmpl",
	},
	dockerfileContent: []string{
		"FROM ubuntu:bionic",
		"RUN apt-get update && apt-get install wixl imagemagick -y",
	},
	buildOutputDirectory:    "build",
	packagingScriptTemplate: "convert -resize x16 build/assets/icon.png build/assets/icon.ico && wixl -v {{.projectName}}.wxs && mv {{.projectName}}.msi {{.projectName}}-{{.version}}.msi",
	outputFileExtension:     "msi",
	generateBuildFiles: func(projectName, 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", projectName, err)
			os.Exit(1)
		}
		directoriesFile, err := os.Create(directoriesFilePath)
		if err != nil {
			log.Errorf("Failed to create directories.wxi file %s: %v", projectName, 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", projectName, err)
			os.Exit(1)
		}
		directoryRefsFile, err := os.Create(directoryRefsFilePath)
		if err != nil {
			log.Errorf("Failed to create directory_refs.wxi file %s: %v", projectName, 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", projectName, err)
			os.Exit(1)
		}
		componentRefsFile, err := os.Create(componentRefsFilePath)
		if err != nil {
			log.Errorf("Failed to create component_refs.wxi file %s: %v", projectName, err)
			os.Exit(1)
		}
		directoriesFileContent = append(directoriesFileContent, `<Include>`)
		directoryRefsFileContent = append(directoryRefsFileContent, `<Include>`)
		componentRefsFileContent = append(componentRefsFileContent, `<Include>`)
		processFiles(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", projectName, err)
				os.Exit(1)
			}
		}
		err = directoriesFile.Close()
		if err != nil {
			log.Errorf("Could not close directories.wxi: %v", projectName, 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", projectName, err)
				os.Exit(1)
			}
		}
		err = directoryRefsFile.Close()
		if err != nil {
			log.Errorf("Could not close directory_refs.wxi: %v", projectName, 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", projectName, err)
				os.Exit(1)
			}
		}
		err = componentRefsFile.Close()
		if err != nil {
			log.Errorf("Could not close component_refs.wxi: %v", projectName, err)
			os.Exit(1)
		}
	},
}

WindowsMsiPackagingTask packaging for windows as msi

Functions

func AssertDockerInstalled

func AssertDockerInstalled()

AssertDockerInstalled check if docker is installed on the host os, otherwise exits with an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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