Google Groupes

goinstall: an experiment in package installation


Russ Cox 24 févr. 2010 15:41
Envoyé au groupe : golang-nuts
CL 224043, not yet sent for review, would add a new command
goinstall that can download packages into the local file system.
Rather than establish a central naming authority for Go packages
(witness the multiple mysqlgo packages), it uses import paths
that contain the names of common hosting sites.  The full docs
are below.

Goinstall already works with standalone packages that
don't depend on other packages.  For example, I can run:

goinstall github.com/hoisie/web.go.git
goinstall github.com/jacobsa/igo.git/set
goinstall go-avltree.googlecode.com/svn/trunk
goinstall mimeparse.googlecode.com/svn/trunk/go
goinstall gomatrix.googlecode.com/hg
goinstall golang.googlecode.com/hg/src/pkg/scanner

And then import any of those using the same paths.
If those had referred to other import paths of the same
form, goinstall would have downloaded the dependencies,
recursively.  So in your own package, you can put
a line like import "gomatrix.googlecode.com/hg" and
then just run

goinstall my/package

which will notice the import line and download and install
the remote package.  The first time goinstall downloads
and installs a public package, it pings the Go dashboard
to update a list of what people are using.
http://godashboard.appspot.com/package.

This is a request for comments on the general approach.
Please comment here, on the mailing list, rather than in the
codereview site.  It will be easier to have a discussion in an
actual discussion forum.


-- documentation from goinstall/doc.go

Goinstall is an experiment in automatic package installation.
It installs packages, possibly downloading them from public version
control systems, and it maintains a list of public Go packages at
http://godashboard.appspot.com/packages.

Usage:
        goinstall [flags] importpath...

Flags and default settings:
        -dashboard=true   tally public packages on godashboard.appspot.com
        -update=false     update already-downloaded packages
        -v=false          verbose operation

Goinstall installs each of the packages identified by import path on
the command line.  It installs a package's prerequisites before
trying to install the package itself.

The source code for a package with import path foo/bar is expected
to be in the directory $GOROOT/src/pkg/foo/bar/.  If the import
path refers to a code hosting site, goinstall will download it if necessary.
The recognized code hosting sites are:

        GitHub (Git)

                import "github.com/user/project.git"
                import "github.com/user/project.git/sub/directory"

        Google Code Project Hosting (Mercurial, Subversion)

                import "project.googlecode.com/hg"
                import "project.googlecode.com/hg/sub/directory"

                import "project.googlecode.com/svn/trunk"
                import "project.googlecode.com/svn/trunk/sub/directory"


If the directory (e.g., $GOROOT/src/pkg/bitbucket.org/user/project)
already exists and contains an appropriate checkout, goinstall will not
attempt to fetch updates.  The -update flag changes this behavior,
causing goinstall to update all remote packages encountered during
the installation.

When downloading or updating, goinstall first looks for a tag or branch
named "release".  If there is one, it uses that version of the code.
Otherwise it uses the default version selected by the version control
system (typically HEAD for git, tip for Mercurial).

After a successful download and installation of a publicly accessible
remote package, goinstall reports the installation to godashboard.appspot.com,
which increments a count associated with the package and the time
of its most recent installation.  This mechanism powers the package list
at http://godashboard.appspot.com/packages, allowing Go programmers
to learn about popular packages that might be worth looking at.
The -dashboard=false flag disables this reporting.

By default, goinstall prints output only when it encounters an error.
The -v flag causes goinstall to print information about packages
being considered and installed.

Goinstall does not attempt to be a replacement for make.
Instead, it invokes "make install" after locating the package sources.
For local packages without a Makefile and all remote packages,
goinstall creates and uses a temporary Makefile constructed from
the import path and the list of Go files in the package.


FAQ:

• Why not use full URLs instead of hard-coding hosting sites?

Goinstall is an experiment, and it is easier if the experiment does
not involve changes to the compilers and godoc.  The paths used
above double as file system paths, while full URLs do not.
Also, the import path must also convey both the location of
the data and the choice of version control system, so a full URL
would not suffice.

Using this notation does not precluding changing to other
notation once we have more experience or in other contexts.
For example, if Go were to run inside a browser it would make
sense for import lines to be URLs of individual files rather than
version control repositories.

• Why isn't my favorite hosting site supported?

Feel free to add it and send us a CL.
See http://golang.org/doc/contribute.html

• How can I use goinstall with a package I commit changes to?

Instead of having goinstall do the checkout automatically,
check out your package yourself into the same location where
goinstall would put it.  You can use that as your working copy
and push to the world as appropriate.  For example, if you
were working on github.com/hoisie/web.go, you check it out
into $GOROOT/src/pkg/github.com/hoisie/web.go.git
and then edit the files in that directory, pushing back to github
as needed.  Goinstall will use the checked-out git repository
instead of trying to download a fresh one.

• What information is sent to and logged by the dashboard?

The source code for both goinstall and the dashboard are
in the Go repository:

    $GOROOT/src/cmd/goinstall/download.go
    $GOROOT/misc/dashboard/godashboard/package.py

Goinstall sends the package import path.
The dashboard increments a counter and sets the "most recently installed" time.
There is no other reporting or logging.  The data recorded by the dashboard
is publicly visible at http://godashboard.appspot.com/package.

-- end documentation


Again, comments welcome, but please post them here rather
than on the code review site.

Thanks.
Russ