Nir Soffer
2021-Nov-07 16:35 UTC
[Libguestfs] [PATCH libnbd 1/2] golang: Create distribution for a proxy server
Add make-dist.sh script, creating a distribution tree for a proxy server[1]. The created tree must be served by the web server serving the libnbd module, for example: https://download.libguestfs.org/libnbd-golang The Go tools will find this URL by looking at: https://libguestfs.org/linbd Which serve html document with the "go-import" meta tag, pointing to the server serving the module. When the module is available, we need to register the package here: https://pkg.go.dev/libguestfs.org/libnbd [1] https://golang.org/ref/mod#serving-from-proxy Signed-off-by: Nir Soffer <nsoffer at redhat.com> --- golang/make-dist.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100755 golang/make-dist.sh diff --git a/golang/make-dist.sh b/golang/make-dist.sh new file mode 100755 index 0000000..634e306 --- /dev/null +++ b/golang/make-dist.sh @@ -0,0 +1,123 @@ +#!/bin/sh -e +# nbd client library in userspace +# Copyright (C) 2021 Red Hat Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# Create a distribution tree for serving the libnbd Go module. +# +# The web server must serve tree: +# +# libguestfs.org +# ??? libnbd +# ??? @latest +# ??? @v +# ??? list +# ??? v1.11.4.info +# ??? v1.11.4.mod +# ??? v1.11.4.zip +# +# For example: +# +# https://download.libguestfs.org/libnbd-golang/libguestfs.org/libnbd/@v/list +# +# To test the web server use: +# +# GOPROXY=https://download.libguestfs.org go get libguestfs.org/libnbd +# +# This should download the module and add it to the local cache, by +# default in: +# +# ~/go/pkg/mod/libguestfs.org/libnbd at v1.11.4/ +# +# The Go tools will find the web server by looking at: +# +# https://libguestfs.org/libnbd +# +# Which must serve html document with this meta tag: +# +# <meta name="go-import" content="libguestfs.org/libnbd mod https://download.libguestfs.org/libnbd-golang"> +# +# With this, users can consume the libnbd Go bindings using: +# +# go get libguestfs.org/libnbd +# + +version=$(git describe) + +# Create module zip file +# +# libguestfs.org +# ??? libnbd at v1.11.4 +# ??? go.mod +# ??? handle.go +# ... +# +# See https://golang.org/ref/mod#zip-files + +version_dir="libguestfs.org/libnbd at v$version" + +echo "## Creating module zip file: $version.zip" + +mkdir -p $version_dir + +tar cf - \ + --exclude examples \ + --exclude configure \ + --exclude "*_test.go" \ + go.mod README.md LICENSE *.go *.h \ + | tar xvf - -C $version_dir + +zip -rv $version.zip $version_dir/* + +rm -rf libguestfs.org + +# Create web server tree. +# +# libguestfs.org +# ??? libnbd +# ??? @latest +# ??? @v +# ??? list +# ??? v1.11.4.info +# ??? v1.11.4.mod +# ??? v1.11.4.zip +# +# See https://golang.org/ref/mod#serving-from-proxy + +echo "## Creating a tarball: libnbd-golang-$version.tar.gz" + +module_dir=libguestfs.org/libnbd +v_dir=$module_dir/@v + +mkdir -p $v_dir + +echo "{\"Version\": \"$version\"}" > $module_dir/@latest +echo "{\"Version\": \"$version\"}" > $v_dir/$version.info + +# This is not entirely corect. This file should have a list of all +# version avaialable, here we create only single version. This should +# really be done on the server by appending the new version to the list +# file. +echo $version > $v_dir/list + +cp go.mod $v_dir/$version.mod +mv $version.zip $v_dir + +# Create tarball to upload and extract on the webserver. It should be +# extracted in the directory pointed by the "go-import" meta tag. +tar cvzf libnbd-golang-$version.tar.gz libguestfs.org + +rm -rf libguestfs.org -- 2.31.1
Richard W.M. Jones
2021-Nov-08 10:14 UTC
[Libguestfs] [PATCH libnbd 1/2] golang: Create distribution for a proxy server
On Sun, Nov 07, 2021 at 06:35:50PM +0200, Nir Soffer wrote:> Add make-dist.sh script, creating a distribution tree for a proxy > server[1]. The created tree must be served by the web server serving the > libnbd module, for example: > > https://download.libguestfs.org/libnbd-golang > > The Go tools will find this URL by looking at: > > https://libguestfs.org/linbd* libnbd> Which serve html document with the "go-import" meta tag, pointing to > the server serving the module. > > When the module is available, we need to register the package here: > https://pkg.go.dev/libguestfs.org/libnbd > > [1] https://golang.org/ref/mod#serving-from-proxy > > Signed-off-by: Nir Soffer <nsoffer at redhat.com> > --- > golang/make-dist.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 123 insertions(+) > create mode 100755 golang/make-dist.sh > > diff --git a/golang/make-dist.sh b/golang/make-dist.sh > new file mode 100755 > index 0000000..634e306 > --- /dev/null > +++ b/golang/make-dist.sh > @@ -0,0 +1,123 @@ > +#!/bin/sh -e > +# nbd client library in userspace > +# Copyright (C) 2021 Red Hat Inc. > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU Lesser General Public > +# License as published by the Free Software Foundation; either > +# version 2 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# Lesser General Public License for more details. > +# > +# You should have received a copy of the GNU Lesser General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + > +# Create a distribution tree for serving the libnbd Go module. > +# > +# The web server must serve tree: > +# > +# libguestfs.org > +# ??? libnbd > +# ??? @latest > +# ??? @v > +# ??? list > +# ??? v1.11.4.info > +# ??? v1.11.4.mod > +# ??? v1.11.4.zip > +# > +# For example: > +# > +# https://download.libguestfs.org/libnbd-golang/libguestfs.org/libnbd/@v/list > +# > +# To test the web server use: > +# > +# GOPROXY=https://download.libguestfs.org go get libguestfs.org/libnbd > +# > +# This should download the module and add it to the local cache, by > +# default in: > +# > +# ~/go/pkg/mod/libguestfs.org/libnbd at v1.11.4/ > +# > +# The Go tools will find the web server by looking at: > +# > +# https://libguestfs.org/libnbd > +# > +# Which must serve html document with this meta tag: > +# > +# <meta name="go-import" content="libguestfs.org/libnbd mod https://download.libguestfs.org/libnbd-golang"> > +# > +# With this, users can consume the libnbd Go bindings using: > +# > +# go get libguestfs.org/libnbd > +# > + > +version=$(git describe) > + > +# Create module zip file > +# > +# libguestfs.org > +# ??? libnbd at v1.11.4 > +# ??? go.mod > +# ??? handle.go > +# ... > +# > +# See https://golang.org/ref/mod#zip-files > + > +version_dir="libguestfs.org/libnbd at v$version" > + > +echo "## Creating module zip file: $version.zip" > + > +mkdir -p $version_dir > + > +tar cf - \ > + --exclude examples \ > + --exclude configure \ > + --exclude "*_test.go" \ > + go.mod README.md LICENSE *.go *.h \ > + | tar xvf - -C $version_dir > + > +zip -rv $version.zip $version_dir/* > + > +rm -rf libguestfs.org > + > +# Create web server tree. > +# > +# libguestfs.org > +# ??? libnbd > +# ??? @latest > +# ??? @v > +# ??? list > +# ??? v1.11.4.info > +# ??? v1.11.4.mod > +# ??? v1.11.4.zip > +# > +# See https://golang.org/ref/mod#serving-from-proxy > + > +echo "## Creating a tarball: libnbd-golang-$version.tar.gz" > + > +module_dir=libguestfs.org/libnbd > +v_dir=$module_dir/@v > + > +mkdir -p $v_dir > + > +echo "{\"Version\": \"$version\"}" > $module_dir/@latest > +echo "{\"Version\": \"$version\"}" > $v_dir/$version.info > + > +# This is not entirely corect. This file should have a list of all > +# version avaialable, here we create only single version. This should > +# really be done on the server by appending the new version to the list > +# file. > +echo $version > $v_dir/list > + > +cp go.mod $v_dir/$version.mod > +mv $version.zip $v_dir > + > +# Create tarball to upload and extract on the webserver. It should be > +# extracted in the directory pointed by the "go-import" meta tag. > +tar cvzf libnbd-golang-$version.tar.gz libguestfs.org > + > +rm -rf libguestfs.org > -- > 2.31.1-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Eric Blake
2021-Nov-08 19:46 UTC
[Libguestfs] [PATCH libnbd 1/2] golang: Create distribution for a proxy server
On Sun, Nov 07, 2021 at 06:35:50PM +0200, Nir Soffer wrote:> Add make-dist.sh script, creating a distribution tree for a proxy > server[1]. The created tree must be served by the web server serving the > libnbd module, for example: > > https://download.libguestfs.org/libnbd-golang >...> +echo "{\"Version\": \"$version\"}" > $module_dir/@latest > +echo "{\"Version\": \"$version\"}" > $v_dir/$version.info > + > +# This is not entirely corect. This file should have a list of allcorrect> +# version avaialable, here we create only single version. This shouldversions available> +# really be done on the server by appending the new version to the list > +# file. > +echo $version > $v_dir/listWould using >> instead of > work, or would it risk creating a list that has too many (potentially duplicate) entries?> + > +cp go.mod $v_dir/$version.mod > +mv $version.zip $v_dir > + > +# Create tarball to upload and extract on the webserver. It should be > +# extracted in the directory pointed by the "go-import" meta tag. > +tar cvzf libnbd-golang-$version.tar.gz libguestfs.org > + > +rm -rf libguestfs.org > -- > 2.31.1 >-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org