Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md: how to install image-tools (Issue #91) #92

Merged
merged 1 commit into from
Feb 8, 2017

Conversation

Sn0rt
Copy link
Contributor

@Sn0rt Sn0rt commented Dec 1, 2016

This is a draft for issue #91 .

Signed-off-by: Sn0rt wanggh-fnst@cn.fujitsu.com

go get github.com/opencontainers/image-tools/
cd $GOPATH/src/github.com/opencontainers/image-tools/
make tools
cp oci-unpack oci-create-runtime-bundle oci-image-validate /usr/local/bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been using $ prompts for shell-session examples (e.g. here), otherwise this looks good to me.

Longer term, we may want an installation target like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, updated.

@Sn0rt Sn0rt force-pushed the update-readme-with-install branch 3 times, most recently from b19267f to b727a22 Compare December 2, 2016 04:53
$ skopeo copy docker://busybox oci:busybox-oci
$ mkdir busybox-bundle
$ oci-unpack --ref latest busybox-oci busybox-bundle
tree busybox-bundle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a prompt for this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@Sn0rt Sn0rt force-pushed the update-readme-with-install branch 2 times, most recently from 5d4b69e to e768c01 Compare December 2, 2016 06:57
MAN := \
oci-create-runtime-bundle.1 \
oci-image-validate.1 \
oci-unpack.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stay DRY with patsubst:

MAN := $(patsubst %,%.1,$(TOOLS))

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MAN is consistent with TOOLS named.

TOOLS := \
	oci-create-runtime-bundle \
	oci-image-validate \
	oci-unpack
MAN := \
	oci-create-runtime-bundle.1 \
	oci-image-validate.1 \
	oci-unpack.1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or more legibly with a substitution reference:

MAN := $(TOOLS:%=%.1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MAN is consistent with TOOLS named.

Right, but using the substitution reference lets you define the pattern “all tools have a %.1 man page” instead of re-listing all the tool names. That means there's only one place to touch (TOOLS) when you add/remove new commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

go-md2man -in "cmd/oci-image-validate/oci-image-validate.1.md" -out "oci-image-validate.1"
go-md2man -in "cmd/oci-create-runtime-bundle/oci-create-runtime-bundle.1.md" -out "oci-create-runtime-bundle.1"

install: _man
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the phony target, just use:

install: $(TOOLS) $(MAN)
  …

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be some one not want to install acquiescently that meas is just compile, and we should persist a target ($tools) for developer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phony targets as leaf-targets are fine. But if you put them in a chain you'll always rebuild leafier targets. So I'd like to see:

.PHONY: … install man tools …

man: $(MAN)
tools: $(TOOLS)
install: $(MAN) $(TOOLS)
  …

That way you don't re-install if none of the sources changed.

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, I forget it, but the source code is always compiled even if not be updated.


uninstall: clean
rm -f /usr/local/share/man/man1/oci-create-runtime-bundle.1 /usr/local/share/man/man1/oci-image-validate.1 /usr/local/share/man/man1/oci-unpack.1
rm -f /usr/local/bin/oci-create-runtime-bundle /usr/local/bin/oci-image-validate /usr/local/bin/oci-unpack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -f $(patsubst %,/usr/local/share/man/man1/%,$(MAN)) $(patsubst %,/usr/local/bin/%,$(TOOLS))

although you probably want variables for /usr/local/share/man and /usr/local/bin/ in case the user wants to override them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patsubst approach here is also more legible as a substitution reference:

rm -f $(MAN:%=/usr/local/share/man/man1/%) $(TOOLS:%=/usr/local/bin/%)

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, fixed

_man:
go-md2man -in "cmd/oci-unpack/oci-unpack.1.md" -out "oci-unpack.1"
go-md2man -in "cmd/oci-image-validate/oci-image-validate.1.md" -out "oci-image-validate.1"
go-md2man -in "cmd/oci-create-runtime-bundle/oci-create-runtime-bundle.1.md" -out "oci-create-runtime-bundle.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a static pattern rules and secondary expansion to avoid the phony:

.SECONDEXPANSION:
$(MAN): %.1: cmd/$$*/$$*.1.md
  go-md2man -in "$<" -out "$@"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be it can't work normally .

@@ -29,6 +34,21 @@ tools: $(TOOLS)
$(TOOLS): oci-%:
go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/$@

.PHONY: _man install uninstall
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should go in the existing .PHONY to keep things collected.

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move all of .PHONY be together ? L58 L78 L47

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think new entries should go in the .PHONY at the end. I don't have an opinion on collecting existing .PHONYs ;).

@Sn0rt Sn0rt force-pushed the update-readme-with-install branch 3 times, most recently from 3a3deba to 94173c1 Compare December 2, 2016 09:35
@Sn0rt
Copy link
Contributor Author

Sn0rt commented Dec 2, 2016

The reason for append the all target is that some one install the oci tools permission be need and compile is not.

sudo make all
go build -ldflags "-X main.gitCommit=94173c11c8439e462cf9eab6d6bfab897b3da179" ./cmd/oci-create-runtime-bundle
/bin/sh: go: command not found
Makefile:38: recipe for target 'oci-create-runtime-bundle' failed
make all
go build -ldflags "-X main.gitCommit=94173c11c8439e462cf9eab6d6bfab897b3da179" ./cmd/oci-create-runtime-bundle
go build -ldflags "-X main.gitCommit=94173c11c8439e462cf9eab6d6bfab897b3da179" ./cmd/oci-image-validate
go build -ldflags "-X main.gitCommit=94173c11c8439e462cf9eab6d6bfab897b3da179" ./cmd/oci-unpack
go-md2man -in "cmd/oci-unpack/oci-unpack.1.md" -out "oci-create-runtime-bundle.1"
go-md2man -in "cmd/oci-unpack/oci-unpack.1.md" -out "oci-image-validate.1"
go-md2man -in "cmd/oci-unpack/oci-unpack.1.md" -out "oci-unpack.1"


default: help

help:
@echo "Usage: make <target>"
@echo
@echo " * 'all' - Build the oci tools and manual pages"
@echo " * 'install' - Install binaries and manual pages"
@echo " * 'uninstall' - remove the oci tools and manual pages"
@echo " * 'tools' - Build the oci image tools binaries"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should document man here too.

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx , fixed

$(TOOLS): oci-%:
go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/$@

$(MAN): %.1: cmd/*/*.1.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work (see here, where all of your man pages are built from oci-unpack.1.md). You want to use secondary expansion (with the line I suggested here).

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/Makefile b/Makefile
index c564720..bd6ad0b 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ all: $(TOOLS) $(MAN)
 $(TOOLS): oci-%:
        go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/$@

-$(MAN): %.1: cmd/*/*.1.md
+$(MAN): %.1: cmd/$$*/$$*.1.md
        go-md2man -in "$<" -out "$@"
make man
go-md2man -in "" -out "oci-create-runtime-bundle.1"

it will be hang.

Copy link
Contributor Author

@Sn0rt Sn0rt Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(MAN): %.1: cmd/*/*.1.md
	go-md2man -in "$<" -out "$@"
make man
go-md2man -in "cmd/oci-create-runtime-bundle/oci-create-runtime-bundle.1.md" -out "oci-create-runtime-bundle.1"
go-md2man -in "cmd/oci-create-runtime-bundle/oci-create-runtime-bundle.1.md" -out "oci-image-validate.1"
go-md2man -in "cmd/oci-create-runtime-bundle/oci-create-runtime-bundle.1.md" -out "oci-unpack.1"

it's ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ok

It's not ok, it's using oci-create-runtime-bundle.1.md as the source for all the pages.

it will be hang

That's because you left off the SECONDEXPANSION: line. It's important ;). Doc link in my original secondary-expansion comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sogar, thx! fixed.

install -m 644 $(MAN) /usr/local/share/man/man1

uninstall: clean
rm -f $(patsubst %,/usr/local/share/man/man1/%,$(MAN)) $(patsubst %,/usr/local/bin/%,$(TOOLS))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would read more easily as a substitution reference (with the line I suggested here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx very much, fixed

test
test \
$(MAN) \
$(TOOLS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither $(MAN) nor $(TOOLS) are phony. They are all real files that we're building, and they all have targets pointing at them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@Sn0rt Sn0rt force-pushed the update-readme-with-install branch 3 times, most recently from 4caa656 to f14a9b6 Compare December 2, 2016 15:21
$(MAN): %.1: cmd/$$*/$$*.1.md
go-md2man -in "$<" -out "$@"

install:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on $(TOOLS) and $(MAN).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the installation is a special action which depend on permissions, and building is not need permissions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the installation is a special action which depend on permissions, and building is not need permissions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users making separate calls to build and install is fine, but installation still depends on having the prerequisites available. By listing them, you avoid confusing users who do decide to jump straight in with install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fixed.

Recommend to use `go` to download.

```
$ go get github.com/opencontainers/image-tools/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ go get github.com/opencontainers/image-tools/
package github.com/opencontainers/image-tools: no buildable Go source files in /tmp/whatever/src/github.com/opencontainers/image-tools
$ echo $?
1

It's probably better to pick a single command:

$ go get -d github.com/opencontainers/image-tools/cmd/oci-unpack

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider that It does not matter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It matters, because the -d …path/to/cmd… approach succeeds (exits zero), but the approach you have now fails (see the warning and the 1 returned by echo $? in my comment above).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


## example

Firstly, May be you need to install `skopeo` and more information at [here](https://github.com/projectatomic/skopeo).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these examples are using a busybox-oci image. I'd probably structure it like:

Obtaining an image

The following examples assume you have a image-layout tar archive at busybox-oci.
One way to acquire that image is with skopeo:

$ skopeo copy docker://busybox oci:busybox-oci

oci-create-runtime-bundle

$ mkdir busybox-bundle
$ oci-create-runtime-bundle --ref latest busybox-oci busybox-bundle
$ cd busybox-bundle && sudo runc run busybox

More information about oci-create-runtime-bundle can be found in its man page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new “Obtaining an image” linking to skopeo's installation section, I don't think we need any of the text between the “example” and “Obtaining an image” headers anymore. Folks who don't have skopeo can go over to that project's installation docs and see how to install it without us duplicating their instructions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right

@Sn0rt Sn0rt force-pushed the update-readme-with-install branch 2 times, most recently from a7cba1a to 9dde9ac Compare December 5, 2016 03:06
@Sn0rt
Copy link
Contributor Author

Sn0rt commented Dec 5, 2016

PTAL


### Obtaining an image

The following examples assume you have a (image-layout)[https://github.com/opencontainers/image-spec/blob/v1.0.0-rc2/image-layout.md] tar archive at busybox-oci.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backticks around busybox-oci?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

it is recommended that use `go` to download a single command tools.

```
$ go get -d github.com/opencontainers/image-tools/cmd/oci-unpack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wking
Copy link
Contributor

wking commented Dec 21, 2016

bffd46b looks good to me :).

@Sn0rt
Copy link
Contributor Author

Sn0rt commented Dec 22, 2016

@xiekeyang @coolljt0725 PTAL


### Obtaining an image

The following examples assume you have a (image-layout)[https://github.com/opencontainers/image-spec/blob/v1.0.0-rc2/image-layout.md] tar archive at `busybox-oci`.
Copy link
Contributor

@xiekeyang xiekeyang Dec 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax of URL link seems incorrect. Should be [abbreviation]--(url)
And please check other positions in this commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extremely embarrassing, fixed.


default: help

help:
@echo "Usage: make <target>"
@echo
@echo " * 'all' - Build the oci tools and manual pages"
@echo " * 'install' - Install binaries and manual pages"
@echo " * 'uninstall' - remove the oci tools and manual pages"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistent, remove -> Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thx very much.

@@ -2,6 +2,71 @@

`image-tools` is a collection of tools for working with the [OCI image format specification](https://github.com/opencontainers/image-spec).

# Install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be ## Install , double #

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got

@@ -2,6 +2,71 @@

`image-tools` is a collection of tools for working with the [OCI image format specification](https://github.com/opencontainers/image-spec).

# Install

it is recommended that use `go` to download a single command tools.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first letter should be capital
go -> go get?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy that

$ sudo make install
```

## uninstall
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistent, capitalize first letter. Uninstall

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy that

$ sudo make uninstall
```

## example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

$(TOOLS): oci-%:
go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/$@

.SECONDEXPANSION:
$(MAN): %.1: cmd/$$*/$$*.1.md
go-md2man -in "$<" -out "$@"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we install go-md2man in install.tools https://github.com/opencontainers/image-tools/blob/master/Makefile#L60?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider we should install it by install.tools , it seems consistent with the front.

@Sn0rt Sn0rt force-pushed the update-readme-with-install branch 3 times, most recently from 223cb52 to 32eaa3b Compare December 22, 2016 09:37
Signed-off-by: Sn0rt <wanggh-fnst@cn.fujitsu.com>
@Sn0rt
Copy link
Contributor Author

Sn0rt commented Dec 29, 2016

PTAL again

@coolljt0725
Copy link
Member

coolljt0725 commented Jan 22, 2017

LGTM

Approved with PullApprove

@xiekeyang
Copy link
Contributor

xiekeyang commented Feb 7, 2017

LGTM

cc @opencontainers/image-tools-maintainers

Approved with PullApprove

@vbatts
Copy link
Member

vbatts commented Feb 8, 2017

LGTM

Approved with PullApprove

@vbatts vbatts merged commit 945a4e1 into opencontainers:master Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants