diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c060d61
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+SOURCES/libguestfs.keyring
+SOURCES/libnbd-1.2.2.tar.gz
diff --git a/.libnbd.metadata b/.libnbd.metadata
new file mode 100644
index 0000000..33fa200
--- /dev/null
+++ b/.libnbd.metadata
@@ -0,0 +1,2 @@
+1bbc40f501a7fef9eef2a39b701a71aee2fea7c4 SOURCES/libguestfs.keyring
+68e213e85346cc7b9c390e2a4916c7b3f30345e1 SOURCES/libnbd-1.2.2.tar.gz
diff --git a/SOURCES/libnbd-1.2.2.tar.gz.sig b/SOURCES/libnbd-1.2.2.tar.gz.sig
new file mode 100644
index 0000000..a353ae2
--- /dev/null
+++ b/SOURCES/libnbd-1.2.2.tar.gz.sig
@@ -0,0 +1,17 @@
+-----BEGIN PGP SIGNATURE-----
+
+iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAl46yJwRHHJpY2hAYW5u
+ZXhpYS5vcmcACgkQkXOPc+G3aKBNsBAAi+GGHQZ/2VZ/LiqO+kc5hzAsbxfCUb6e
+epLTmHry0sFdDFGeVwaYZxvnALu61nybMvaHsASW8FlWDbtgaqx6tUApgeV46oXb
+yvT1EzmxR4+U8cwb9IEDRBjB1WWqYv+TYltljkV5nmO1DADOZr9AV5yRp872SWsP
+oshiuuxwIw+ugQfXkyhUPgyO2FzjxntmWCjD13nQhDeD42UQUE+0mxAgXiGfsOj4
+eArCsa4Us/ZWpg9QkoXomzpN1xzMoTEQ9a+7PVTn54bfCCgThdodVN5rNxuNhSKU
+yYHl6hUW1gnZaQ17FfqZrOcEFjvVnDYDlkoHF9Vp4AOTNMCd/w008NjKt+yR90WW
+yeiJ21mRpkA/6pK5irHEBMFmk9cf/5IIhgF9Xtl5erqKYQu6W5NqXr4BCTdDS4BL
+auHV+I8Dqi9IEH8bhZYxErS/eba6N6ZJWkwHqbdwtfZBBSqEcZXrTXviXw0BpCsy
+lPGx2xXXmGPB5/BojOmFOEzfPMtiLsLrVW5DwlBoeT90kFEhi7+bGB5gJ24NxL1y
+/2XcTxRhv79FMBdLx+6O7/js/tMrOxmKRkUcInU4rjOg+VGmwx6+LeJ2P0au8ufx
+8Rvk7DHUF0ZazsbJ4IkL0XP4jWIgB2xMJqjIq+E2duLO+c1sDUBxoU43BgCLYUV9
+92Ap8fwsbvA=
+=zo1m
+-----END PGP SIGNATURE-----
diff --git a/SPECS/libnbd.spec b/SPECS/libnbd.spec
new file mode 100644
index 0000000..8c05457
--- /dev/null
+++ b/SPECS/libnbd.spec
@@ -0,0 +1,351 @@
+# If we should verify tarball signature with GPGv2.
+%global verify_tarball_signature 1
+
+# If there are patches which touch autotools files, set this to 1.
+%global patches_touch_autotools %{nil}
+
+# The source directory.
+%global source_directory 1.2-stable
+
+Name:           libnbd
+Version:        1.2.2
+Release:        1%{?dist}
+Summary:        NBD client library in userspace
+
+License:        LGPLv2+
+URL:            https://github.com/libguestfs/libnbd
+
+Source0:        http://libguestfs.org/download/libnbd/%{source_directory}/%{name}-%{version}.tar.gz
+Source1:        http://libguestfs.org/download/libnbd/%{source_directory}/%{name}-%{version}.tar.gz.sig
+# Keyring used to verify tarball signature.  This contains the single
+# key from here:
+# https://pgp.key-server.io/pks/lookup?search=rjones%40redhat.com&fingerprint=on&op=vindex
+Source2:       libguestfs.keyring
+
+%if 0%{patches_touch_autotools}
+BuildRequires: autoconf, automake, libtool
+%endif
+
+%if 0%{verify_tarball_signature}
+BuildRequires:  gnupg2
+%endif
+
+# For the core library.
+BuildRequires:  gcc
+BuildRequires:  /usr/bin/pod2man
+BuildRequires:  gnutls-devel
+BuildRequires:  libxml2-devel
+
+# For nbdfuse.
+BuildRequires:  fuse, fuse-devel
+
+# For the Python 3 bindings.
+BuildRequires:  python3-devel
+
+# For the OCaml bindings.
+BuildRequires:  ocaml
+BuildRequires:  ocaml-findlib-devel
+
+# Only for building the examples.
+BuildRequires:  glib2-devel
+
+# Only for running the test suite.
+BuildRequires:  gnutls-utils
+%ifnarch %{ix86}
+BuildRequires:  nbdkit
+#BuildRequires:  nbdkit-memory-plugin
+#BuildRequires:  nbdkit-null-plugin
+#BuildRequires:  nbdkit-pattern-plugin
+#BuildRequires:  nbdkit-sh-plugin
+BuildRequires:  qemu-img
+%endif
+BuildRequires:  gcc-c++
+
+
+%description
+NBD — Network Block Device — is a protocol for accessing Block Devices
+(hard disks and disk-like things) over a Network.
+
+This is the NBD client library in userspace, a simple library for
+writing NBD clients.
+
+The key features are:
+
+ * Synchronous and asynchronous APIs, both for ease of use and for
+   writing non-blocking, multithreaded clients.
+
+ * High performance.
+
+ * Minimal dependencies for the basic library.
+
+ * Well-documented, stable API.
+
+ * Bindings in several programming languages.
+
+
+%package devel
+Summary:        Development headers for %{name}
+License:        LGPLv2+ and BSD
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+
+
+%description devel
+This package contains development headers for %{name}.
+
+
+%package -n ocaml-%{name}
+Summary:        OCaml language bindings for %{name}
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+
+
+%description -n ocaml-%{name}
+This package contains OCaml language bindings for %{name}.
+
+
+%package -n ocaml-%{name}-devel
+Summary:        OCaml language development package for %{name}
+Requires:       ocaml-%{name}%{?_isa} = %{version}-%{release}
+
+
+%description -n ocaml-%{name}-devel
+This package contains OCaml language development package for
+%{name}.  Install this if you want to compile OCaml software which
+uses %{name}.
+
+
+%package -n python3-%{name}
+Summary:        Python 3 bindings for %{name}
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+%{?python_provide:%python_provide python3-%{name}}
+
+# The Python module happens to be called lib*.so.  Don't scan it and
+# have a bogus "Provides: libnbdmod.*".
+%global __provides_exclude_from ^%{python3_sitearch}/lib.*\\.so
+
+
+%description -n python3-%{name}
+python3-%{name} contains Python 3 bindings for %{name}.
+
+
+%package -n nbdfuse
+Summary:        FUSE support for %{name}
+License:        LGPLv2+ and BSD
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+
+
+%description -n nbdfuse
+This package contains FUSE support for %{name}.
+
+
+%prep
+%if 0%{verify_tarball_signature}
+tmphome="$(mktemp -d)"
+gpgv2 --homedir "$tmphome" --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0}
+%endif
+%autosetup -p1
+%if 0%{patches_touch_autotools}
+autoreconf -i
+%endif
+
+
+%build
+%configure \
+    --disable-static \
+    --with-tls-priority=@LIBNBD,SYSTEM \
+    PYTHON=%{__python3} \
+    --enable-python \
+    --enable-ocaml \
+    --enable-fuse
+
+make %{?_smp_mflags}
+
+
+%install
+%make_install
+
+# Delete libtool crap.
+find $RPM_BUILD_ROOT -name '*.la' -delete
+
+
+%check
+# interop/structured-read.sh fails with the old qemu-nbd in Fedora 29,
+# so disable it there.
+%if 0%{?fedora} <= 29
+rm interop/structured-read.sh
+touch interop/structured-read.sh
+chmod +x interop/structured-read.sh
+%endif
+
+# All fuse tests fail in Koji with:
+# fusermount: entry for fuse/test-*.d not found in /etc/mtab
+# for unknown reasons but probably related to the Koji environment.
+for f in fuse/test-*.sh; do
+    rm $f
+    touch $f
+    chmod +x $f
+done
+
+make %{?_smp_mflags} check || {
+    for f in $(find -name test-suite.log); do
+        echo
+        echo "==== $f ===="
+        cat $f
+    done
+    exit 1
+  }
+
+
+%files
+%doc README
+%license COPYING.LIB
+%{_libdir}/libnbd.so.*
+
+
+%files devel
+%doc TODO examples/*.c
+%license examples/LICENSE-FOR-EXAMPLES
+%{_includedir}/libnbd.h
+%{_libdir}/libnbd.so
+%{_libdir}/pkgconfig/libnbd.pc
+%{_mandir}/man3/libnbd.3*
+%{_mandir}/man1/libnbd-release-notes-1.*.1*
+%{_mandir}/man3/libnbd-security.3*
+%{_mandir}/man3/nbd_*.3*
+
+
+%files -n ocaml-%{name}
+%{_libdir}/ocaml/nbd
+%exclude %{_libdir}/ocaml/nbd/*.a
+%exclude %{_libdir}/ocaml/nbd/*.cmxa
+%exclude %{_libdir}/ocaml/nbd/*.cmx
+%exclude %{_libdir}/ocaml/nbd/*.mli
+%{_libdir}/ocaml/stublibs/dllmlnbd.so
+%{_libdir}/ocaml/stublibs/dllmlnbd.so.owner
+
+
+%files -n ocaml-%{name}-devel
+%doc ocaml/examples/*.ml
+%license ocaml/examples/LICENSE-FOR-EXAMPLES
+%{_libdir}/ocaml/nbd/*.a
+%{_libdir}/ocaml/nbd/*.cmxa
+%{_libdir}/ocaml/nbd/*.cmx
+%{_libdir}/ocaml/nbd/*.mli
+%{_mandir}/man3/libnbd-ocaml.3*
+
+
+%files -n python3-%{name}
+%{python3_sitearch}/libnbdmod*.so
+%{python3_sitearch}/nbd.py
+%{python3_sitearch}/nbdsh.py
+%{python3_sitearch}/__pycache__/nbd*.py*
+%{_bindir}/nbdsh
+%{_mandir}/man1/nbdsh.1*
+
+
+%files -n nbdfuse
+%{_bindir}/nbdfuse
+%{_mandir}/man1/nbdfuse.1*
+
+
+%changelog
+* Wed Feb  5 2020 Richard W.M. Jones <rjones@redhat.com> - 1.2.2-1
+- New stable release 1.2.2.
+
+* Tue Dec  3 2019 Richard W.M. Jones <rjones@redhat.com> - 1.2.1-1
+- New stable release 1.2.1.
+
+* Thu Nov 14 2019 Richard W.M. Jones <rjones@redhat.com> - 1.2.0-1
+- New stable release 1.2.0.
+
+* Wed Oct  9 2019 Richard W.M. Jones <rjones@redhat.com> - 1.0.3-1
+- New upstream version 1.0.3.
+- Contains fix for remote code execution vulnerability.
+- Add new libnbd-security(3) man page.
+
+* Tue Sep 17 2019 Richard W.M. Jones <rjones@redhat.com> - 1.0.2-1
+- New upstream version 1.0.2.
+- Remove patches which are upstream.
+- Contains fix for NBD Protocol Downgrade Attack (CVE-2019-14842).
+- Fix previous commit message.
+
+* Thu Sep 12 2019 Richard W.M. Jones <rjones@redhat.com> - 1.0.1-2
+- Add upstream patch to fix nbdsh (for nbdkit tests).
+- Fix interop tests on slow machines.
+
+* Sun Sep 08 2019 Richard W.M. Jones <rjones@redhat.com> - 1.0.1-1
+- New stable version 1.0.1.
+
+* Wed Aug 28 2019 Richard W.M. Jones <rjones@redhat.com> - 1.0.0-1
+- New upstream version 1.0.0.
+
+* Wed Aug 21 2019 Miro Hrončok <mhroncok@redhat.com> - 0.9.9-2
+- Rebuilt for Python 3.8
+
+* Wed Aug 21 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.9-1
+- New upstream version 0.9.9.
+
+* Wed Aug 21 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.8-4
+- Fix nbdkit dependencies so we're actually running the tests.
+- Add glib2-devel BR so we build the glib main loop example.
+- Add upstream patch to fix test error:
+  nbd_connect_unix: getlogin: No such device or address
+- Fix test failure on 32 bit.
+
+* Tue Aug 20 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.8-3
+- Bump and rebuild to fix releng brokenness.
+  https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/2LIDI33G3IEIPYSCCIP6WWKNHY7XZJGQ/
+
+* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.9.8-2
+- Rebuilt for Python 3.8
+
+* Thu Aug 15 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.8-1
+- New upstream version 0.9.8.
+- Package the new nbd_*(3) man pages.
+
+* Mon Aug  5 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.7-1
+- New upstream version 0.9.7.
+- Add libnbd-ocaml(3) man page.
+
+* Sat Aug  3 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.6-2
+- Add all upstream patches since 0.9.6 was released.
+- Package the ocaml bindings into a subpackage.
+
+* Tue Jul 30 2019 Richard W.M. Jones <rjones@redhat.com> - 0.9.6-1
+- New upstream verison 0.9.6.
+
+* Fri Jul 26 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.9-1
+- New upstream version 0.1.9.
+
+* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.8-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
+
+* Wed Jul 17 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.8-1
+- New upstream version 0.1.8.
+
+* Tue Jul 16 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.7-1
+- New upstream version 0.1.7.
+
+* Wed Jul  3 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.6-1
+- New upstream version 0.1.6.
+
+* Thu Jun 27 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.5-1
+- New upstream version 0.1.5.
+
+* Sun Jun 09 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.4-1
+- New upstream version 0.1.4.
+
+* Sun Jun  2 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.2-2
+- Enable libxml2 for NBD URI support.
+
+* Thu May 30 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.2-1
+- New upstream version 0.1.2.
+
+* Tue May 28 2019 Richard W.M. Jones <rjones@redhat.com> - 0.1.1-1
+- Fix license in man pages and examples.
+- Add nbdsh(1) man page.
+- Include the signature and keyring even if validation is disabled.
+- Update devel subpackage license.
+- Fix old FSF address in Python tests.
+- Filter Python provides.
+- Remove executable permission on the tar.gz.sig file.
+- Initial release.