new package: below

This commit is contained in:
Tee KOBAYASHI 2022-03-25 06:10:33 +09:00 committed by xtkoba
parent ed872ed00d
commit b312b033ab
7 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,15 @@
--- a/below/config/src/lib.rs
+++ b/below/config/src/lib.rs
@@ -22,9 +22,9 @@
#[cfg(test)]
mod test;
-pub const BELOW_DEFAULT_CONF: &str = "/etc/below/below.conf";
-const BELOW_DEFAULT_LOG: &str = "/var/log/below";
-const BELOW_DEFAULT_STORE: &str = "/var/log/below/store";
+pub const BELOW_DEFAULT_CONF: &str = "@TERMUX_PREFIX@/etc/below/below.conf";
+const BELOW_DEFAULT_LOG: &str = "@TERMUX_PREFIX@/var/log/below";
+const BELOW_DEFAULT_STORE: &str = "@TERMUX_PREFIX@/var/log/below/store";
/// Global below config
pub static BELOW_CONFIG: OnceCell<BelowConfig> = OnceCell::new();

55
packages/below/build.sh Normal file
View File

@ -0,0 +1,55 @@
TERMUX_PKG_HOMEPAGE=https://github.com/facebookincubator/below
TERMUX_PKG_DESCRIPTION="An interactive tool to view and record historical system data"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.5.0
TERMUX_PKG_SRCURL=https://github.com/facebookincubator/below/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=9e76d066ce4815b8c51c720375a29d8b0a97a7890fd80602bbe49968573adeb5
TERMUX_PKG_DEPENDS="libelf, zlib"
TERMUX_PKG_BUILD_IN_SRC=true
# ```
# error[E0308]: mismatched types
# --> /home/builder/.cargo/registry/src/github.com-1ecc6299db9ec823/openat-0.1.21/src/dir.rs:465:34
# |
# 465 | match stat.st_mode & libc::S_IFMT {
# | ^^^^^^^^^^^^ expected `u32`, found `u16`
# ```
TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686"
termux_step_pre_configure() {
termux_setup_rust
: "${CARGO_HOME:=$HOME/.cargo}"
export CARGO_HOME
cargo fetch --target $CARGO_TARGET_NAME
local d p
for d in $CARGO_HOME/registry/src/github.com-*/libbpf-sys-*; do
for p in libbpf-sys-0.6.0-1-libbpf-include-linux-{compiler,types}.h.diff; do
patch --silent -p1 -d ${d} \
< "$TERMUX_PKG_BUILDER_DIR/${p}" || :
done
done
for d in $CARGO_HOME/registry/src/github.com-*/nix-*; do
for p in nix-{0.22.0,0.23.1}-src-sys-statfs.rs.diff; do
patch --silent -p1 -d ${d} \
< "$TERMUX_PKG_BUILDER_DIR/${p}" || :
done
done
local _CARGO_TARGET_LIBDIR=target/$CARGO_TARGET_NAME/release/deps
mkdir -p $_CARGO_TARGET_LIBDIR
local lib
for lib in lib{elf,z}.so; do
ln -sf $TERMUX_PREFIX/lib/${lib} $_CARGO_TARGET_LIBDIR/
done
}
termux_step_make() {
cargo build --jobs $TERMUX_MAKE_PROCESSES --target $CARGO_TARGET_NAME --release
}
termux_step_make_install() {
install -Dm700 -t $TERMUX_PREFIX/bin target/${CARGO_TARGET_NAME}/release/below
}

View File

@ -0,0 +1,17 @@
--- a/libbpf/include/linux/compiler.h
+++ b/libbpf/include/linux/compiler.h
@@ -1,5 +1,14 @@
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+#ifdef __ANDROID__
+#ifndef __user
+#define __user
+#endif
+#ifndef __force
+#define __force
+#endif
+#endif /* __ANDROID__ */
+
#ifndef __LINUX_COMPILER_H
#define __LINUX_COMPILER_H

View File

@ -0,0 +1,10 @@
--- a/libbpf/include/linux/types.h
+++ b/libbpf/include/linux/types.h
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+#include_next <linux/types.h>
+
#ifndef __LINUX_TYPES_H
#define __LINUX_TYPES_H

View File

@ -0,0 +1,11 @@
--- a/src/sys/statfs.rs
+++ b/src/sys/statfs.rs
@@ -94,6 +94,8 @@
pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC as fs_type_t);
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC as fs_type_t);
+#[cfg(target_os = "android")]
+pub const CGROUP2_SUPER_MAGIC: FsType = FsType(0x63677270 as fs_type_t);
impl Statfs {

View File

@ -0,0 +1,12 @@
--- a/src/sys/statfs.rs
+++ b/src/sys/statfs.rs
@@ -132,6 +132,9 @@
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
#[allow(missing_docs)]
pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC as fs_type_t);
+#[cfg(target_os = "android")]
+#[allow(missing_docs)]
+pub const CGROUP2_SUPER_MAGIC: FsType = FsType(0x63677270 as fs_type_t);
impl Statfs {

View File

@ -86,6 +86,9 @@ PACKAGES+=" swig"
# Needed by package dbus-glib.
PACKAGES+=" libdbus-1-dev"
# Needed by package below.
PACKAGES+=" libelf-dev"
# Needed by package ghostscript.
PACKAGES+=" libexpat1-dev"
PACKAGES+=" libjpeg-dev"