Compare commits
2 commits
main
...
1.19-devel
Author | SHA1 | Date | |
---|---|---|---|
|
451eef7392 | ||
|
abc4a12447 |
5 changed files with 20 additions and 170 deletions
108
.github/workflows/update.yml
vendored
108
.github/workflows/update.yml
vendored
|
@ -1,108 +0,0 @@
|
||||||
name: Update
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 14 * * 1'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Install xmllint
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install libxml2-utils
|
|
||||||
- name: Update nbdkit bindings from libguestfs.org releases
|
|
||||||
run: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
RELEASES=$(curl --silent https://download.libguestfs.org/nbdkit/ | xmllint --html --noblanks --xpath "/html/body/table/tr[td/img/@alt = '[DIR]']/td[a/.]/a/text()" -)
|
|
||||||
git config --global user.email "marnold@redhat.com"
|
|
||||||
git config --global user.name "Matthew Arnold"
|
|
||||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
|
||||||
git pull --all --set-upstream
|
|
||||||
for release in ${RELEASES}
|
|
||||||
do
|
|
||||||
release=${release%?}
|
|
||||||
TARBALLS=$(curl --silent https://download.libguestfs.org/nbdkit/$release/ | xmllint --html --noblanks --xpath "/html/body/table/tr/td[contains(a/@href, '.tar.gz') and not(contains(a/@href, '.tar.gz.sig'))]/a/@href" -) || true
|
|
||||||
for tarball in ${TARBALLS}
|
|
||||||
do
|
|
||||||
IFS=\"$IFS read href tarball suffix <<< $tarball # Intentionally overwrite tarball
|
|
||||||
IFS="-.$IFS" read nbdkit major minor build suffix <<< $tarball
|
|
||||||
if (($major \* 100000000 + $minor \* 10000 + $build \< 100190009))
|
|
||||||
then # Go bindings added in 1.19.9
|
|
||||||
echo Ignoring release older than 1.19.9: $release/$tarball
|
|
||||||
echo
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
latestrelease=$release
|
|
||||||
version=$major.$minor.$build
|
|
||||||
tag=v$major.$minor.$build
|
|
||||||
echo Branch: $release Tar: $tarball Tag: $tag
|
|
||||||
if git rev-parse --verify $tag
|
|
||||||
then
|
|
||||||
echo Already present in repository: $tag
|
|
||||||
else
|
|
||||||
if ! (git rev-parse --verify $release || git rev-parse --verify origin/$release)
|
|
||||||
then
|
|
||||||
echo Creating new branch: $release
|
|
||||||
root=$(git rev-list --max-parents=0 HEAD)
|
|
||||||
git checkout $root
|
|
||||||
git checkout -b $release
|
|
||||||
else
|
|
||||||
echo Checking out existing branch: $release
|
|
||||||
git checkout $release
|
|
||||||
fi
|
|
||||||
echo Updating $release branch with new version $version
|
|
||||||
curl --silent https://download.libguestfs.org/nbdkit/$release/$tarball | tar -xzv --strip-components=6 nbdkit-$version/plugins/golang/src/libguestfs.org/nbdkit/
|
|
||||||
rm -f .gitignore
|
|
||||||
git add --all
|
|
||||||
git diff-index --quiet HEAD || git commit -m "Import nbdkit-$version"
|
|
||||||
git tag $tag
|
|
||||||
fi
|
|
||||||
if git rev-parse --verify $tag-cdi
|
|
||||||
then
|
|
||||||
echo Already present in repository: $tag-cdi
|
|
||||||
else
|
|
||||||
if ! (git rev-parse --verify $release-cdi || git rev-parse --verify origin/$release-cdi)
|
|
||||||
then
|
|
||||||
echo Creating new branch: $release-cdi
|
|
||||||
root=$(git rev-list --max-parents=0 HEAD)
|
|
||||||
git checkout $root
|
|
||||||
git checkout -b $release-cdi
|
|
||||||
else
|
|
||||||
echo Checking out existing branch: $release-cdi
|
|
||||||
git checkout $release-cdi
|
|
||||||
fi
|
|
||||||
git checkout $tag ./
|
|
||||||
find . -type f -name '*.go' -exec sed -i 's/#cgo pkg-config: nbdkit/#cgo LDFLAGS: -lnbdkit/g' {} +
|
|
||||||
git add --all
|
|
||||||
git diff-index --quiet HEAD || git commit -m "Tweak nbdkit-$version for CDI build"
|
|
||||||
git tag $tag-cdi
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
latest=$(tail -n 1 <<< $latestrelease)
|
|
||||||
git checkout main
|
|
||||||
if git rev-parse --verify $latestrelease
|
|
||||||
then
|
|
||||||
echo Copy newest bindings from local $latest
|
|
||||||
git checkout $latest ./
|
|
||||||
elif git rev-parse --verify origin/$latestrelease
|
|
||||||
then
|
|
||||||
echo Copy newest bindings from remote $latest
|
|
||||||
git checkout origin/$latest ./
|
|
||||||
else
|
|
||||||
echo Latest branch not present in local or remote? Check libguestfs.org for unpopulated directory.
|
|
||||||
fi
|
|
||||||
git diff-index --quiet HEAD || git commit -m "Update latest nbdkit bindings."
|
|
||||||
git push --all -u
|
|
||||||
git push --tags
|
|
30
LICENSE
30
LICENSE
|
@ -1,30 +0,0 @@
|
||||||
nbdkit
|
|
||||||
Copyright (C) 2013-2020 Red Hat Inc.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of Red Hat nor the names of its contributors may be
|
|
||||||
used to endorse or promote products derived from this software without
|
|
||||||
specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
||||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGE.
|
|
|
@ -1,6 +0,0 @@
|
||||||
# go-nbdkit
|
|
||||||
Importable Golang bindings for nbdkit, extracted from official libguestfs.org releases.
|
|
||||||
|
|
||||||
This repository includes all the auto-generated golang files from the official libguestfs.org releases of nbdkit, so that the bindings can be imported with `go.mod` or `go get`. This is intended as a temporary measure to allow [CDI](https://github.com/kubevirt/containerized-data-importer) to make use of nbdkit plugins for functional tests.
|
|
||||||
|
|
||||||
Requires a minimum of nbdkit version 1.20.
|
|
4
go.mod
4
go.mod
|
@ -1,4 +0,0 @@
|
||||||
module git.batts.cloud/vbatts/go-nbdkit
|
|
||||||
|
|
||||||
// First version of golang with working module support.
|
|
||||||
go 1.13
|
|
42
nbdkit.go
42
nbdkit.go
|
@ -103,44 +103,42 @@ const (
|
||||||
|
|
||||||
// The plugin interface.
|
// The plugin interface.
|
||||||
type PluginInterface interface {
|
type PluginInterface interface {
|
||||||
|
// Open is required for all plugins.
|
||||||
|
// Other methods are optional.
|
||||||
Load()
|
Load()
|
||||||
Unload()
|
Unload()
|
||||||
|
|
||||||
DumpPlugin()
|
DumpPlugin()
|
||||||
|
|
||||||
Config(key string, value string) error
|
Config(key string, value string) error
|
||||||
ConfigComplete() error
|
ConfigComplete() error
|
||||||
GetReady() error
|
GetReady() error
|
||||||
|
|
||||||
PreConnect(readonly bool) error
|
PreConnect(readonly bool) error
|
||||||
Open(readonly bool) (ConnectionInterface, error) // required
|
Open(readonly bool) (ConnectionInterface, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The client connection interface.
|
// The client connection interface.
|
||||||
type ConnectionInterface interface {
|
type ConnectionInterface interface {
|
||||||
GetSize() (uint64, error) // required
|
// GetSize and PRead are required for all plugins.
|
||||||
|
// Other methods are optional.
|
||||||
|
Close()
|
||||||
|
|
||||||
|
GetSize() (uint64, error)
|
||||||
|
|
||||||
|
CanWrite() (bool, error)
|
||||||
|
CanFlush() (bool, error)
|
||||||
IsRotational() (bool, error)
|
IsRotational() (bool, error)
|
||||||
|
CanTrim() (bool, error)
|
||||||
|
CanZero() (bool, error)
|
||||||
CanMultiConn() (bool, error)
|
CanMultiConn() (bool, error)
|
||||||
|
|
||||||
PRead(buf []byte, offset uint64, flags uint32) error // required
|
PRead(buf []byte, offset uint64, flags uint32) error
|
||||||
|
// NB: This will NOT be called unless CanWrite returns true.
|
||||||
// NB: PWrite will NOT be called unless CanWrite returns true.
|
|
||||||
CanWrite() (bool, error)
|
|
||||||
PWrite(buf []byte, offset uint64, flags uint32) error
|
PWrite(buf []byte, offset uint64, flags uint32) error
|
||||||
|
// NB: This will NOT be called unless CanFlush returns true.
|
||||||
// NB: Flush will NOT be called unless CanFlush returns true.
|
|
||||||
CanFlush() (bool, error)
|
|
||||||
Flush(flags uint32) error
|
Flush(flags uint32) error
|
||||||
|
// NB: This will NOT be called unless CanTrim returns true.
|
||||||
// NB: Trim will NOT be called unless CanTrim returns true.
|
|
||||||
CanTrim() (bool, error)
|
|
||||||
Trim(count uint32, offset uint64, flags uint32) error
|
Trim(count uint32, offset uint64, flags uint32) error
|
||||||
|
// NB: This will NOT be called unless CanZero returns true.
|
||||||
// NB: Zero will NOT be called unless CanZero returns true.
|
|
||||||
CanZero() (bool, error)
|
|
||||||
Zero(count uint32, offset uint64, flags uint32) error
|
Zero(count uint32, offset uint64, flags uint32) error
|
||||||
|
|
||||||
Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default implementations for plugin interface methods.
|
// Default implementations for plugin interface methods.
|
||||||
|
@ -529,7 +527,7 @@ func PluginInitialize(name string, impl PluginInterface) unsafe.Pointer {
|
||||||
|
|
||||||
// Set up the hidden plugin fields as for C.
|
// Set up the hidden plugin fields as for C.
|
||||||
struct_size := C.ulong(unsafe.Sizeof(plugin))
|
struct_size := C.ulong(unsafe.Sizeof(plugin))
|
||||||
plugin._struct_size = C.uint64_t(struct_size)
|
plugin._struct_size = struct_size
|
||||||
plugin._api_version = C.NBDKIT_API_VERSION
|
plugin._api_version = C.NBDKIT_API_VERSION
|
||||||
plugin._thread_model = C.NBDKIT_THREAD_MODEL_PARALLEL
|
plugin._thread_model = C.NBDKIT_THREAD_MODEL_PARALLEL
|
||||||
|
|
||||||
|
@ -563,7 +561,7 @@ func PluginInitialize(name string, impl PluginInterface) unsafe.Pointer {
|
||||||
// Return a newly malloced copy of the struct. This must be
|
// Return a newly malloced copy of the struct. This must be
|
||||||
// globally available to the C code in the server, so it is
|
// globally available to the C code in the server, so it is
|
||||||
// never freed.
|
// never freed.
|
||||||
p := (*C.struct_nbdkit_plugin)(C.malloc(C.size_t(struct_size)))
|
p := (*C.struct_nbdkit_plugin)(C.malloc(struct_size))
|
||||||
*p = plugin
|
*p = plugin
|
||||||
return unsafe.Pointer(p)
|
return unsafe.Pointer(p)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue