Skip to content

Commit a35d94d

Browse files
fix(main/7zip): enable 7z.so, 7zr, 7zCon.sfx, ARM assembly and RAR
- License becomes "The 'GNU LGPL' with 'unRAR license restriction' for some code" https://www.7-zip.org/license.txt. Arch Linux builds 7zip this way; Debian and Alpine Linux do not - The x86 assembly is non-position-independent, so is not compatible with Android 5+. The ARM assembly works.
1 parent c8cf04b commit a35d94d

4 files changed

Lines changed: 110 additions & 40 deletions

File tree

packages/7zip/build.sh

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
TERMUX_PKG_HOMEPAGE=https://www.7-zip.org
22
TERMUX_PKG_DESCRIPTION="7-Zip file archiver with a high compression ratio"
33
TERMUX_PKG_LICENSE="LGPL-2.1, BSD 3-Clause, BSD 2-Clause"
4-
TERMUX_PKG_LICENSE_FILE="DOC/License.txt, DOC/copying.txt"
4+
TERMUX_PKG_LICENSE_FILE="
5+
DOC/copying.txt
6+
DOC/License.txt
7+
DOC/unRarLicense.txt
8+
"
59
TERMUX_PKG_MAINTAINER="@termux"
610
TERMUX_PKG_VERSION="26.02"
7-
TERMUX_PKG_REVISION=1
11+
TERMUX_PKG_REVISION=2
812
TERMUX_PKG_SRCURL=(
913
"https://www.7-zip.org/a/7z${TERMUX_PKG_VERSION//./}-src.tar.xz"
1014
"https://www.7-zip.org/a/7z${TERMUX_PKG_VERSION//./}-linux-arm.tar.xz" # for manual, arm is smallest
@@ -13,6 +17,7 @@ TERMUX_PKG_SHA256=(
1317
cf967c98bca02a4b8b16375f441825a8e141362f14be1969bbec8e1ca0bff9dd
1418
81b7f04b3528852fac10f5becf9f15870a5da4cb94fbcb8a138197eb937468bf
1519
)
20+
TERMUX_PKG_BUILD_DEPENDS="dos2unix"
1621
TERMUX_PKG_AUTO_UPDATE=false
1722
TERMUX_PKG_BUILD_IN_SRC=true
1823
TERMUX_PKG_CONFLICTS="p7zip"
@@ -27,29 +32,49 @@ termux_extract_src_archive() {
2732
tar -xf "$file" -C "$TERMUX_PKG_SRCDIR"
2833
}
2934

30-
termux_step_pre_configure() {
31-
if [[ "$TERMUX_ARCH" == 'aarch64' ]]; then
32-
CFLAGS+=' -march=armv8.1-a+crypto'
33-
CXXFLAGS+=' -march=armv8.1-a+crypto'
35+
termux_step_post_get_source() {
36+
# convert CRLF to LF like in libpluto package
37+
if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then
38+
DOS2UNIX="$TERMUX_PKG_TMPDIR/dos2unix"
39+
(
40+
. "$TERMUX_SCRIPTDIR/packages/dos2unix/build.sh"
41+
. "$TERMUX_SCRIPTDIR/scripts/build/get_source/termux_unpack_src_archive.sh"
42+
TERMUX_PKG_SRCDIR="$DOS2UNIX" termux_step_get_source
43+
)
44+
pushd "$DOS2UNIX"
45+
make dos2unix
46+
popd # DOS2UNIX
47+
export PATH="$DOS2UNIX:$PATH"
3448
fi
49+
50+
find "$TERMUX_PKG_SRCDIR" -type f -print0 | xargs -0 dos2unix
51+
}
52+
53+
termux_step_pre_configure() {
3554
# Remove executable perms from docs
3655
chmod -x DOC/*.txt
3756
# Remove -Werror to make build succeed
3857
sed -i -e 's/-Werror//' CPP/7zip/7zip_gcc.mak
3958
}
4059

4160
termux_step_make() {
61+
local optim_args
62+
case "$TERMUX_ARCH" in
63+
x86_64) optim_args='-f ../../cmpl_clang_x64.mak' ;;
64+
i686) optim_args='-f ../../cmpl_clang_x86.mak' ;;
65+
arm) optim_args='-f ../../cmpl_clang.mak PLATFORM=arm USE_ASM=1' ;;
66+
aarch64) optim_args='-f ../../cmpl_clang_arm64.mak' ;;
67+
esac
68+
4269
# from https://git.alpinelinux.org/aports/tree/community/7zip/APKBUILD?id=b4601c88f608662c75422311b7ca3c26fab4b1f4
43-
# TODO: enable asm
44-
# DISABLE_RAR: RAR codec is non-free
4570
# -D_GNU_SOURCE: broken sched.h defines
4671
local bin
47-
for bin in Bundles/{Alone,Alone2} UI/Console; do
72+
for bin in Bundles/{Format7zF,Alone,Alone7z,Alone2,SFXCon} UI/Console; do
4873
make -C "CPP/7zip/$bin" \
4974
CC="$CC $CFLAGS $LDFLAGS -D_GNU_SOURCE" \
5075
CXX="$CXX $CXXFLAGS $LDFLAGS -D_GNU_SOURCE" \
51-
DISABLE_RAR=1 \
52-
--file ../../cmpl_clang.mak \
76+
O=b/c \
77+
$optim_args \
5378
--jobs "$TERMUX_PKG_MAKE_PROCESSES"
5479
done
5580
}
@@ -59,10 +84,17 @@ termux_step_make_install() {
5984
-t "$TERMUX_PREFIX"/bin \
6085
"$TERMUX_PKG_BUILDDIR"/CPP/7zip/UI/Console/b/c/7z \
6186
"$TERMUX_PKG_BUILDDIR"/CPP/7zip/Bundles/Alone/b/c/7za \
87+
"$TERMUX_PKG_BUILDDIR"/CPP/7zip/Bundles/Alone7z/b/c/7zr \
6288
"$TERMUX_PKG_BUILDDIR"/CPP/7zip/Bundles/Alone2/b/c/7zz
89+
install -Dm0755 \
90+
"$TERMUX_PKG_BUILDDIR"/CPP/7zip/Bundles/SFXCon/b/c/7zCon \
91+
"$TERMUX_PREFIX"/libexec/7zip/7zCon.sfx
92+
install -Dm0755 \
93+
-t "$TERMUX_PREFIX"/libexec/7zip \
94+
"$TERMUX_PKG_BUILDDIR"/CPP/7zip/Bundles/Format7zF/b/c/7z.so
6395
install -Dm0644 \
6496
-t "$TERMUX_PREFIX"/share/doc/"$TERMUX_PKG_NAME" \
65-
"$TERMUX_PKG_BUILDDIR"/DOC/{7zC,7zFormat,copying,License,lzma,Methods,readme,src-history}.txt
97+
"$TERMUX_PKG_BUILDDIR"/DOC/{7zC,7zFormat,lzma,Methods,readme,src-history}.txt
6698
tar -C "$TERMUX_PREFIX"/share/doc/"$TERMUX_PKG_NAME" \
6799
-xvf "$TERMUX_PKG_CACHEDIR/$(basename "${TERMUX_PKG_SRCURL[1]}")" MANUAL
68100
# Remove carriage returns from docs
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
The x86 ASM is not position-independent
2+
ld.lld: error: relocation R_386_32 cannot be used against symbol 'Reverse_Endian_Mask';
3+
recompile with -fPIC
4+
5+
--- a/CPP/7zip/var_clang_x64.mak
6+
+++ b/CPP/7zip/var_clang_x64.mak
7+
@@ -5,7 +5,7 @@ IS_X86=
8+
IS_ARM64=
9+
CROSS_COMPILE=
10+
MY_ARCH=
11+
-USE_ASM=1
12+
+USE_ASM=
13+
CC=$(CROSS_COMPILE)clang
14+
CXX=$(CROSS_COMPILE)clang++
15+
USE_CLANG=1
16+
--- a/CPP/7zip/var_clang_x86.mak
17+
+++ b/CPP/7zip/var_clang_x86.mak
18+
@@ -5,7 +5,7 @@ IS_X86=1
19+
IS_ARM64=
20+
CROSS_COMPILE=
21+
MY_ARCH=-m32
22+
-USE_ASM=1
23+
+USE_ASM=
24+
CC=$(CROSS_COMPILE)clang
25+
CXX=$(CROSS_COMPILE)clang++
26+
USE_CLANG=1
Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
--- a/CPP/7zip/UI/Console/Main.cpp
22
+++ b/CPP/7zip/UI/Console/Main.cpp
33
@@ -283,7 +283,7 @@ static void ShowProgInfo(CStdOutStream *so)
4-
{
5-
FString temp;
6-
NDir::MyGetTempPath(temp);
7-
- if (!temp.IsEqualTo(STRING_PATH_SEPARATOR "tmp" STRING_PATH_SEPARATOR))
8-
+ if (!temp.IsEqualTo("@TERMUX_PREFIX@/tmp/"))
9-
*so << " temp_path:" << temp;
10-
}
11-
}
4+
{
5+
FString temp;
6+
NDir::MyGetTempPath(temp);
7+
- if (!temp.IsEqualTo(STRING_PATH_SEPARATOR "tmp" STRING_PATH_SEPARATOR))
8+
+ if (!temp.IsEqualTo("@TERMUX_PREFIX@/tmp/"))
9+
*so << " temp_path:" << temp;
10+
}
11+
}
1212
--- a/CPP/Windows/FileDir.cpp
1313
+++ b/CPP/Windows/FileDir.cpp
1414
@@ -748,10 +748,10 @@ bool MyGetTempPath(FString &path)
15-
#else // !_WIN32
16-
17-
// FIXME: improve that code
18-
- path = STRING_PATH_SEPARATOR "tmp";
19-
+ path = "@TERMUX_PREFIX@/tmp";
20-
const char *s;
21-
if (NFind::DoesDirExist_FollowLink(path))
22-
- s = STRING_PATH_SEPARATOR "tmp" STRING_PATH_SEPARATOR;
23-
+ s = "@TERMUX_PREFIX@/tmp/";
24-
else
25-
s = "." STRING_PATH_SEPARATOR;
26-
path = s;
15+
#else // !_WIN32
16+
17+
// FIXME: improve that code
18+
- path = STRING_PATH_SEPARATOR "tmp";
19+
+ path = "@TERMUX_PREFIX@/tmp";
20+
const char *s;
21+
if (NFind::DoesDirExist_FollowLink(path))
22+
- s = STRING_PATH_SEPARATOR "tmp" STRING_PATH_SEPARATOR;
23+
+ s = "@TERMUX_PREFIX@/tmp/";
24+
else
25+
s = "." STRING_PATH_SEPARATOR;
26+
path = s;
27+
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
28+
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
29+
@@ -1894,8 +1894,7 @@ FString GetModuleDirPrefix()
30+
FString s;
31+
32+
s = fas2fs(g_ModuleDirPrefix);
33+
- if (s.IsEmpty())
34+
- s = FTEXT(".") FSTRING_PATH_SEPARATOR;
35+
+ s = FTEXT("@TERMUX_PREFIX@/libexec/7zip") FSTRING_PATH_SEPARATOR;
36+
return s;
37+
/*
38+
setenv("_7ZIP_HOME_DIR", "/test/", 0);
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
--- a/CPP/Windows/TimeUtils.cpp
22
+++ b/CPP/Windows/TimeUtils.cpp
33
@@ -260,7 +260,7 @@
4-
Cygwin 2.9, mingw, MSVC 14, Android 9.0.
5-
Android NDK defines TIME_UTC but doesn't have the timespec_get().
6-
*/
7-
-#if defined(TIME_UTC) && !defined(__ANDROID__)
8-
+#if defined(TIME_UTC) && (!defined __ANDROID_API__ || __ANDROID_API__ >= 29)
9-
#define ZIP7_USE_timespec_get
10-
// #pragma message("ZIP7_USE_timespec_get")
11-
#elif defined(CLOCK_REALTIME)
4+
Cygwin 2.9, mingw, MSVC 14, Android 9.0.
5+
Android NDK defines TIME_UTC but doesn't have the timespec_get().
6+
*/
7+
-#if defined(TIME_UTC) && !defined(__ANDROID__)
8+
+#if defined(TIME_UTC) && (!defined __ANDROID_API__ || __ANDROID_API__ >= 29)
9+
#define ZIP7_USE_timespec_get
10+
// #pragma message("ZIP7_USE_timespec_get")
11+
#elif defined(CLOCK_REALTIME)

0 commit comments

Comments
 (0)