diff --git a/Makefile b/Makefile index 4a6a79a..e44ea87 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,14 @@ VERSION = dev_$(shell date +%F_%T) GOCMD = go LDFLAGS := "$(LDFLAGS) -X 'main.Version=$(VERSION)'" GOBUILD = $(GOCMD) build -ldflags=$(LDFLAGS) -SRCMAIN = . +SRCMAIN = ./cmd/$(NAME) BINDIR = bin BIN = $(BINDIR)/$(NAME) +README = ./doc/README +LICENSE = LICENSE PREFIX = /usr -.PHONY: all prep build check-build freebsd-386 darwin-386 linux-386 windows-386 freebsd-amd64 darwin-amd64 linux-amd64 windows-amd64 compile install check-install uninstall clean +.PHONY: all prep build doc check-build freebsd-386 darwin-386 linux-386 windows-386 freebsd-amd64 darwin-amd64 linux-amd64 windows-amd64 compile install check-install uninstall clean all: build @@ -18,6 +20,10 @@ prep: clean build: prep $(GOBUILD) -o $(BIN) $(SRCMAIN) + +doc: check-build + test -d ./doc || mkdir ./doc + $(BIN) --help > ./doc/README check-build: test -e $(BIN) @@ -48,15 +54,25 @@ windows-amd64: prep compile: freebsd-386 darwin-386 linux-386 windows-386 freebsd-amd64 darwin-amd64 linux-amd64 windows-amd64 -install: check-build - install -m 755 -d $(PREFIX)/bin/ - install -m 755 $(BIN) $(PREFIX)/bin/ +install: check-build doc + install -m 755 -d $(PREFIX)/bin/ + install -m 755 $(BIN) $(PREFIX)/bin/ + install -m 755 -d $(PREFIX)/share/licenses/$(NAME)/ + install -m 644 $(LICENSE) $(PREFIX)/share/licenses/$(NAME)/ + install -m 755 -d $(PREFIX)/share/licenses/$(NAME)/go-perceptualhash + install -m 644 ./third_party/go-perceptualhash/LICENSE $(PREFIX)/share/licenses/$(NAME)/go-perceptualhash + install -m 755 -d $(PREFIX)/share/doc/$(NAME)/ + install -m 644 $(README) $(PREFIX)/share/doc/$(NAME)/ check-install: - test -e $(PREFIX)/bin/$(NAME) + test -e $(PREFIX)/bin/$(NAME) || \ + test -d $(PREFIX)/share/licenses/$(NAME) || \ + test -d $(PREFIX)/share/doc/$(NAME) uninstall: check-install rm -f $(PREFIX)/bin/$(NAME) + rm -rf $(PREFIX)/share/licenses/$(NAME) + rm -rf $(PREFIX)/share/doc/$(NAME) clean: rm -rf $(BINDIR) diff --git a/args.go b/cmd/range-gen/args.go similarity index 98% rename from args.go rename to cmd/range-gen/args.go index 529f5da..a564a10 100644 --- a/args.go +++ b/cmd/range-gen/args.go @@ -3,7 +3,7 @@ package main import ( "github.com/juju/gnuflag" - "range-gen/output" + "range-gen/internal/output" "errors" "os" diff --git a/main.go b/cmd/range-gen/main.go similarity index 99% rename from main.go rename to cmd/range-gen/main.go index 905d765..a7b0cfc 100644 --- a/main.go +++ b/cmd/range-gen/main.go @@ -18,7 +18,7 @@ import ( "github.com/dsoprea/go-perceptualhash" - "range-gen/output" + "range-gen/internal/output" ) const ( diff --git a/doc/README b/doc/README new file mode 100644 index 0000000..d8bf017 --- /dev/null +++ b/doc/README @@ -0,0 +1,12 @@ +Сreates a list of scene ranges based on a set of frames from the video + +Usage: range-gen [option]... +input_dir Directory with png images +output_file Range list file +threshold Image similarity threshold (0-1024) + +Options: + -j, --jobs N Allow N jobs at once + -n, --noise Default noise level for each range + -h, --help Show this page + -v, --version Show version diff --git a/output/output.go b/internal/output/output.go similarity index 100% rename from output/output.go rename to internal/output/output.go diff --git a/third_party/go-perceptualhash/LICENSE b/third_party/go-perceptualhash/LICENSE new file mode 100644 index 0000000..ca609a1 --- /dev/null +++ b/third_party/go-perceptualhash/LICENSE @@ -0,0 +1,26 @@ +BSD 3-Clause License + +Copyright (c) 2018, Dustin Oprea +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.