new package: unar

This commit is contained in:
Tee KOBAYASHI 2022-01-02 18:32:22 +09:00 committed by Leonid Pliushch
parent 1b256dae46
commit c8ed49a65f
5 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,29 @@
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -71,20 +71,20 @@
rm -f $@
$(AR) rcs $@ $^
-../UniversalDetector/libUniversalDetector.a:
- make -C ../UniversalDetector -f Makefile.linux
+UniversalDetector/libUniversalDetector.a:
+ make -C UniversalDetector -f Makefile.linux
-unar: $(UNAR_OBJS) $(CMDLINE_OBJS) libXADMaster.a ../UniversalDetector/libUniversalDetector.a
+unar: $(UNAR_OBJS) $(CMDLINE_OBJS) libXADMaster.a UniversalDetector/libUniversalDetector.a
$(LD) $(ALL_LDFLAGS) -o $@ $^ $(LIBS)
-lsar: $(LSAR_OBJS) $(CMDLINE_OBJS) libXADMaster.a ../UniversalDetector/libUniversalDetector.a
+lsar: $(LSAR_OBJS) $(CMDLINE_OBJS) libXADMaster.a UniversalDetector/libUniversalDetector.a
$(LD) $(ALL_LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf $(BUILD_DIR) $(EXECUTABLE_FILES) $(LIBRARY_FILES)
- make -C ../UniversalDetector -f Makefile.linux clean
+ make -C UniversalDetector -f Makefile.linux clean
-.PHONY: ../UniversalDetector/libUniversalDetector.a clean
+.PHONY: UniversalDetector/libUniversalDetector.a clean
# Suffix rules

View File

@ -0,0 +1,12 @@
--- a/XADPlatformLinux.m
+++ b/XADPlatformLinux.m
@@ -25,6 +25,9 @@
#import <unistd.h>
#import <sys/stat.h>
#import <sys/time.h>
+#if defined __ANDROID__ && __ANDROID_API__ < 26
+#import "sys_time.c"
+#endif

View File

@ -0,0 +1,11 @@
--- a/XADString.m
+++ b/XADString.m
@@ -20,7 +20,7 @@
*/
#import "XADString.h"
-#import "../UniversalDetector/UniversalDetector.h"
+#import "UniversalDetector/UniversalDetector.h"

37
packages/unar/build.sh Normal file
View File

@ -0,0 +1,37 @@
TERMUX_PKG_HOMEPAGE=https://theunarchiver.com/command-line
TERMUX_PKG_DESCRIPTION="Command line tools for archive and file unarchiving and extraction"
TERMUX_PKG_LICENSE="LGPL-2.1"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=()
TERMUX_PKG_VERSION+=(1.10.7)
TERMUX_PKG_VERSION+=(1.1)
TERMUX_PKG_SRCURL=(https://github.com/MacPaw/XADMaster/archive/v${TERMUX_PKG_VERSION}/XADMaster-${TERMUX_PKG_VERSION}.tar.gz
https://github.com/MacPaw/universal-detector/archive/${TERMUX_PKG_VERSION[1]}/universal-detector-${TERMUX_PKG_VERSION[1]}.tar.gz)
TERMUX_PKG_SHA256=(3d766dc1856d04a8fb6de9942a6220d754d0fa7eae635d5287e7b1cf794c4f45
8e8532111d0163628eb828a60d67b53133afad3f710b1967e69d3b8eee28a811)
TERMUX_PKG_DEPENDS="libbz2, libc++, libgnustep-base, libicu, libwavpack, zlib"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_MAKE_ARGS="-e -f Makefile.linux"
termux_step_post_get_source() {
mv universal-detector-${TERMUX_PKG_VERSION[1]} UniversalDetector
cp $TERMUX_PKG_BUILDER_DIR/sys_time.c ./
}
termux_step_pre_configure() {
CFLAGS+=" $CPPFLAGS"
CXXFLAGS+=" $CPPFLAGS"
export OBJCC="$CC"
export OBJCFLAGS="$CFLAGS -fobjc-nonfragile-abi"
LD="$CXX"
}
termux_step_make_install() {
install -Dm700 -t $TERMUX_PREFIX/bin lsar unar
install -Dm600 -t $TERMUX_PREFIX/share/man/man1 Extra/*.1
mkdir -p $TERMUX_PREFIX/share/bash-completion/completions
for c in lsar unar; do
install -Dm600 Extra/${c}.bash_completion \
$TERMUX_PREFIX/share/bash-completion/completions/${c}
done
}

62
packages/unar/sys_time.c Normal file
View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/time.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#pragma GCC visibility push(hidden)
int timespec_from_timeval(struct timespec ts, const struct timeval tv) {
// Whole seconds can just be copied.
ts.tv_sec = tv.tv_sec;
// But we might overflow when converting microseconds to nanoseconds.
if (tv.tv_usec >= 1000000 || tv.tv_usec < 0) {
return 0;
}
ts.tv_nsec = tv.tv_usec * 1000;
return 1;
}
static int futimesat(int fd, const char* path, const struct timeval tv[2], int flags) {
struct timespec ts[2];
if (tv && (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1]))) {
errno = EINVAL;
return -1;
}
return utimensat(fd, path, tv ? ts : NULL, flags);
}
int lutimes(const char* path, const struct timeval tv[2]) {
return futimesat(AT_FDCWD, path, tv, AT_SYMLINK_NOFOLLOW);
}
#pragma GCC visibility pop