pkg

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 14 Imported by: 0

README

pkg

a simple c/c++ package manager based on source code.

Usage

  • Quick Start
$ go get -u github.com/genshen/pkg/pkg

# generate a new "package.yaml"
$ pkg init

# install a package,type can be "git", "tar", "files" for now. 
$ pkg fetch <type> <packagename>

# build and install packages from "package.yaml" file.
$ pkg install

# build and install a package specified by argument --pkg.
$ pkg install -pkg=<package_name>  # or: pkg install --pkg <package_name>

Documentation

Index

Constants

View Source
const (
	DlStatusEmpty = iota
	DlStatusSkip
	DlStatusOk
)
View Source
const (
	VendorName        = "vendor"
	VendorCache       = "cache"
	VendorSrc         = "src"
	VendorPkg         = "pkg"
	VendorScripts     = "scripts"
	VendorInclude     = "include"
	VendorLib         = "lib"
	VendorLib64       = "lib64"
	VendorUserHome    = ".pkg"
	VendorUserHomeSrc = "registry/default-pkg/src"
)
View Source
const (
	PkgFileName         = "pkg.yaml"
	PurgePkgSumFileName = "pkg.sum.yaml"
	PkgSumFileName      = VendorName + "/" + PurgePkgSumFileName
	BuildShellName      = "pkg.build.sh"
	CMakeDep            = "pkg.dep.cmake"
	DepGraph            = "pkg.graph"
	CMakeVendorPath     = "${VENDOR_PATH}"
)
View Source
const PKGROOT = "PKG_ROOT"
View Source
const RootPKG = "root"

Variables

This section is empty.

Functions

func AddPathEnv

func AddPathEnv(packageName string, packageSrcPath string) error

pkgRoot: the root directory of pkg.yaml

func AddVendorPathEnv

func AddVendorPathEnv(pkgRoot string)

pkgRoot: the root directory of pkg.yaml

func CheckDir

func CheckDir(path string) error

check if the dir exits,if not create it.

func CheckDirLists

func CheckDirLists(dirs ...string) error

check a list of dirs

func DepTreeRecover

func DepTreeRecover(metas *map[string]PackageMeta, filename string) error

recover the dependency tree from a yaml file. the result is saved in variable deps.

func GetCMakeVendorPkgPath

func GetCMakeVendorPkgPath(packageName string) (path string)

return ${VENDOR_PATH}/pkg/@packageName

func GetCachePath

func GetCachePath(base, packageName string) (path string)

return @base/vendor/cache

func GetDepGraphPath

func GetDepGraphPath(base string) string

func GetHomeSrcPath

func GetHomeSrcPath() (string, error)

return $HOME/.pkg/registry/default-pkg/src

func GetIncludePath

func GetIncludePath(base string) (path string)

return @base/vendor/include

func GetPackageHomeSrcPath

func GetPackageHomeSrcPath(packageName string, version string) (string, error)

func GetPackagePkgPath

func GetPackagePkgPath(base string, packageName string) (path string)

return @base/vendor/pkg/@packageName

func GetPackageSrcPath

func GetPackageSrcPath(base, packageName string) (path string)

return @base/vendor/src/@packageName deprecated

func GetPkgBuildPath

func GetPkgBuildPath(base string) string

func GetPkgIncludePath

func GetPkgIncludePath(base string, packageName string) (path string)

return @base/vendor/pkg/@packageName/include

func GetPkgPath

func GetPkgPath(base string) (path string)

return @base/vendor/pkg

func GetPkgSumPath

func GetPkgSumPath(base string) string

func GetPkgUserHomeFile

func GetPkgUserHomeFile(suffixPath string) (string, error)

func GetVendorPath

func GetVendorPath(base string) string

func LoadListFromGraph

func LoadListFromGraph(graphPath, packageName string) ([]string, error)

func ProcessEnv

func ProcessEnv(origin string) string

replace origin string with args values.

func RelativePath

func RelativePath(base, target string) string

