Skip to content

Commit

Permalink
Locale fix and upgrade
Browse files Browse the repository at this point in the history
* #2
* libarchive 3.5.2
* lzma 5.2.5
  • Loading branch information
green-green-avk committed Nov 7, 2021
1 parent bc22118 commit b654f95
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 green-green-avk
Copyright (c) 2021 green-green-avk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions android-min.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
#define HAVE_SIGACTION 1
#define HAVE_SIGNAL_H 1
#define HAVE_STATFS 1
#define HAVE_STRUCT_STATFS 1
#define HAVE_STDARG_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
Expand Down
42 changes: 40 additions & 2 deletions android.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
--- libarchive/archive_string.c
+++ libarchive/archive_string.c
@@ -59,6 +59,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_string.c 201095 2009-12-28 02:33
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
+#endif
+#if defined(_WIN32) && !defined(__CYGWIN__) || defined(HAVE_LOCALE_H)
#include <locale.h>
#endif

@@ -429,9 +431,21 @@ default_iconv_charset(const char *charset) {
return locale_charset();
#elif HAVE_NL_LANGINFO
return nl_langinfo(CODESET);
+#else
+ // No iconv, etc... :(
+#if defined(HAVE_SETLOCALE)
+ // It is required just to understand what can we actually convert...
+ const char *const locale = setlocale(LC_CTYPE, NULL);
+ const char *const dot = strchr(locale, '.');
+ if (dot != NULL)
+ return dot + 1;
+#endif
+#if defined(__ANDROID__)
+ return "UTF-8"; // It looks a bit more sane here...
#else
return "";
#endif
+#endif
}

#if defined(_WIN32) && !defined(__CYGWIN__)
--- libarchive/archive_write_disk_posix.c
+++ libarchive/archive_write_disk_posix.c
@@ -2206,8 +2206,8 @@ restore_entry(struct archive_write_disk *a)
Expand Down Expand Up @@ -27,12 +60,17 @@
}
/*
* TODO: consider using the cleaned-up path as the link
@@ -2284,7 +2284,34 @@ create_filesystem_object(struct archive_write_disk *a)
@@ -2284,12 +2284,39 @@ create_filesystem_object(struct archive_write_disk *a)
*/
if (a->flags & ARCHIVE_EXTRACT_SAFE_WRITES)
unlink(a->name);
+#ifndef IS_ANDROID_NOROOT
#ifdef HAVE_LINKAT
r = linkat(AT_FDCWD, linkname, AT_FDCWD, a->name,
0) ? errno : 0;
#else
r = link(linkname, a->name) ? errno : 0;
#endif
+ if (r != 0)
+ archive_set_error(&a->archive, ARCHIVE_FAILED, "Can't create hard link '%s', errno = %d",
+ a->name, r);
Expand Down Expand Up @@ -62,7 +100,7 @@
/*
* New cpio and pax formats allow hardlink entries
* to carry data, so we may have to open the file
@@ -2329,7 +2356,11 @@ create_filesystem_object(struct archive_write_disk *a)
@@ -2334,7 +2361,11 @@ create_filesystem_object(struct archive_write_disk *a)
*/
if (a->flags & ARCHIVE_EXTRACT_SAFE_WRITES)
unlink(a->name);
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
[ "$1" = '-u' ] && UPDATE=1

BUILD_DIR='build'
VER='3.5.1'
VER='3.5.2'
NAME="libarchive-$VER"

export PATH="$HOME/Android/Sdk/ndk/21.3.6528147:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion lzma/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

BUILD_DIR='build'
VER='5.2.4'
VER='5.2.5'
NAME="xz-$VER"

mkdir -p "$BUILD_DIR"
Expand Down
3 changes: 3 additions & 0 deletions minitar/minitar.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <locale.h>

/*
* NO_CREATE implies NO_XZ_CREATE and implies NO_BZIP2_CREATE and NO_GZIP_CREATE and NO_COMPRESS_CREATE.
Expand Down Expand Up @@ -153,6 +154,8 @@ static int verbose = 0;
int
main(int argc, const char **argv)
{
setlocale(LC_ALL, "");

const char *filename = NULL;
int compress, flags, mode, opt;

Expand Down
Binary file modified prebuilt/arm64-v8a/minitar
Binary file not shown.
Binary file modified prebuilt/armeabi-v7a/minitar
Binary file not shown.
Binary file modified prebuilt/x86/minitar
Binary file not shown.
Binary file modified prebuilt/x86_64/minitar
Binary file not shown.

0 comments on commit b654f95

Please sign in to comment.