samuela / rustybox Goto Github PK
View Code? Open in Web Editor NEWA free-range, non-GMO fork of busybox in 100% Rust π¦
A free-range, non-GMO fork of busybox in 100% Rust π¦
Trying to build it in WSL2 gives the error:
error: legacy asm! syntax is no longer supported
archival/dpkg.rs:2451:3
|
2451 | asm!("" : : : "memory" : "volatile");
| ----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| help: replace with: `llvm_asm!
in a bunch of places (422 errors)
Here's the relevant system information:
Linux Version: 4.4.0-18362-Microsoft x86_64 x86_64 x86_64 GNU/Linux
Ubuntu Version: Ubuntu 18.04.4 LTS
Windows Version: Windows 10 Pro 1909 (v. 18363.836)
Rust version: 1.45.0-nightly (4bd32c980 2020-05-29)
I tried building it on windows without success. Are there any plans for a Windows version too? What might be the effort required for that?
Is this project abandoned? If so please archive it.
Also this still has no license #1
Cargo.toml should probably have the licence in and inclusion in the root.
I think you want this in Cargo.toml:
license = "GPL-2.0-only"
Perhaps the AUTHORS file from busybox as well.
Great work!
Is it possible to include some applets from toybox?
For example the file command
Toybox is BSD licence and Busybox is GPL licence, I don't know if they can be mixed together :/
Do you think it would be clearer if the entrypoints used the full path names (here)[https://github.com/samuela/rustybox/blob/master/applets/applet_tables.rs#L424]?
Great work in cleaning up that file btw, it looks great now.
Hi,
I have found a rust unshare repo: https://github.com/tailhook/unshare
Maybe it's interesting for compare between the native rust library and the converted code from busybox?
Regards
I get the build working with a glibc based Host and nightly channel.
But it isn't static and it should be musl linux target.
Is it possible to build for musl target? Musl host build fails I know. So I would try to build on a glibc host with musl target. Should that work?
Or how else I could build a small static binary?
This isn't the case if you call it through the raw binary, e.g:
$ rustybox yes test
This will print something like the following:
yes test
yes test
yes test
Where it should be printing the following instead:
test
test
test
This is because it doesn't use the args that were passed into the function but instead get's the args from the env
crate directly.
Hi,
I tried to built rustybox inside of a docker container, but it fails with debian and alpine based Dockerfiles.
FROM liuchong/rustup:stable-musl AS build
#FROM rust:alpine
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
clang \
git
#RUN apk --update --no-cache add \
# build-base \
# pkgconfig \
# clang \
# gcc \
# git
RUN git clone https://github.com/samuela/rustybox.git /mnt/gitrepo-rustybox
WORKDIR /mnt/gitrepo-rustybox
RUN cargo build --all-features
error:
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2020-02-19, rust version 1.43.0-nightly (e620d0f33 2020-02-18)
warning: Force-skipping unavailable component 'clippy-x86_64-unknown-linux-gnu'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
Updating crates.io index
Downloading crates ...
Downloaded lazy_static v1.4.0
Downloaded c2rust-bitfields v0.3.0
Downloaded c2rust-asm-casts v0.1.1
Downloaded libc v0.2.65
Downloaded c2rust-bitfields-derive v0.2.0
Downloaded quote v0.6.13
Downloaded syn v0.15.44
Downloaded proc-macro2 v0.4.30
Downloaded unicode-xid v0.1.0
Compiling proc-macro2 v0.4.30
Compiling unicode-xid v0.1.0
Compiling syn v0.15.44
Compiling libc v0.2.65
Compiling rustybox v0.0.0 (/mnt/gitrepo-rustybox)
Compiling lazy_static v1.4.0
error[E0463]: can't find crate for `core`
|
= note: the `x86_64-unknown-linux-musl` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `lazy_static`.
warning: build failed, waiting for other jobs to finish...
error: build failed
As users have pointed out on HN, since this is a direct conversion from C, thereβs a lot of usages of unsafe
. I think it would be nice to denote this in two ways:
A statement exclaiming such somewhere near the top, like βThis is still a work in progress and contains memory-unsafe code as translated from C.β
A bullet point in the contributing section about reducing unsafe
usages, as imaginably that would be a useful goal.
I am interested in trying to contribute and if I do this may be a focus area for me.
Cheers.
After cloning the repository and running cargo build --release
(Ubuntu 19.10 arm64
), an error is thrown:
$ cargo build --release
info: syncing channel updates for 'nightly-aarch64-unknown-linux-gnu'
info: latest update on 2019-12-03, rust version 1.41.0-nightly (fdc001156 2019-12-02)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-12-02-aarch64-unknown-linux-gnu'
info: latest update on 2019-12-02, rust version 1.41.0-nightly (4007d4ef2 2019-12-01)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-12-01-aarch64-unknown-linux-gnu'
info: latest update on 2019-12-01, rust version 1.41.0-nightly (d8bdb3fdc 2019-11-30)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-11-30-aarch64-unknown-linux-gnu'
info: latest update on 2019-11-30, rust version 1.41.0-nightly (25d8a9494 2019-11-29)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-11-29-aarch64-unknown-linux-gnu'
info: latest update on 2019-11-29, rust version 1.41.0-nightly (bbb664a99 2019-11-28)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-11-28-aarch64-unknown-linux-gnu'
info: latest update on 2019-11-28, rust version 1.41.0-nightly (e87a205c2 2019-11-27)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-11-27-aarch64-unknown-linux-gnu'
info: latest update on 2019-11-27, rust version 1.41.0-nightly (797fd9262 2019-11-26)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-11-26-aarch64-unknown-linux-gnu'
info: latest update on 2019-11-26, rust version 1.41.0-nightly (a44774c3a 2019-11-25)
info: skipping nightly which is missing installed component 'clippy-preview'
info: syncing channel updates for 'nightly-2019-11-25-aarch64-unknown-linux-gnu'
info: latest update on 2019-11-25, rust version 1.41.0-nightly (412f43ac5 2019-11-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustc-dev'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustc-dev'
info: installing component 'rustfmt'
Updating crates.io index
Downloaded libc v0.2.65
Downloaded lazy_static v1.4.0
Downloaded c2rust-asm-casts v0.1.1
Downloaded f128 v0.2.6
Downloaded c2rust-bitfields v0.3.0
Downloaded c2rust-bitfields-derive v0.2.0
Downloaded quote v0.6.13
Downloaded syn v0.15.44
Downloaded num-traits v0.2.9
Downloaded f128_input v0.2.1
Downloaded f128_internal v0.2.1
Downloaded unicode-xid v0.1.0
Downloaded autocfg v0.1.7
Downloaded proc-macro2 v0.4.30
Downloaded cc v1.0.47
Compiling proc-macro2 v0.4.30
Compiling autocfg v0.1.7
Compiling libc v0.2.65
Compiling cc v1.0.47
Compiling unicode-xid v0.1.0
Compiling syn v0.15.44
Compiling rustybox v0.0.0 (/home/ubuntu/src/github.com/samuela/rustybox)
Compiling lazy_static v1.4.0
Compiling c2rust-asm-casts v0.1.1
Compiling num-traits v0.2.9
Compiling quote v0.6.13
Compiling f128_internal v0.2.1
error: failed to run custom build command for `f128_internal v0.2.1`
Caused by:
process didn't exit successfully: `/home/ubuntu/src/github.com/samuela/rustybox/target/release/build/f128_internal-7dde1865362d42db/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("aarch64-unknown-linux-gnu")
OPT_LEVEL = Some("z")
HOST = Some("aarch64-unknown-linux-gnu")
CC_aarch64-unknown-linux-gnu = None
CC_aarch64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_aarch64-unknown-linux-gnu = None
CFLAGS_aarch64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fp,neon")
running: "cc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-Bstatic" "-lgfortran" "-lquadmath" "-o" "/home/ubuntu/src/github.com/samuela/rustybox/target/release/build/f128_internal-cd7ce17671f7d9fd/out/src/f128.o" "-c" "src/f128.c"
cargo:warning=src/f128.c:2:10: fatal error: quadmath.h: No such file or directory
cargo:warning= 2 | #include <quadmath.h>
cargo:warning= | ^~~~~~~~~~~~
cargo:warning=compilation terminated.
exit code: 1
--- stderr
error occurred: Command "cc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-Bstatic" "-lgfortran" "-lquadmath" "-o" "/home/ubuntu/src/github.com/samuela/rustybox/target/release/build/f128_internal-cd7ce17671f7d9fd/out/src/f128.o" "-c" "src/f128.c" with args "cc" did not execute successfully (status code exit code: 1).
warning: build failed, waiting for other jobs to finish...
error: build failed
I get errors like the following when running on Ubuntu 18.04 on the master branch. Does any ideas what the cause could be?
error[E0599]: no method named `wrapping_offset_from` found for raw pointer `*mut i8` in the current scope --> util_linux/mdev.rs:582:17 | 582 | s.wrapping_offset_from(val) as libc::c_long as libc::c_int, | ^^^^^^^^^^^^^^^^^^^^ help: there is an associated function with a similar name: `wrapping_offset` | = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
It seems like c2rust has removed a lot of the named constants so we've ended up with a bunch of magic numbers which are a lot less readable.
A good example might dumpkmap which has the following on line 77:
write(
1i32,
bb_common_bufsiz1.as_mut_ptr() as *const libc::c_void,
(7i32 + 256i32) as size_t,
);
Versus the busybox version:
write(
STDOUT_FILENO,
flags,
7 + MAX_NR_KEYMAPS
);
If and when someone gets c2rust refactor
going this might be something good to tackle.
Hi,
I again try to move to rustybox because it would be easier to build (if musl / static build works) for custom needs.
With busybox binary I have some problems with modprobe_small which not handle (soft) deps as should.
Supports rustybox modprobe, modprobe_small or both?
So I was trying to compile rustybox and obviously, I have the latest nightly toolchain.
But I'm afraid that the build failed viciously π
I wonder, would it require the nightly toolchain which was present back at the time of the last commit made on May 31, 2020
?
I've attached the log below.
log.txt
Just to make sure you get that I can use some "harsh language" from time to time, but it is getting cool here? Guess it's this project! (and somethings can get lost by translation as well).
Nice done!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.