// change path to relative path, replace PKG_DIR with relative path.

func Unzip

func Unzip(src string, dest string) error

FROM https://golangcode.com/unzip-files-in-go/ Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

func UrlJoin

func UrlJoin(base, ele string) string

Types

type ArchivePackage

type ArchivePackage struct {
	Package `yaml:",inline"`
}

type DepPkgContext

type DepPkgContext struct {
	PackageName string
	SrcPath     string
	Version     string
}

type DependencyTree

type DependencyTree struct {
	Context      DepPkgContext
	Dependencies []*DependencyTree
	Builder      []string // outer builder (specified by others pkg,)
	SelfBuild    []string // inner builder (this is specified in package's pkg.yaml file)
	CMakeLib     string   // outer cmake script to add this lib.
	SelfCMakeLib string   // inner cmake script to add this lib.
	DlStatus     int
	IsPkgPackage bool
}

func (*DependencyTree) Dump

func (depTree *DependencyTree) Dump(filename string) error

marshal dependency tree content to a yaml file.

func (*DependencyTree) ListDeps

func (depTree *DependencyTree) ListDeps() ([]string, error)

list all dependencies packages of a package by TraversalDeep.

func (*DependencyTree) MarshalGraph

func (depTree *DependencyTree) MarshalGraph(writer io.Writer) error

dump direct and indirect dependencies packages of all packages.

func (*DependencyTree) Traversal

func (depTree *DependencyTree) Traversal(callback func(*DependencyTree) bool)

traversal all tree node with pre-order. if the return value of callback function is false, it will skip its children nodes.

func (*DependencyTree) TraversalDeep

func (depTree *DependencyTree) TraversalDeep(callback func(*DependencyTree) error) error

traversal all tree node(including the root node) by deep first strategy. if return value of callback is false, then the traversal will break.

func (*DependencyTree) TraversalPreOrder

func (depTree *DependencyTree) TraversalPreOrder(callback func(*DependencyTree) bool) bool

traversal all tree node with pre-order. if the return value of callback function is false, then the traversal will break.

type FilesPackage

type FilesPackage struct {
	Package `yaml:",inline"`
	Files   map[string]string `yaml:"files"`
}

type GitPackage

type GitPackage struct {
	Package `yaml:",inline"`
	Tag     string `yaml:"tag"`    // git tag
	Branch  string `yaml:"branch"` // git branch
	Hash    string `yaml:"hash"`   // git commit hash
}

type Package

type Package struct {
	Path     string `yaml:"path"`
	Override bool   `yaml:"override"` // override package self build.
	//	Dependencies []string          `yaml:"dependencies"`
	Build            []string `yaml:"build"`
	CMakeLib         string   `yaml:"cmake_lib"`
	CMakeLibOverride bool     `yaml:"cmake_lib_override"`
}

type PackageMeta

type PackageMeta struct {
	SrcPath      string   `yaml:"-"`
	Version      string   `yaml:"version"`
	Builder      []string `yaml:"builder"`        // outer builder (lib used by others)
	SelfBuild    []string `yaml:"self_build"`     // inner builder (shows how this package is built)
	CMakeLib     string   `yaml:"cmake_lib"`      // outer cmake script to add this lib.
	SelfCMakeLib string   `yaml:"self_cmake_lib"` // inner cmake script to add this lib.
}

package metadata used in sum file.

type Packages

type Packages struct {
	GitPackages     map[string]GitPackage     `yaml:"git"`
	FilesPackages   map[string]FilesPackage   `yaml:"files"`
	ArchivePackages map[string]ArchivePackage `yaml:"archive"`
}

type Pkg

type Pkg struct {
	Version  int                 `yaml:"version"`
	Args     map[string]string   `yaml:"args"`
	Name     string              `yaml:"name"`
	Packages Packages            `yaml:"packages"`
	Build    map[string][]string `yaml:"build"`
	CMakeLib string              `yaml:"cmake_lib"`
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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