diff --git a/.gitignore b/.gitignore index f5868db4..040ee17b 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ coverage.txt /build /_vendor* /vendor +deb +_build +dive-build-deps_* diff --git a/debian/README.md b/debian/README.md new file mode 100644 index 00000000..a7ec56bc --- /dev/null +++ b/debian/README.md @@ -0,0 +1,88 @@ + +## Guides +- https://go-team.pages.debian.net/packaging.html +- https://www.debian.org/doc/manuals/debmake-doc/ch04.en.html + +## Tools +- generate debian dir `dh-make-golang make -type p github.com/tonymet/dive` +- create chroot (lots of deps)`debootstrap bullseye /srv/chroot/test` +- build package - `dpkg-buildpackage -b` +- [in schroot] install deps `mk-build-deps -i` + +## TODO +- address missing deps (some are not in deb) +- copyright & upstream updates to canonical + + +## Missing deps + +``` + /usr/lib/go-1.15/src/github.com/wagoodman/dive/cmd (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/cmd (from $GOPATH) +src/github.com/tonymet/dive/cmd/analyze.go:11:2: cannot find package "github.com/wagoodman/dive/dive" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/dive (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/dive (from $GOPATH) +src/github.com/tonymet/dive/cmd/root.go:16:2: cannot find package "github.com/wagoodman/dive/dive/filetree" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/dive/filetree (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/dive/filetree (from $GOPATH) +src/github.com/tonymet/dive/cmd/analyze.go:12:2: cannot find package "github.com/wagoodman/dive/runtime" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/dive/get_image_resolver.go:5:2: cannot find package "github.com/wagoodman/dive/dive/image" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/dive/image (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/dive/image (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/dive/get_image_resolver.go:6:2: cannot find package "github.com/wagoodman/dive/dive/image/docker" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/dive/image/docker (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/dive/image/docker (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/dive/get_image_resolver.go:7:2: cannot find package "github.com/wagoodman/dive/dive/image/podman" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/dive/image/podman (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/dive/image/podman (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/dive/filetree/file_node.go:13:2: cannot find package "github.com/phayes/permbits" in any of: + /usr/lib/go-1.15/src/github.com/phayes/permbits (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/phayes/permbits (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/dive/image/docker/engine_resolver.go:11:2: cannot find package "github.com/docker/cli/cli/connhelper" in any of: + /usr/lib/go-1.15/src/github.com/docker/cli/cli/connhelper (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/docker/cli/cli/connhelper (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/dive/image/docker/cli.go:5:2: cannot find package "github.com/wagoodman/dive/utils" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/utils (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/utils (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/run.go:11:2: cannot find package "github.com/wagoodman/dive/runtime/ci" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ci (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ci (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/run.go:12:2: cannot find package "github.com/wagoodman/dive/runtime/export" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/export (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/export (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/run.go:13:2: cannot find package "github.com/wagoodman/dive/runtime/ui" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/app.go:10:2: cannot find package "github.com/jroimartin/gocui" in any of: + /usr/lib/go-1.15/src/github.com/jroimartin/gocui (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/jroimartin/gocui (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/app.go:5:2: cannot find package "github.com/wagoodman/dive/runtime/ui/key" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui/key (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui/key (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/app.go:6:2: cannot find package "github.com/wagoodman/dive/runtime/ui/layout" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui/layout (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui/layout (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/app.go:7:2: cannot find package "github.com/wagoodman/dive/runtime/ui/layout/compound" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui/layout/compound (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui/layout/compound (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/controller.go:8:2: cannot find package "github.com/wagoodman/dive/runtime/ui/view" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui/view (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui/view (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/controller.go:9:2: cannot find package "github.com/wagoodman/dive/runtime/ui/viewmodel" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui/viewmodel (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui/viewmodel (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/key/binding.go:8:2: cannot find package "github.com/wagoodman/dive/runtime/ui/format" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/dive/runtime/ui/format (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/dive/runtime/ui/format (from $GOPATH) +src/github.com/tonymet/dive/deb/dive/runtime/ui/key/binding.go:9:2: cannot find package "github.com/wagoodman/keybinding" in any of: + /usr/lib/go-1.15/src/github.com/wagoodman/keybinding (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/wagoodman/keybinding (from $GOPATH) +src/github.com/tonymet/dive/runtime/ui/app.go:6:2: cannot find package "github.com/awesome-gocui/gocui" in any of: + /usr/lib/go-1.15/src/github.com/awesome-gocui/gocui (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/awesome-gocui/gocui (from $GOPATH) +src/github.com/tonymet/dive/runtime/ui/key/binding.go:7:2: cannot find package "github.com/awesome-gocui/keybinding" in any of: + /usr/lib/go-1.15/src/github.com/awesome-gocui/keybinding (from $GOROOT) + /home/tonymet/src/dive/_build/src/github.com/awesome-gocui/keybinding (from $GOPATH) +``` \ No newline at end of file diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..1d1e94cf --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +dive (0.9.2-1) UNRELEASED; urgency=medium + + * Initial release (Closes: TODO) + + -- Anthony Metzidis Tue, 21 Jan 2025 16:32:27 -0800 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..5d5d9976 --- /dev/null +++ b/debian/control @@ -0,0 +1,381 @@ +Source: dive +Maintainer: Debian Go Packaging Team +Uploaders: Anthony Metzidis +Section: golang +Testsuite: autopkgtest-pkg-go +Priority: optional +Build-Depends: debhelper-compat (= 13), + dh-golang, + golang-any, + golang-github-cespare-xxhash-dev, + golang-github-docker-docker-dev, + golang-github-dustin-go-humanize-dev, + golang-github-fatih-color-dev, + golang-github-google-uuid-dev, + golang-github-logrusorgru-aurora-dev, + golang-github-lunixbochs-vtclean-dev, + golang-github-mitchellh-go-homedir-dev, + golang-github-sergi-go-diff-dev, + golang-github-spf13-afero-dev, + golang-github-spf13-cobra-dev, + golang-github-spf13-viper-dev, + golang-golang-x-net-dev, + golang-logrus-dev +Standards-Version: 4.6.0 +Vcs-Browser: https://salsa.debian.org/go-team/packages/dive +Vcs-Git: https://salsa.debian.org/go-team/packages/dive.git +Homepage: https://github.com/tonymet/dive +Rules-Requires-Root: no +XS-Go-Import-Path: github.com/tonymet/dive + +Package: dive +Architecture: any +Depends: ${misc:Depends}, + ${shlibs:Depends} +Built-Using: ${misc:Built-Using} +Description: A tool for exploring each layer in a docker image (program) + dive + . + GitHub release (https://github.com/wagoodman/dive/releases/latest) + Validations + (https://github.com/wagoodman/dive/actions/workflows/validations.yaml) + Go Report Card + (https://goreportcard.com/report/github.com/wagoodman/dive) License: MIT + (https://github.com/wagoodman/dive/blob/main/LICENSE) Donate + (https://www.paypal.me/wagoodman) + . + **A tool for exploring a docker image, layer contents, and discovering + ways to shrink the size of your Docker/OCI image.** + . + [Image: Image] (/.data/demo.gif) + . + To analyze a Docker image simply run dive with an image tag/id/digest: + . + dive + . + or you can dive with docker command directly + . + alias dive="docker run -ti --rm -v + /var/run/docker.sock:/var/run/docker.sock wagoodman/dive" + dive + . + # for example + dive nginx:latest + . + or if you want to build your image then jump straight into analyzing it: + . + dive build -t . + . + Building on Macbook (supporting only the Docker container engine) + . + docker run --rm -it \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v "$(pwd)":"$(pwd)" \ + -w "$(pwd)" \ + -v "$HOME/.dive.yaml":"$HOME/.dive.yaml" \ + wagoodman/dive:latest build -t . + . + Additionally you can run this in your CI pipeline to ensure you're + keeping wasted space to a minimum (this skips the UI): + . + CI=true dive + . + [Image: Image] (/.data/demo-ci.png) + . + **This is beta quality!** *Feel free to submit an issue if you want a + new feature or find a bug :)* + . + Basic Features + . + **Show Docker image contents broken down by layer** + . + As you select a layer on the left, you are shown the contents of that + layer combined with all previous layers on the right. Also, you can + fully explore the file tree with the arrow keys. + . + **Indicate what's changed in each layer** + . + Files that have changed, been modified, added, or removed are indicated + in the file tree. This can be adjusted to show changes for a specific + layer, or aggregated changes up to this layer. + . + **Estimate "image efficiency"** + . + The lower left pane shows basic layer info and an experimental metric + that will guess how much wasted space your image contains. This might be + from duplicating files across layers, moving files across layers, or not + fully removing files. Both a percentage "score" and total wasted file + space is provided. + . + **Quick build/analysis cycles** + . + You can build a Docker image and do an immediate analysis with one + command: dive build -t some-tag . + . + You only need to replace your docker build command with the same dive + build command. + . + **CI Integration** + . + Analyze an image and get a pass/fail result based on the image + efficiency and wasted space. Simply set CI=true in the environment when + invoking any valid dive command. + . + **Multiple Image Sources and Container Engines Supported** + . + With the --source option, you can select where to fetch the container + image from: + . + dive --source + . + or + . + dive :// + . + With valid source options as such: + . + * docker: Docker engine (the default option) + * docker-archive: A Docker Tar Archive from disk + * podman: Podman engine (linux only) + . + Installation + . + **Ubuntu/Debian** + . + Using debs: + . + DIVE_VERSION=$(curl -sL + "https://api.github.com/repos/wagoodman/dive/releases/latest" | grep + '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') + curl -OL + https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.deb + sudo apt install ./dive_${DIVE_VERSION}_linux_amd64.deb + . + Using snap: + . + sudo snap install docker + sudo snap install dive + sudo snap connect dive:docker-executables docker:docker-executables + sudo snap connect dive:docker-daemon docker:docker-daemon + . + **RHEL/Centos** + . + DIVE_VERSION=$(curl -sL + "https://api.github.com/repos/wagoodman/dive/releases/latest" | grep + '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') + curl -OL + https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.rpm + rpm -i dive_${DIVE_VERSION}_linux_amd64.rpm + . + **Arch Linux** + . + Available in the extra repository + (https://archlinux.org/packages/extra/x86_64/dive/) and can be installed + via pacman (https://wiki.archlinux.org/title/Pacman): + . + pacman -S dive + . + **Mac** + . + If you use Homebrew (https://brew.sh): + . + brew install dive + . + If you use MacPorts (https://www.macports.org): + . + sudo port install dive + . + Or download the latest Darwin build from the releases page + (https://github.com/wagoodman/dive/releases/latest). + . + **Windows** + . + Download the latest release + (https://github.com/wagoodman/dive/releases/latest). + . + **Go tools** Requires Go version 1.10 or higher. + . + go get github.com/wagoodman/dive + . + *Note*: installing in this way you will not see a proper version when + running dive -v. + . + **Nix/NixOS** + . + On NixOS: + . + nix-env -iA nixos.dive + . + On non-NixOS (Linux, Mac) + . + nix-env -iA nixpkgs.dive + . + **Docker** + . + docker pull wagoodman/dive + . + or + . + docker pull quay.io/wagoodman/dive + . + When running you'll need to include the docker socket file: + . + docker run --rm -it \ + -v /var/run/docker.sock:/var/run/docker.sock \ + wagoodman/dive:latest + . + Docker for Windows (showing PowerShell compatible line breaks; collapse + to a single line for Command Prompt compatibility) + . + docker run --rm -it ` + -v /var/run/docker.sock:/var/run/docker.sock ` + wagoodman/dive:latest + . + **Note:** depending on the version of docker you are running locally you + may need to specify the docker API version as an environment variable: + . + DOCKER_API_VERSION=1.37 dive ... + . + or if you are running with a docker image: + . + docker run --rm -it \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -e DOCKER_API_VERSION=1.37 \ + wagoodman/dive:latest + . + CI Integration + . + When running dive with the environment variable CI=true then the dive UI + will be bypassed and will instead analyze your docker image, giving it a + pass/fail indication via return code. Currently there are three metrics + supported via a .dive-ci file that you can put at the root of your repo: + . + rules: + # If the efficiency is measured below X%, mark as failed. + # Expressed as a ratio between 0-1. + lowestEfficiency: 0.95 + . + # If the amount of wasted space is at least X or larger than X, mark + as failed. + # Expressed in B, KB, MB, and GB. + highestWastedBytes: 20MB + . + # If the amount of wasted space makes up for X% or more of the + image, mark as failed. + # Note: the base image layer is NOT included in the total image + size. + # Expressed as a ratio between 0-1; fails if the threshold is met or + crossed. + highestUserWastedPercent: 0.20 + . + You can override the CI config path with the --ci-config option. + . + KeyBindings + . + KEY BINDING | DESCRIPTION + ----------------+--------------------------------- + Ctrl + C or Q | Exit + Tab | Switch between the layer and + | filetree views + Ctrl + F | Filter files + PageUp | Scroll up a page + PageDown | Scroll down a page + Ctrl + A | Layer view: see aggregated + | image modifications + Ctrl + L | Layer view: see current layer + | modifications + Space | Filetree view: + | collapse/uncollapse a + | directory + Ctrl + Space | Filetree view: + | collapse/uncollapse all + | directories + Ctrl + A | Filetree view: show/hide added + | files + Ctrl + R | Filetree view: show/hide + | removed files + Ctrl + M | Filetree view: show/hide + | modified files + Ctrl + U | Filetree view: show/hide + | unmodified files + Ctrl + B | Filetree view: show/hide file + | attributes + PageUp | Filetree view: scroll up a + | page + PageDown | Filetree view: scroll down a + | page + . + UI Configuration + . + No configuration is necessary, however, you can create a config file and + override values: + . + # supported options are "docker" and "podman" + container-engine: docker + # continue with analysis even if there are errors parsing the image + archive + ignore-errors: false + log: + enabled: true + path: ./dive.log + level: info + . + # Note: you can specify multiple bindings by separating values with a + comma. + # Note: UI hinting is derived from the first binding + keybinding: + # Global bindings + quit: ctrl+c + toggle-view: tab + filter-files: ctrl+f, ctrl+slash + . + # Layer view specific bindings + compare-all: ctrl+a + compare-layer: ctrl+l + . + # File view specific bindings + toggle-collapse-dir: space + toggle-collapse-all-dir: ctrl+space + toggle-added-files: ctrl+a + toggle-removed-files: ctrl+r + toggle-modified-files: ctrl+m + toggle-unmodified-files: ctrl+u + toggle-filetree-attributes: ctrl+b + page-up: pgup + page-down: pgdn + . + diff: + # You can change the default files shown in the filetree (right + pane). All diff types are shown by default. + hide: + - added + - removed + - modified + - unmodified + . + filetree: + # The default directory-collapse state + collapse-dir: false + . + # The percentage of screen width the filetree should take on the + screen (must be >0 and <1) + pane-width: 0.5 + . + # Show the file attributes next to the filetree + show-attributes: true + . + layer: + # Enable showing all changes from this layer and every previous + layer + show-aggregated-changes: false + . + . + dive will search for configs in the following locations: + . + * $XDG_CONFIG_HOME/dive/*.yaml + * $XDG_CONFIG_DIRS/dive/*.yaml + * ~/.config/dive/*.yaml + * ~/.dive.yaml + . + .yml can be used instead of .yaml if desired. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..5de6e57a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,32 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dive +Upstream-Contact: TODO +Source: https://github.com/tonymet/dive + +Files: * +Copyright: 2020 Tony Metzidis +License: Expat + +Files: debian/* +Copyright: 2025 Anthony Metzidis +License: Expat +Comment: Debian packaging is licensed under the same terms as upstream + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 00000000..3d450c28 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,3 @@ +[DEFAULT] +debian-branch = debian/sid +dist = DEP14 diff --git a/debian/gitlab-ci.yml b/debian/gitlab-ci.yml new file mode 100644 index 00000000..594e14e7 --- /dev/null +++ b/debian/gitlab-ci.yml @@ -0,0 +1,6 @@ +# auto-generated, DO NOT MODIFY. +# The authoritative copy of this file lives at: +# https://salsa.debian.org/go-team/infra/pkg-go-tools/blob/master/config/gitlabciyml.go +--- +include: + - https://salsa.debian.org/go-team/infra/pkg-go-tools/-/raw/master/pipeline/test-archive.yml diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..a97e1354 --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +%: + dh $@ --builddirectory=_build --buildsystem=golang --with=golang + +override_dh_auto_install: + dh_auto_install -- --no-source diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 00000000..8883b6ec --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,5 @@ +--- +Bug-Database: https://github.com/tonymet/dive/issues +Bug-Submit: https://github.com/tonymet/dive/issues/new +Repository: https://github.com/tonymet/dive.git +Repository-Browse: https://github.com/tonymet/dive diff --git a/debian/watch b/debian/watch new file mode 100644 index 00000000..f563794a --- /dev/null +++ b/debian/watch @@ -0,0 +1,4 @@ +version=4 +opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%@PACKAGE@-$1.tar.gz%,\ + uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/$1~$2$3/" \ + https://github.com/tonymet/dive/tags .*/v?(\d\S*)\.tar\.gz debian