Skip to content

Commit

Permalink
feat: add dfcache rpm/deb packages and man pages and publish in gorel…
Browse files Browse the repository at this point in the history
…easer (dragonflyoss#1259)

add goreleaser dfcache rpm/deb packages and man pages

Note that dfcache*.md files are generated by `dfcache doc` command.

Signed-off-by: Eryu Guan <[email protected]>
  • Loading branch information
eryugey authored Apr 18, 2022
1 parent 96bdf9f commit 3582336
Show file tree
Hide file tree
Showing 19 changed files with 870 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ builds:
- -X "d7y.io/dragonfly/v2/version.Gotags=none"
- -X "d7y.io/dragonfly/v2/version.Gogcflags=none"

- main: ./cmd/dfcache
id: dfcache
binary: dfcache
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -X d7y.io/dragonfly/v2/version.Major={{ .Major }}
- -X d7y.io/dragonfly/v2/version.Minor={{ .Minor }}
- -X d7y.io/dragonfly/v2/version.GitVersion={{ .Tag }}
- -X d7y.io/dragonfly/v2/version.GitCommit={{ .ShortCommit }}
- -X d7y.io/dragonfly/v2/version.BuildTime={{ .Date }}
- -X "d7y.io/dragonfly/v2/version.Gotags=none"
- -X "d7y.io/dragonfly/v2/version.Gogcflags=none"

- main: ./cmd/scheduler
id: scheduler
binary: scheduler
Expand Down Expand Up @@ -138,3 +155,45 @@ nfpms:
postinstall: build/package/nfpm/dfget-postinstall.sh
preremove: build/package/nfpm/dfget-preremove.sh
postremove: build/package/nfpm/dfget-postremove.sh
- id: dfcache
file_name_template: "dfcache-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
package_name: dfcache
description: dfcache is the cache client to of dragonfly that communicates with dfdaemon and operates on files in P2P network
license: "Apache 2.0"
homepage: https://d7y.io
bindir: /usr/bin
builds:
- dfcache
formats:
- rpm
- deb
contents:
- src: build/package/docs/dfcache/dfcache.1
dst: /usr/share/man/man1/dfcache.1

- src: build/package/docs/dfcache/dfcache-delete.1
dst: /usr/share/man/man1/dfcache-delete.1

- src: build/package/docs/dfcache/dfcache-doc.1
dst: /usr/share/man/man1/dfcache-doc.1

- src: build/package/docs/dfcache/dfcache-export.1
dst: /usr/share/man/man1/dfcache-export.1

- src: build/package/docs/dfcache/dfcache-import.1
dst: /usr/share/man/man1/dfcache-import.1

- src: build/package/docs/dfcache/dfcache-plugin.1
dst: /usr/share/man/man1/dfcache-plugin.1

- src: build/package/docs/dfcache/dfcache-stat.1
dst: /usr/share/man/man1/dfcache-stat.1

- src: build/package/docs/dfcache/dfcache-version.1
dst: /usr/share/man/man1/dfcache-version.1

- src: LICENSE
dst: /usr/share/doc/dfcache/License

- src: CHANGELOG.md
dst: /usr/share/doc/dfcache/ChangeLog
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

PROJECT_NAME := "d7y.io/dragonfly/v2"
DFGET_NAME := "dfget"
DFCACHE_NAME := "dfcache"
SEMVER := "2.0.1"
VERSION_RELEASE := "1"
PKG := "$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/ | grep -v '\(/test/\)')
GIT_COMMIT := $(shell git rev-parse --verify HEAD --short=7)
GIT_COMMIT_LONG := $(shell git rev-parse --verify HEAD)
DFGET_ARCHIVE_PREFIX := "$(DFGET_NAME)_$(SEMVER)-$(VERSION_RELEASE)_$(GIT_COMMIT)"
DFCACHE_ARCHIVE_PREFIX := "$(DFCACHE_NAME)_$(SEMVER)-$(VERSION_RELEASE)_$(GIT_COMMIT)"

all: help

Expand Down Expand Up @@ -186,6 +188,23 @@ build-rpm-dfget: build-linux-dfget
@echo "Build package output: ./bin/$(DFGET_ARCHIVE_PREFIX)_linux_amd64.rpm"
.PHONY: build-rpm-dfget

# Build rpm dfcache
build-rpm-dfcache: build-linux-dfcache build-dfcache-man-page
@echo "Begin to build rpm dfcache"
@docker run --rm \
-v "$(PWD)/build:/root/build" \
-v "$(PWD)/build/package/docs:/root/docs" \
-v "$(PWD)/LICENSE:/root/License" \
-v "$(PWD)/CHANGELOG.md:/root/CHANGELOG.md" \
-v "$(PWD)/bin:/root/bin" \
-e "SEMVER=$(SEMVER)" \
-e "VERSION_RELEASE=$(VERSION_RELEASE)" \
goreleaser/nfpm pkg \
--config /root/build/package/nfpm/dfcache.yaml \
--target /root/bin/$(DFCACHE_ARCHIVE_PREFIX)_linux_amd64.rpm
@echo "Build package output: ./bin/$(DFCACHE_ARCHIVE_PREFIX)_linux_amd64.rpm"
.PHONY: build-rpm-dfcache

# Build deb dfget
build-deb-dfget: build-linux-dfget
@echo "Begin to build deb dfget"
Expand All @@ -203,11 +222,40 @@ build-deb-dfget: build-linux-dfget
@echo "Build package output: ./bin/$(DFGET_ARCHIVE_PREFIX)_linux_amd64.deb"
.PHONY: build-deb-dfget

# Build deb dfcache
build-deb-dfcache: build-linux-dfcache build-dfcache-man-page
@echo "Begin to build deb dfcache"
@docker run --rm \
-v "$(PWD)/build:/root/build" \
-v "$(PWD)/build/package/docs:/root/docs" \
-v "$(PWD)/LICENSE:/root/License" \
-v "$(PWD)/CHANGELOG.md:/root/CHANGELOG.md" \
-v "$(PWD)/bin:/root/bin" \
-e "SEMVER=$(SEMVER)" \
-e "VERSION_RELEASE=$(VERSION_RELEASE)" \
goreleaser/nfpm pkg \
--config /root/build/package/nfpm/dfcache.yaml \
--target /root/bin/$(DFCACHE_ARCHIVE_PREFIX)_linux_amd64.deb
@echo "Build package output: ./bin/$(DFCACHE_ARCHIVE_PREFIX)_linux_amd64.deb"
.PHONY: build-deb-dfcache

# Generate dfget man page
build-dfget-man-page:
@pandoc -s -t man ./build/package/docs/dfget.1.md -o ./build/package/docs/dfget.1
.PHONY: build-dfget-man-page

# Genrate dfcache man pages
build-dfcache-man-page:
@pandoc -s -t man ./build/package/docs/dfcache/dfcache.md -o ./build/package/docs/dfcache/dfcache.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_delete.md -o ./build/package/docs/dfcache/dfcache-delete.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_doc.md -o ./build/package/docs/dfcache/dfcache-doc.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_export.md -o ./build/package/docs/dfcache/dfcache-export.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_import.md -o ./build/package/docs/dfcache/dfcache-import.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_plugin.md -o ./build/package/docs/dfcache/dfcache-plugin.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_stat.md -o ./build/package/docs/dfcache/dfcache-stat.1
@pandoc -s -t man ./build/package/docs/dfcache/dfcache_version.md -o ./build/package/docs/dfcache/dfcache-version.1
.PHONY: build-dfcache-man-page

# Generate e2e sha256sum
build-e2e-sha256sum:
@GOOS=linux GOARCH=amd64 go build -o /tmp/sha256sum-offset test/tools/sha256sum-offset/main.go
Expand Down Expand Up @@ -345,8 +393,11 @@ help:
@echo "make install-scheduler install scheduler"
@echo "make install-manager install manager"
@echo "make build-rpm-dfget build rpm dfget"
@echo "make build-rpm-dfcache build rpm dfcache"
@echo "make build-deb-dfget build deb dfget"
@echo "make build-deb-dfcache build deb dfcache"
@echo "make build-dfget-man-page generate dfget man page"
@echo "make build-dfcache-man-page generate dfcache man page"
@echo "make test run unit tests"
@echo "make test-coverage run tests with coverage"
@echo "make actions-e2e-test-coverage run github actons E2E tests with coverage"
Expand Down
44 changes: 44 additions & 0 deletions build/package/docs/dfcache/dfcache-delete.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.\" Automatically generated by Pandoc 2.14.0.3
.\"
.TH "DFCACHE" "1" "" "Version v2.0.2" "Frivolous \[lq]Dfcache\[rq] Documentation"
.hy
.SS dfcache delete
.PP
delete file from P2P cache system
.SS Synopsis
.PP
delete file from P2P cache system
.IP
.nf
\f[C]
dfcache delete <-i cid> [flags]
\f[R]
.fi
.SS Options
.IP
.nf
\f[C]
-h, --help help for delete
\f[R]
.fi
.SS Options inherited from parent commands
.IP
.nf
\f[C]
--callsystem string The caller name which is mainly used for statistics and access control
-i, --cid string content or cache ID, e.g. sha256 digest of the content
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
--console whether logger output records to the stdout
--jaeger string jaeger endpoint url, like: http://localhost:14250/api/traces
--logdir string Dfcache log directory
--pprof-port int listen port for pprof, 0 represents random port (default -1)
--service-name string name of the service for tracer (default \[dq]dragonfly-dfcache\[dq])
-t, --tag string different tags for the same cid will be recognized as different files in P2P network
--timeout duration Timeout for this cache operation, 0 is infinite
--verbose whether logger use debug level
--workhome string Dfcache working directory
\f[R]
.fi
.SS SEE ALSO
.IP \[bu] 2
dfcache - the P2P cache client of dragonfly
45 changes: 45 additions & 0 deletions build/package/docs/dfcache/dfcache-doc.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.\" Automatically generated by Pandoc 2.14.0.3
.\"
.TH "DFCACHE" "1" "" "Version v2.0.2" "Frivolous \[lq]Dfcache\[rq] Documentation"
.hy
.SS dfcache doc
.PP
generate documents
.SS Synopsis
.PP
generate markdown documents for cmd: dfcache .
.IP
.nf
\f[C]
dfcache doc [flags]
\f[R]
.fi
.SS Options
.IP
.nf
\f[C]
-h, --help help for doc
--path string destination dir of generated markdown documents (default \[dq]./\[dq])
\f[R]
.fi
.SS Options inherited from parent commands
.IP
.nf
\f[C]
--callsystem string The caller name which is mainly used for statistics and access control
-i, --cid string content or cache ID, e.g. sha256 digest of the content
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
--console whether logger output records to the stdout
--jaeger string jaeger endpoint url, like: http://localhost:14250/api/traces
--logdir string Dfcache log directory
--pprof-port int listen port for pprof, 0 represents random port (default -1)
--service-name string name of the service for tracer (default \[dq]dragonfly-dfcache\[dq])
-t, --tag string different tags for the same cid will be recognized as different files in P2P network
--timeout duration Timeout for this cache operation, 0 is infinite
--verbose whether logger use debug level
--workhome string Dfcache working directory
\f[R]
.fi
.SS SEE ALSO
.IP \[bu] 2
dfcache - the P2P cache client of dragonfly
46 changes: 46 additions & 0 deletions build/package/docs/dfcache/dfcache-export.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.\" Automatically generated by Pandoc 2.14.0.3
.\"
.TH "DFCACHE" "1" "" "Version v2.0.2" "Frivolous \[lq]Dfcache\[rq] Documentation"
.hy
.SS dfcache export
.PP
export file from P2P cache system
.SS Synopsis
.PP
export file from P2P cache system
.IP
.nf
\f[C]
dfcache export <-i cid> <output>|<-O output> [flags]
\f[R]
.fi
.SS Options
.IP
.nf
\f[C]
-h, --help help for export
-l, --local only export file from local cache
-O, --output string export file path
\f[R]
.fi
.SS Options inherited from parent commands
.IP
.nf
\f[C]
--callsystem string The caller name which is mainly used for statistics and access control
-i, --cid string content or cache ID, e.g. sha256 digest of the content
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
--console whether logger output records to the stdout
--jaeger string jaeger endpoint url, like: http://localhost:14250/api/traces
--logdir string Dfcache log directory
--pprof-port int listen port for pprof, 0 represents random port (default -1)
--service-name string name of the service for tracer (default \[dq]dragonfly-dfcache\[dq])
-t, --tag string different tags for the same cid will be recognized as different files in P2P network
--timeout duration Timeout for this cache operation, 0 is infinite
--verbose whether logger use debug level
--workhome string Dfcache working directory
\f[R]
.fi
.SS SEE ALSO
.IP \[bu] 2
dfcache - the P2P cache client of dragonfly
45 changes: 45 additions & 0 deletions build/package/docs/dfcache/dfcache-import.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.\" Automatically generated by Pandoc 2.14.0.3
.\"
.TH "DFCACHE" "1" "" "Version v2.0.2" "Frivolous \[lq]Dfcache\[rq] Documentation"
.hy
.SS dfcache import
.PP
import file into P2P cache system
.SS Synopsis
.PP
import file into P2P cache system
.IP
.nf
\f[C]
dfcache import <-i cid> <file>|<-I file> [flags]
\f[R]
.fi
.SS Options
.IP
.nf
\f[C]
-h, --help help for import
-I, --input string import the given file into P2P network
\f[R]
.fi
.SS Options inherited from parent commands
.IP
.nf
\f[C]
--callsystem string The caller name which is mainly used for statistics and access control
-i, --cid string content or cache ID, e.g. sha256 digest of the content
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
--console whether logger output records to the stdout
--jaeger string jaeger endpoint url, like: http://localhost:14250/api/traces
--logdir string Dfcache log directory
--pprof-port int listen port for pprof, 0 represents random port (default -1)
--service-name string name of the service for tracer (default \[dq]dragonfly-dfcache\[dq])
-t, --tag string different tags for the same cid will be recognized as different files in P2P network
--timeout duration Timeout for this cache operation, 0 is infinite
--verbose whether logger use debug level
--workhome string Dfcache working directory
\f[R]
.fi
.SS SEE ALSO
.IP \[bu] 2
dfcache - the P2P cache client of dragonfly
44 changes: 44 additions & 0 deletions build/package/docs/dfcache/dfcache-plugin.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.\" Automatically generated by Pandoc 2.14.0.3
.\"
.TH "DFCACHE" "1" "" "Version v2.0.2" "Frivolous \[lq]Dfcache\[rq] Documentation"
.hy
.SS dfcache plugin
.PP
show plugin
.SS Synopsis
.PP
show the plugin details of dragonfly.
.IP
.nf
\f[C]
dfcache plugin [flags]
\f[R]
.fi
.SS Options
.IP
.nf
\f[C]
-h, --help help for plugin
\f[R]
.fi
.SS Options inherited from parent commands
.IP
.nf
\f[C]
--callsystem string The caller name which is mainly used for statistics and access control
-i, --cid string content or cache ID, e.g. sha256 digest of the content
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
--console whether logger output records to the stdout
--jaeger string jaeger endpoint url, like: http://localhost:14250/api/traces
--logdir string Dfcache log directory
--pprof-port int listen port for pprof, 0 represents random port (default -1)
--service-name string name of the service for tracer (default \[dq]dragonfly-dfcache\[dq])
-t, --tag string different tags for the same cid will be recognized as different files in P2P network
--timeout duration Timeout for this cache operation, 0 is infinite
--verbose whether logger use debug level
--workhome string Dfcache working directory
\f[R]
.fi
.SS SEE ALSO
.IP \[bu] 2
dfcache - the P2P cache client of dragonfly
Loading

0 comments on commit 3582336

Please sign in to comment.