From 34ba38e6435e94312f7f83b0fb1eb67f8c743dcd Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Sun, 8 Oct 2017 08:09:26 +0000
Subject: [PATCH 1/4] Update dependencies to packages with Haiku support

* num_cpus from 1.1.0 to 1.4.0
* fs2 from 0.3.0 to 0.4.2
---
 Cargo.lock | 12 ++++++------
 Cargo.toml |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 679ed04..4c23ac6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12,7 +12,7 @@ dependencies = [
  "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "git2 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -22,7 +22,7 @@ dependencies = [
  "libgit2-sys 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "num_cpus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -181,7 +181,7 @@ dependencies = [
 
 [[package]]
 name = "fs2"
-version = "0.3.0"
+version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -435,7 +435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "num_cpus"
-version = "1.1.0"
+version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -660,7 +660,7 @@ dependencies = [
 "checksum error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "318cb3c71ee4cdea69fdc9e15c173b245ed6063e1709029e8fd32525a881120f"
 "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
 "checksum flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "3eeb481e957304178d2e782f2da1257f1434dfecbae883bafb61ada2a9fea3bb"
-"checksum fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "640001e1bd865c7c32806292822445af576a6866175b5225aa2087ca5e3de551"
+"checksum fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ab76cfd2aaa59b7bf6688ad9ba15bbae64bff97f04ea02144cfd3443e5c2866"
 "checksum gcc 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)" = "771e4a97ff6f237cf0f7d5f5102f6e28bb9743814b6198d684da5c58b76c11e0"
 "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
 "checksum git2 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0534ca86640c6a3a0687cc6bee9ec4032509a0d112d97e8241fa6b7e075f6119"
@@ -688,7 +688,7 @@ dependencies = [
 "checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c"
 "checksum num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "54ff603b8334a72fbb27fe66948aac0abaaa40231b3cecd189e76162f6f38aaf"
 "checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c"
-"checksum num_cpus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8890e6084723d57d0df8d2720b0d60c6ee67d6c93e7169630e4371e88765dcad"
+"checksum num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca313f1862c7ec3e0dfe8ace9fa91b1d9cb5c84ace3d00f5ec4216238e93c167"
 "checksum openssl 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0c00da69323449142e00a5410f0e022b39e8bbb7dc569cee8fc6af279279483c"
 "checksum openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "756d49c8424483a3df3b5d735112b4da22109ced9a8294f1f5cdf80fb3810919"
 "checksum openssl-sys 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b1482f9a06f56c906007e17ea14d73d102210b5d27bc948bf5e175f493f3f7c3"
diff --git a/Cargo.toml b/Cargo.toml
index 54ca093..ea6c16a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,7 @@ docopt = "0.6"
 env_logger = "0.3"
 filetime = "0.1"
 flate2 = "0.2"
-fs2 = "0.3"
+fs2 = "0.4.2"
 git2 = "0.6"
 git2-curl = "0.7"
 glob = "0.2"
-- 
2.7.0


From 3757cd1452455ebeef36e6e7b91edf8f6e23824f Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Sun, 8 Oct 2017 08:10:10 +0000
Subject: [PATCH 2/4] Haiku: libc does not define SIGSYS. Use the constant
 instead.

To be fixed in future versions of liblibc
---
 src/cargo/util/errors.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs
index c54199f..f821085 100644
--- a/src/cargo/util/errors.rs
+++ b/src/cargo/util/errors.rs
@@ -429,7 +429,7 @@ pub fn process_error(msg: &str,
                 libc::SIGSEGV => ", SIGSEGV: invalid memory reference",
                 libc::SIGTERM => ", SIGTERM: termination signal",
                 libc::SIGBUS => ", SIGBUS: access to undefined memory",
-                libc::SIGSYS => ", SIGSYS: bad system call",
+                25 => ", SIGSYS: bad system call",
                 libc::SIGTRAP => ", SIGTRAP: trace/breakpoint trap",
                 _ => "",
             };
-- 
2.7.0


From ee129f92b11a54d127c33ae7498c6ceecb54d654 Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Sun, 8 Oct 2017 11:30:02 +0000
Subject: [PATCH 3/4] Haiku: properly process the SYSCONFDIR for Haiku
 packaging

---
 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index 55e9bb0..ea47e82 100755
--- a/configure
+++ b/configure
@@ -379,6 +379,7 @@ CFG_INFODIR=${CFG_INFODIR#${CFG_PREFIX}}
 CFG_DOCDIR=${CFG_DOCDIR#${CFG_PREFIX}}
 CFG_MANDIR=${CFG_MANDIR#${CFG_PREFIX}}
 CFG_LIBDIR=${CFG_LIBDIR#${CFG_PREFIX}}
+CFG_SYSCONFDIR=${CFG_SYSCONFDIR#${CFG_PREFIX}}
 
 # copy host-triples to target-triples so that hosts are a subset of targets
 V_TEMP=""
@@ -407,6 +408,7 @@ putvar CFG_DOCDIR
 putvar CFG_INFODIR
 putvar CFG_MANDIR
 putvar CFG_LIBDIR
+putvar CFG_SYSCONFDIR
 putvar CFG_RUSTC
 putvar CFG_RUSTDOC
 putvar CFG_CARGO
-- 
2.7.0


From cadf34e1936325e1ddd2c79f22f97359ef5b931f Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Sun, 8 Oct 2017 17:54:43 +0000
Subject: [PATCH 4/4] Haiku: rename() gives an error when the filenames are the
 same. Backport of future fix

---
 src/cargo/ops/cargo_rustc/mod.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs
index fd8c379..d004b73 100644
--- a/src/cargo/ops/cargo_rustc/mod.rs
+++ b/src/cargo/ops/cargo_rustc/mod.rs
@@ -373,7 +373,7 @@ fn rustc(cx: &mut Context, unit: &Unit, exec: Arc<Executor>) -> CargoResult<Work
             let src = dst.with_file_name(dst.file_name().unwrap()
                                             .to_str().unwrap()
                                             .replace(&real_name, &crate_name));
-            if src.exists() {
+            if src.exists() && src.file_name() != dst.file_name() {
                 fs::rename(&src, &dst).chain_error(|| {
                     internal(format!("could not rename crate {:?}", src))
                 })?;
-- 
2.7.0

