From fdc011f21ad9b16f71bb6142da871463ee1093af Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sun, 28 Apr 2019 11:21:38 +0200 Subject: [PATCH] Initial import Signed-off-by: Igor Gnatenko --- .gitignore | 1 + 0001-Use-pnet_-subcrates.patch | 115 +++++++++++++++++++++++++++++++ afterburn-fix-metadata.diff | 19 ++++++ rust-afterburn.spec | 119 +++++++++++++++++++++++++++++++++ sources | 1 + 5 files changed, 255 insertions(+) create mode 100644 .gitignore create mode 100644 0001-Use-pnet_-subcrates.patch create mode 100644 afterburn-fix-metadata.diff create mode 100644 rust-afterburn.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ade8b26 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/afterburn-4.1.0.crate diff --git a/0001-Use-pnet_-subcrates.patch b/0001-Use-pnet_-subcrates.patch new file mode 100644 index 0000000..2f050b0 --- /dev/null +++ b/0001-Use-pnet_-subcrates.patch @@ -0,0 +1,115 @@ +From 96d1972ca872559fc70ad847a53bf9e20417e505 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Sun, 28 Apr 2019 10:43:24 +0200 +Subject: [PATCH] Use pnet_* subcrates + +Signed-off-by: Igor Gnatenko +--- + src/main.rs | 1 - + src/network.rs | 2 +- + src/providers/digitalocean/mod.rs | 2 +- + src/providers/packet/mod.rs | 2 +- + src/providers/vagrant_virtualbox/mod.rs | 6 +++--- + src/util/mod.rs | 4 ++-- + 6 files changed, 8 insertions(+), 9 deletions(-) + +diff --git a/src/main.rs b/src/main.rs +index 337f3da..9743425 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -22,7 +22,6 @@ extern crate ipnetwork; + extern crate nix; + extern crate openssh_keys; + extern crate openssl; +-extern crate pnet; + extern crate reqwest; + #[macro_use] + extern crate serde_derive; +diff --git a/src/network.rs b/src/network.rs +index f084a75..d12037d 100644 +--- a/src/network.rs ++++ b/src/network.rs +@@ -16,7 +16,7 @@ + //! interface unit files. All that is left is to write the resulting string to + //! the necessary unit. + +-use pnet::util::MacAddr; ++use pnet_base::MacAddr; + use std::net::IpAddr; + use std::string::String; + use std::string::ToString; +diff --git a/src/providers/digitalocean/mod.rs b/src/providers/digitalocean/mod.rs +index eeaa7c2..e6ad868 100644 +--- a/src/providers/digitalocean/mod.rs ++++ b/src/providers/digitalocean/mod.rs +@@ -21,7 +21,7 @@ use std::str::FromStr; + use ipnetwork; + use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network}; + use openssh_keys::PublicKey; +-use pnet::util::MacAddr; ++use pnet_base::MacAddr; + + use crate::errors::*; + use crate::network; +diff --git a/src/providers/packet/mod.rs b/src/providers/packet/mod.rs +index f471baf..3a42520 100644 +--- a/src/providers/packet/mod.rs ++++ b/src/providers/packet/mod.rs +@@ -23,7 +23,7 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; + use std::str::FromStr; + + use openssh_keys::PublicKey; +-use pnet::util::MacAddr; ++use pnet_base::MacAddr; + + use crate::errors::*; + use crate::network::{self, Device, Interface, NetworkRoute, Section}; +diff --git a/src/providers/vagrant_virtualbox/mod.rs b/src/providers/vagrant_virtualbox/mod.rs +index e4d4109..5d5ee40 100644 +--- a/src/providers/vagrant_virtualbox/mod.rs ++++ b/src/providers/vagrant_virtualbox/mod.rs +@@ -21,7 +21,7 @@ use std::time::Duration; + + use hostname; + use openssh_keys::PublicKey; +-use pnet; ++use pnet_datalink; + + use crate::errors::*; + use crate::network; +@@ -52,8 +52,8 @@ impl VagrantVirtualboxProvider { + Err("eth1 was not found!".into()) + } + +- fn find_eth1() -> Option { +- let mut ifaces = pnet::datalink::interfaces(); ++ fn find_eth1() -> Option { ++ let mut ifaces = pnet_datalink::interfaces(); + ifaces.retain(|i| i.name == "eth1"); + if !ifaces.is_empty() { + Some(ifaces[0].clone()) +diff --git a/src/util/mod.rs b/src/util/mod.rs +index 80ab3c7..daa49b1 100644 +--- a/src/util/mod.rs ++++ b/src/util/mod.rs +@@ -16,7 +16,7 @@ + + use crate::errors::*; + use crate::retry; +-use pnet; ++use pnet_datalink; + use std::fs::File; + use std::io::{BufRead, BufReader, Read}; + use std::path::Path; +@@ -52,7 +52,7 @@ pub fn key_lookup(delim: char, key: &str, reader: R) -> Result Result { +- let interfaces = pnet::datalink::interfaces(); ++ let interfaces = pnet_datalink::interfaces(); + trace!("interfaces - {:?}", interfaces); + + retry::Retry::new() +-- +2.21.0 + diff --git a/afterburn-fix-metadata.diff b/afterburn-fix-metadata.diff new file mode 100644 index 0000000..4876e05 --- /dev/null +++ b/afterburn-fix-metadata.diff @@ -0,0 +1,19 @@ +--- afterburn-4.1.0/Cargo.toml 1970-01-01T00:00:00+00:00 ++++ afterburn-4.1.0/Cargo.toml 2019-04-27T07:55:33.077957+00:00 +@@ -64,11 +64,14 @@ + [dependencies.openssl] + version = "^0.10.20" + +-[dependencies.pnet] ++[dependencies.pnet_base] ++version = "0.22" ++ ++[dependencies.pnet_datalink] + version = "0.22" + + [dependencies.reqwest] +-version = "^0.9.15" ++version = "^0.9.13" + + [dependencies.serde] + version = "1.0" diff --git a/rust-afterburn.spec b/rust-afterburn.spec new file mode 100644 index 0000000..1ac22cf --- /dev/null +++ b/rust-afterburn.spec @@ -0,0 +1,119 @@ +# Generated by rust2rpm +%bcond_without check + +%global crate afterburn + +Name: rust-%{crate} +Version: 4.1.0 +Release: 1%{?dist} +Summary: Simple cloud provider agent + +# Upstream license specification: Apache-2.0 +License: ASL 2.0 +URL: https://crates.io/crates/afterburn +Source: %{crates_source} +# Initial patched metadata +# * Switch to split version of pnet_* +# * Downgrade reqwest to 0.9.13 temporarily +Patch0: afterburn-fix-metadata.diff +# Finish splitting pnet_* +Patch0001: 0001-Use-pnet_-subcrates.patch + +ExclusiveArch: %{rust_arches} + +BuildRequires: rust-packaging +BuildRequires: (crate(base64/default) >= 0.10.1 with crate(base64/default) < 0.11.0) +BuildRequires: (crate(byteorder/default) >= 1.3.0 with crate(byteorder/default) < 2.0.0) +BuildRequires: (crate(clap/default) >= 2.33.0 with crate(clap/default) < 3.0.0) +BuildRequires: (crate(error-chain) >= 0.12.0 with crate(error-chain) < 0.13.0) +BuildRequires: (crate(hostname/default) >= 0.1.0 with crate(hostname/default) < 0.2.0) +BuildRequires: (crate(ipnetwork/default) >= 0.14.0 with crate(ipnetwork/default) < 0.15.0) +BuildRequires: (crate(mime/default) >= 0.3.0 with crate(mime/default) < 0.4.0) +BuildRequires: (crate(nix/default) >= 0.13.0 with crate(nix/default) < 0.14.0) +BuildRequires: (crate(openssh-keys/default) >= 0.4.1 with crate(openssh-keys/default) < 0.5.0) +BuildRequires: (crate(openssl/default) >= 0.10.20 with crate(openssl/default) < 0.11.0) +BuildRequires: (crate(pnet_base/default) >= 0.22.0 with crate(pnet_base/default) < 0.23.0) +BuildRequires: (crate(pnet_datalink/default) >= 0.22.0 with crate(pnet_datalink/default) < 0.23.0) +BuildRequires: (crate(reqwest/default) >= 0.9.13 with crate(reqwest/default) < 0.10.0) +BuildRequires: (crate(serde-xml-rs/default) >= 0.3.0 with crate(serde-xml-rs/default) < 0.4.0) +BuildRequires: (crate(serde/default) >= 1.0.0 with crate(serde/default) < 2.0.0) +BuildRequires: (crate(serde_derive/default) >= 1.0.0 with crate(serde_derive/default) < 2.0.0) +BuildRequires: (crate(serde_json/default) >= 1.0.0 with crate(serde_json/default) < 2.0.0) +BuildRequires: (crate(slog-async/default) >= 2.1.0 with crate(slog-async/default) < 3.0.0) +BuildRequires: (crate(slog-scope/default) >= 4.1.0 with crate(slog-scope/default) < 4.2.0) +BuildRequires: (crate(slog-term/default) >= 2.2.0 with crate(slog-term/default) < 3.0.0) +BuildRequires: (crate(slog/default) >= 2.0.0 with crate(slog/default) < 3.0.0) +BuildRequires: (crate(slog/max_level_trace) >= 2.0.0 with crate(slog/max_level_trace) < 3.0.0) +BuildRequires: (crate(slog/release_max_level_info) >= 2.0.0 with crate(slog/release_max_level_info) < 3.0.0) +BuildRequires: (crate(tempdir/default) >= 0.3.0 with crate(tempdir/default) < 0.4.0) +BuildRequires: (crate(tempfile/default) >= 3.0.7 with crate(tempfile/default) < 4.0.0) +BuildRequires: (crate(users/default) >= 0.9.1 with crate(users/default) < 0.10.0) +%if %{with check} +BuildRequires: (crate(mockito/default) >= 0.17.0 with crate(mockito/default) < 0.18.0) +%endif +BuildRequires: systemd + +%global _description \ +A simple cloud provider agent. + +%description %{_description} + +%package -n %{crate} +Summary: %{summary} +%{?systemd_requires} + +%description -n %{crate} %{_description} + +%files -n %{crate} +%license LICENSE +%doc README.md +%{_bindir}/afterburn +%{_unitdir}/afterburn.service +%{_unitdir}/afterburn-checkin.service +%{_unitdir}/afterburn-firstboot-checkin.service +%{_unitdir}/afterburn-sshkeys@.service + +%post -n %{crate} +%systemd_post afterburn.service +%systemd_post afterburn-checkin.service +%systemd_post afterburn-firstboot-checkin.service +%systemd_post afterburn-sshkeys@.service + +%preun -n %{crate} +%systemd_preun afterburn.service +%systemd_preun afterburn-checkin.service +%systemd_preun afterburn-firstboot-checkin.service +%systemd_preun afterburn-sshkeys@.service + +%postun -n %{crate} +%systemd_postun afterburn.service +%systemd_postun afterburn-checkin.service +%systemd_postun afterburn-firstboot-checkin.service +%systemd_postun afterburn-sshkeys@.service + +%prep +%autosetup -n %{crate}-%{version_no_tilde} -p1 +# afterburn-sshkeys@.service is by default enabled for the 'core' user in +# Fedora CoreOS. +# Based on https://github.com/coreos/afterburn/blob/master/Makefile. +sed -e 's,@DEFAULT_INSTANCE@,core,' < \ + systemd/afterburn-sshkeys@.service.in > \ + systemd/afterburn-sshkeys@.service +%cargo_prep + +%build +%cargo_build + +%install +%cargo_install +%{__install} -Dpm0644 -t %{buildroot}%{_unitdir} \ + systemd/*.service + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +* Sat Apr 27 09:55:54 CEST 2019 Igor Gnatenko - 4.1.0-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..0537999 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (afterburn-4.1.0.crate) = 171f24befd2af780840d75be98d84130590a2a62c3c8a961c6c408ce561555084d6c8c19ca6746891175fe0fc597066cdaef23e22524fbc38866729102b47598