Nir Soffer
2022-Feb-06 17:21 UTC
[Libguestfs] [PATCH libnbd] golang: make-dist.sh: Generate the list file
Generated the list file when creating the distribution. Since the Go tool treat the list file on the proxy server as the source of truth, we do the same. The new list file is created by downloading the current list file, sorting it, and appending the current version. Creating a distribution tarball requires now access to download.libguestfs.org. With this change the distribution tarball can be extract on the server without any additional manual process. Signed-off-by: Nir Soffer <nsoffer at redhat.com> --- golang/make-dist.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/golang/make-dist.sh b/golang/make-dist.sh index a590e6c6..5fe006ff 100755 --- a/golang/make-dist.sh +++ b/golang/make-dist.sh @@ -86,48 +86,42 @@ rm -rf libguestfs.org # # libguestfs.org # ??? libnbd # ??? @latest # ??? @v # ??? list # ??? v1.11.4.info # ??? v1.11.4.mod # ??? v1.11.4.zip # -# We create @latest and @v/*{.info,mod,zip} here. -# -# The "@v/list" file must be created on the web server after uploading -# a new release: -# -# $ cd libguestfs.org/libnbd/@v -# $ ls -1 v*.info | awk -F.info '{print $1}' > list -# $ cat list -# v1.11.3 -# v1.11.4 -# # See https://golang.org/ref/mod#serving-from-proxy module_dir=libguestfs.org/libnbd v_dir=$module_dir/@v mkdir -p $v_dir # Go wants a string in RFC 3339 format, git strict ISO 8601 format is # compatible. info="{ \"Version\": \"$version\", \"Time\": \"$(git show -s --format=%cI)\" }" echo "$info" > $module_dir/@latest echo "$info" > $v_dir/$version.info cp go.mod $v_dir/$version.mod mv $version.zip $v_dir +# Create the list file by amending the curent file on the server. +list_url=https://download.libguestfs.org/libnbd/golang/libguestfs.org/libnbd/@v/list +curl --silent --show-error "$list_url" | sort > $v_dir/list +grep -q "$version" $v_dir/list || echo "$version" >> $v_dir/list + # Create tarball to upload and extract on the webserver. It should be # extracted in the directory pointed by the "go-import" meta tag. output=$PWD/libnbd-golang-$version.tar.gz tar czf $output libguestfs.org rm -rf libguestfs.org echo output written to $output -- 2.34.1
Richard W.M. Jones
2022-Feb-06 19:13 UTC
[Libguestfs] [PATCH libnbd] golang: make-dist.sh: Generate the list file
On Sun, Feb 06, 2022 at 07:21:02PM +0200, Nir Soffer wrote:> Generated the list file when creating the distribution. Since the Go > tool treat the list file on the proxy server as the source of truth, we > do the same. The new list file is created by downloading the current > list file, sorting it, and appending the current version. > > Creating a distribution tarball requires now access to > download.libguestfs.org. > > With this change the distribution tarball can be extract on the server > without any additional manual process. > > Signed-off-by: Nir Soffer <nsoffer at redhat.com> > --- > golang/make-dist.sh | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/golang/make-dist.sh b/golang/make-dist.sh > index a590e6c6..5fe006ff 100755 > --- a/golang/make-dist.sh > +++ b/golang/make-dist.sh > @@ -86,48 +86,42 @@ rm -rf libguestfs.org > # > # libguestfs.org > # ??? libnbd > # ??? @latest > # ??? @v > # ??? list > # ??? v1.11.4.info > # ??? v1.11.4.mod > # ??? v1.11.4.zip > # > -# We create @latest and @v/*{.info,mod,zip} here. > -# > -# The "@v/list" file must be created on the web server after uploading > -# a new release: > -# > -# $ cd libguestfs.org/libnbd/@v > -# $ ls -1 v*.info | awk -F.info '{print $1}' > list > -# $ cat list > -# v1.11.3 > -# v1.11.4 > -# > # See https://golang.org/ref/mod#serving-from-proxy > > module_dir=libguestfs.org/libnbd > v_dir=$module_dir/@v > > mkdir -p $v_dir > > # Go wants a string in RFC 3339 format, git strict ISO 8601 format is > # compatible. > info="{ > \"Version\": \"$version\", > \"Time\": \"$(git show -s --format=%cI)\" > }" > echo "$info" > $module_dir/@latest > echo "$info" > $v_dir/$version.info > > cp go.mod $v_dir/$version.mod > mv $version.zip $v_dir > > +# Create the list file by amending the curent file on the server. > +list_url=https://download.libguestfs.org/libnbd/golang/libguestfs.org/libnbd/@v/list > +curl --silent --show-error "$list_url" | sort > $v_dir/list > +grep -q "$version" $v_dir/list || echo "$version" >> $v_dir/list > + > # Create tarball to upload and extract on the webserver. It should be > # extracted in the directory pointed by the "go-import" meta tag. > output=$PWD/libnbd-golang-$version.tar.gz > tar czf $output libguestfs.org > > rm -rf libguestfs.org > > echo output written to $outputYes this seems a reasonable approach. ACK Rich. -- 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
2022-Feb-07 13:13 UTC
[Libguestfs] [PATCH libnbd] golang: make-dist.sh: Generate the list file
On Sun, Feb 06, 2022 at 07:21:02PM +0200, Nir Soffer wrote:> Generated the list file when creating the distribution. Since the Go > tool treat the list file on the proxy server as the source of truth, we > do the same. The new list file is created by downloading the current > list file, sorting it, and appending the current version. > > Creating a distribution tarball requires now access to > download.libguestfs.org. > > With this change the distribution tarball can be extract on the server > without any additional manual process. > > Signed-off-by: Nir Soffer <nsoffer at redhat.com> > ---> > +# Create the list file by amending the curent file on the server. > +list_url=https://download.libguestfs.org/libnbd/golang/libguestfs.org/libnbd/@v/list > +curl --silent --show-error "$list_url" | sort > $v_dir/listDo we want to use 'LC_ALL=C sort' for deterministic sorting, rather than facing differences when different maintainers use locales with slightly different collation rules? Because the curl command is piped to sort, we don't exit the script with non-zero status if the curl step fails. Is that problematic?> +grep -q "$version" $v_dir/list || echo "$version" >> $v_dir/list > + > # Create tarball to upload and extract on the webserver. It should be > # extracted in the directory pointed by the "go-import" meta tag. > output=$PWD/libnbd-golang-$version.tar.gz > tar czf $output libguestfs.org > > rm -rf libguestfs.org > > echo output written to $output > -- > 2.34.1 >-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org