new package: mdbook-auto-gen-summary

This commit is contained in:
Tee KOBAYASHI 2022-11-28 20:11:35 +09:00 committed by xtkoba
parent 44d663143d
commit 37533d8669
2 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,46 @@
TERMUX_PKG_HOMEPAGE=https://github.com/cococolanosugar/mdbook-auto-gen-summary
TERMUX_PKG_DESCRIPTION="A preprocessor and cli tool for mdbook to auto generate summary"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
_COMMIT=a8e1d8edba05c52d927880a5fe2b97180441c955
TERMUX_PKG_VERSION=0.1.10
TERMUX_PKG_SRCURL=https://github.com/cococolanosugar/mdbook-auto-gen-summary.git
TERMUX_PKG_GIT_BRANCH=master
TERMUX_PKG_BUILD_IN_SRC=true
# https://github.com/termux/termux-packages/issues/12824
TERMUX_RUST_VERSION=1.63.0
termux_step_post_get_source() {
git fetch --unshallow
git checkout $_COMMIT
local ver=$(sed -En 's/^version = "([^"]+)".*/\1/p' Cargo.toml)
if [ "${ver}" != "${TERMUX_PKG_VERSION#*:}" ]; then
termux_error_exit "Version string '$TERMUX_PKG_VERSION' does not seem to be correct."
fi
}
termux_step_pre_configure() {
termux_setup_rust
: "${CARGO_HOME:=$HOME/.cargo}"
export CARGO_HOME
cargo fetch --target "${CARGO_TARGET_NAME}"
local _patch=$TERMUX_PKG_BUILDER_DIR/filetime-src-unix-utimes.rs.diff
local d
for d in $CARGO_HOME/registry/src/github.com-*/filetime-*; do
patch --silent -p1 -d ${d} < ${_patch} || :
done
}
termux_step_make() {
termux_setup_rust
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/mdbook-auto-gen-summary
}

View File

@ -0,0 +1,58 @@
--- a/src/unix/utimes.rs
+++ b/src/unix/utimes.rs
@@ -20,7 +20,7 @@
set_times(p, Some(atime), None, false)
}
-#[cfg(not(target_env = "uclibc"))]
+#[cfg(not(any(target_env = "uclibc", target_os = "android")))]
#[allow(dead_code)]
pub fn set_file_handle_times(
f: &fs::File,
@@ -40,7 +40,7 @@
};
}
-#[cfg(target_env = "uclibc")]
+#[cfg(any(target_env = "uclibc", target_os = "android"))]
#[allow(dead_code)]
pub fn set_file_handle_times(
f: &fs::File,
@@ -85,6 +85,7 @@
set_times(p, Some(atime), Some(mtime), true)
}
+#[cfg(not(target_os = "android"))]
pub fn set_times(
p: &Path,
atime: Option<FileTime>,
@@ -111,6 +112,29 @@
};
}
+#[cfg(target_os = "android")]
+pub fn set_times(
+ p: &Path,
+ atime: Option<FileTime>,
+ mtime: Option<FileTime>,
+ symlink: bool,
+) -> io::Result<()> {
+ let flags = if symlink {
+ libc::AT_SYMLINK_NOFOLLOW
+ } else {
+ 0
+ };
+
+ let p = CString::new(p.as_os_str().as_bytes())?;
+ let times = [super::to_timespec(&atime), super::to_timespec(&mtime)];
+ let rc = unsafe { libc::utimensat(libc::AT_FDCWD, p.as_ptr(), times.as_ptr(), flags) };
+ if rc == 0 {
+ Ok(())
+ } else {
+ Err(io::Error::last_os_error())
+ }
+}
+
fn to_timeval(ft: &FileTime) -> libc::timeval {
libc::timeval {
tv_sec: ft.seconds() as libc::time_t,