From bd0201b6d3bf9abbefb5fa69ba2a510282e097d2 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Wed, 3 Dec 2025 17:22:33 +0100 Subject: [PATCH] Add Debian package building, add manpage, release v1.0.0 --- .gitignore | 1 + Makefile | 19 +++++- cmd/s3-genindex/main.go | 11 ++++ debian/changelog | 8 +++ debian/compat | 1 + debian/control | 21 +++++++ debian/install | 2 + debian/rules | 20 +++++++ docs/s3-genindex.1 | 126 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/install create mode 100755 debian/rules create mode 100644 docs/s3-genindex.1 diff --git a/.gitignore b/.gitignore index c7551bb..fbbe78a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Generated index files **/index.html +coverage.* # Debian packaging artifacts debian/.debhelper/ diff --git a/Makefile b/Makefile index fcfd47f..d21b37a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build clean wipe test help +.PHONY: build clean wipe test help sync-version pkg-deb # Default target all: build @@ -27,6 +27,8 @@ clean: @echo "Cleaning build artifacts..." rm -f s3-genindex rm -f coverage.out coverage.html + rm -rf debian/s3-genindex debian/files debian/*.substvars debian/debhelper-build-stamp + rm -rf debian/.gocache debian/go find . -name index.html -delete @echo "Clean complete" @@ -73,6 +75,19 @@ bench: @echo "Running benchmarks..." go test -bench=. ./... +# Sync version from debian/changelog to source code +sync-version: + @echo "Syncing version..." + @version=$$(head -1 debian/changelog | sed -n 's/.*(\([^)]*\)).*/\1/p'); \ + sed -i "s/const Version = .*/const Version = \"$$version\"/" cmd/s3-genindex/main.go; \ + echo "Updated version to $$version" + +# Build Debian package +pkg-deb: sync-version + @echo "Building Debian package..." + fakeroot dpkg-buildpackage -us -uc -b + @echo "Debian package build complete" + # Show help help: @echo "Available targets:" @@ -87,4 +102,6 @@ help: @echo " lint - Lint code (requires golangci-lint)" @echo " check - Run fmt, vet, lint, and test" @echo " bench - Run benchmarks" + @echo " sync-version - Sync version from debian/changelog to source" + @echo " pkg-deb - Build Debian package" @echo " help - Show this help message" diff --git a/cmd/s3-genindex/main.go b/cmd/s3-genindex/main.go index 612a1e7..ee8d6d9 100644 --- a/cmd/s3-genindex/main.go +++ b/cmd/s3-genindex/main.go @@ -20,6 +20,9 @@ import ( "git.ipng.ch/ipng/s3-genindex/internal/indexgen" ) +// Version is the application version (sync'd from debian/changelog) +const Version = "1.0.0-1" + // S3Config holds S3 connection configuration type S3Config struct { Endpoint string @@ -348,6 +351,7 @@ func main() { var dryRun bool var showIndexFiles bool var watermarkURL string + var showVersion bool // Set defaults opts.DirAppend = true @@ -363,6 +367,7 @@ func main() { flag.BoolVar(&opts.Verbose, "v", false, "verbosely list every processed file") flag.BoolVar(&showIndexFiles, "i", false, "show index.html files in directory listings") flag.StringVar(&watermarkURL, "wm", "", "watermark logo URL to display in top left corner") + flag.BoolVar(&showVersion, "version", false, "show version information") flag.Usage = func() { fmt.Fprintf(os.Stderr, "Generate directory index files (recursive is ON, hidden files included by default).\n") @@ -381,6 +386,12 @@ func main() { flag.Parse() + // Handle version flag + if showVersion { + fmt.Printf("s3-genindex version %s\n", Version) + os.Exit(0) + } + // Check mutual exclusion and that exactly one option is provided if directory == "" && s3URL == "" { fmt.Fprintf(os.Stderr, "Error: Either -d or -s3 must be specified.\n\n") diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..a48223a --- /dev/null +++ b/debian/changelog @@ -0,0 +1,8 @@ +s3-genindex (1.0.0-1) unstable; urgency=medium + + * Initial release + * HTML directory index generator for local and S3 storage + * Support for file type icons and responsive design + * Watermark support and hierarchical S3 navigation + + -- Pim van Pelt Tue, 03 Dec 2024 14:30:00 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..9a03714 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..1d22659 --- /dev/null +++ b/debian/control @@ -0,0 +1,21 @@ +Source: s3-genindex +Section: utils +Priority: optional +Maintainer: Pim van Pelt +Build-Depends: debhelper (>= 10), golang-go +Standards-Version: 4.1.2 +Homepage: https://git.ipng.ch/ipng/s3-genindex + +Package: s3-genindex +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: HTML directory index generator for local and S3 storage + Generate HTML directory indexes with file type icons and responsive design + for local directories and S3-compatible storage. This is particularly useful + for S3 buckets that are publicly readable. + . + Features include local directory indexing with recursive traversal, + S3-compatible storage support (MinIO, AWS S3, etc.), hierarchical directory + structure for S3 buckets, responsive HTML design with file type icons, + dry run mode for testing, flexible filtering with glob patterns and regex + exclusion, and hidden file control. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..c03eb5a --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +s3-genindex usr/bin +docs/s3-genindex.1 usr/share/man/man1 \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4c54f8d --- /dev/null +++ b/debian/rules @@ -0,0 +1,20 @@ +#!/usr/bin/make -f + +export GO111MODULE=on +export GOPROXY=direct +export GOSUMDB=off +export GOCACHE=$(CURDIR)/debian/.gocache +export GOPATH=$(CURDIR)/debian/go + +%: + dh $@ + +override_dh_auto_build: + go build -o s3-genindex ./cmd/s3-genindex + +override_dh_auto_test: + go test ./... + +override_dh_auto_install: + mkdir -p debian/s3-genindex/usr/bin + cp s3-genindex debian/s3-genindex/usr/bin/ \ No newline at end of file diff --git a/docs/s3-genindex.1 b/docs/s3-genindex.1 new file mode 100644 index 0000000..97e8221 --- /dev/null +++ b/docs/s3-genindex.1 @@ -0,0 +1,126 @@ +.TH S3-GENINDEX 1 "December 2024" "s3-genindex 1.0.0" "User Commands" +.SH NAME +s3-genindex \- Generate HTML directory indexes for local directories and S3 storage +.SH SYNOPSIS +.B s3-genindex +[\fIOPTIONS\fR] +.SH DESCRIPTION +.B s3-genindex +generates HTML directory indexes with file type icons and responsive design for local directories and S3-compatible storage. This is particularly useful for S3 buckets that are publicly readable. + +The tool creates hierarchical directory structures with responsive HTML pages that include file type icons, sorting capabilities, and optional watermark branding. + +By default, recursive processing is enabled, hidden files are included, and the output file is named 'index.html' with directory href appending enabled. + +.SH OPTIONS +.TP +.BR \-d " \fIDIRECTORY\fR" +Process local directory. Mutually exclusive with \-s3. + +.TP +.BR \-s3 " \fIURL\fR" +Process S3-compatible storage. URL format: http://host:port/bucket or https://host/bucket. +Mutually exclusive with \-d. + +.TP +.BR \-f " \fIGLOB\fR" +Only include files matching glob pattern (default: "*"). +Example: "*.py" to include only Python files. + +.TP +.BR \-n +Dry run mode. Show what would be written without actually creating files. + +.TP +.BR \-x " \fIREGEX\fR" +Exclude files matching regular expression pattern. + +.TP +.BR \-v +Verbose mode. List every processed file during operation. + +.TP +.BR \-i +Show index.html files in directory listings (normally hidden). + +.TP +.BR \-wm " \fIURL\fR" +Watermark logo URL to display in top left corner of generated pages. + +.TP +.BR \-\-version +Show version information and exit. + +.SH ENVIRONMENT +For S3 operations, the following environment variables must be set: + +.TP +.B AWS_ACCESS_KEY_ID +S3 access key ID for authentication. + +.TP +.B AWS_SECRET_ACCESS_KEY +S3 secret access key for authentication. + +.SH EXAMPLES +.TP +Process a local directory: +.B s3-genindex -d /var/www/html + +.TP +Process an S3 bucket with verbose output: +.B s3-genindex -v -s3 http://minio.example.com:9000/my-bucket + +.TP +Dry run with file filtering: +.B s3-genindex -n -f "*.log" -d /var/log + +.TP +S3 processing with watermark and filtering: +.B s3-genindex -v -f "*.jpg" -wm https://example.com/logo.svg -s3 https://s3.amazonaws.com/photos + +.TP +Show version information: +.B s3-genindex --version + +.SH FILES +.TP +.B index.html +Default output filename for generated directory indexes. + +.SH EXIT STATUS +.TP +.B 0 +Success +.TP +.B 1 +Error (invalid arguments, missing credentials, file system errors, etc.) + +.SH FEATURES +.IP \(bu 2 +Local directory indexing with recursive traversal +.IP \(bu 2 +S3-compatible storage support (MinIO, AWS S3, etc.) +.IP \(bu 2 +Hierarchical directory structure for S3 buckets +.IP \(bu 2 +Responsive HTML design with file type icons +.IP \(bu 2 +Dry run mode for testing +.IP \(bu 2 +Flexible filtering with glob patterns and regex exclusion +.IP \(bu 2 +Hidden file control and index.html visibility options +.IP \(bu 2 +Watermark support for branding + +.SH SEE ALSO +.BR ls (1), +.BR find (1), +.BR tree (1) + +.SH AUTHOR +Pim van Pelt + +.SH COPYRIGHT +Copyright \(co 2024 Pim van Pelt. Licensed under the MIT License. \ No newline at end of file