From: David Bauer Date: Mon, 16 Jan 2023 00:30:29 +0000 (+0100) Subject: dosfstools: switch to AC_CHECK_LIB X-Git-Tag: v23.05.0-rc1~1242 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=9300a20dcce2217b121bd2020cc1a4ea41fa4475;p=openwrt%2Fstaging%2Fhauke.git dosfstools: switch to AC_CHECK_LIB This fixes spurious build-errors on OpenWrt, where the AM_ICONV macro is undefined while invoking autoconfig. Later in the build, the ICONV LDOPTIONS are set to @LIBICONV@, failing the build. Signed-off-by: David Bauer --- diff --git a/tools/dosfstools/patches/100-source-date-epoch.patch b/tools/dosfstools/patches/100-source-date-epoch.patch new file mode 100644 index 0000000000..c758caa4c1 --- /dev/null +++ b/tools/dosfstools/patches/100-source-date-epoch.patch @@ -0,0 +1,150 @@ +From 8da7bc93315cb0c32ad868f17808468b81fa76ec Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= +Date: Wed, 5 Dec 2018 19:52:51 +0100 +Subject: [PATCH] Honor the SOURCE_DATE_EPOCH variable +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Implement the SOURCE_DATE_EPOCH specification[1] for reproducible +builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the +current time. + +[1] https://reproducible-builds.org/specs/source-date-epoch/ + +Signed-off-by: Bjørn Forsman +--- + src/boot.c | 23 +++++++++++++++++++++-- + src/common.c | 18 ++++++++++++++++-- + src/mkfs.fat.c | 19 ++++++++++++++++--- + 3 files changed, 53 insertions(+), 7 deletions(-) + +--- a/src/boot.c ++++ b/src/boot.c +@@ -33,6 +33,8 @@ + #include + #include + #include ++#include ++#include + + #include "common.h" + #include "fsck.fat.h" +@@ -672,6 +674,7 @@ void write_volume_label(DOS_FS * fs, cha + { + time_t now; + struct tm *mtime; ++ char *source_date_epoch = NULL; + off_t offset; + int created; + DIR_ENT de; +@@ -687,8 +690,24 @@ void write_volume_label(DOS_FS * fs, cha + if (de.name[0] == 0xe5) + de.name[0] = 0x05; + +- now = time(NULL); +- mtime = (now != (time_t)-1) ? localtime(&now) : NULL; ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) { ++ char *tmp = NULL; ++ long long conversion = 0; ++ errno = 0; ++ conversion = strtoll(source_date_epoch, &tmp, 10); ++ now = conversion; ++ if (!isdigit((unsigned char)*source_date_epoch) || *tmp != '\0' ++ || errno != 0 || (long long)now != conversion) { ++ die("SOURCE_DATE_EPOCH is too big or contains non-digits: \"%s\"", ++ source_date_epoch); ++ } ++ mtime = gmtime(&now); ++ } else { ++ now = time(NULL); ++ mtime = (now != (time_t)-1) ? localtime(&now) : NULL; ++ } ++ + if (mtime && mtime->tm_year >= 80 && mtime->tm_year <= 207) { + de.time = htole16((unsigned short)((mtime->tm_sec >> 1) + + (mtime->tm_min << 5) + +--- a/src/common.c ++++ b/src/common.c +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -298,8 +299,21 @@ void check_atari(void) + uint32_t generate_volume_id(void) + { + struct timeval now; ++ char *source_date_epoch = NULL; + +- if (gettimeofday(&now, NULL) != 0 || now.tv_sec == (time_t)-1 || now.tv_sec < 0) { ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) { ++ char *tmp = NULL; ++ long long conversion = 0; ++ errno = 0; ++ conversion = strtoll(source_date_epoch, &tmp, 10); ++ if (!isdigit((unsigned char)*source_date_epoch) || *tmp != '\0' ++ || errno != 0) { ++ die("SOURCE_DATE_EPOCH is too big or contains non-digits: \"%s\"", ++ source_date_epoch); ++ } ++ return (uint32_t)conversion; ++ } else if (gettimeofday(&now, NULL) != 0 || now.tv_sec == (time_t)-1 || now.tv_sec < 0) { + srand(getpid()); + /* rand() returns int from [0,RAND_MAX], therefore only 31 bits */ + return (((uint32_t)(rand() & 0xFFFF)) << 16) | ((uint32_t)(rand() & 0xFFFF)); +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -1074,7 +1074,7 @@ static void setup_tables(void) + } + + /* If is not available then generate random 32 bit disk signature */ +- if (invariant) ++ if (invariant || getenv("SOURCE_DATE_EPOCH")) + disk_sig = volume_id; + else if (!disk_sig) + disk_sig = generate_volume_id(); +@@ -1287,7 +1287,7 @@ static void setup_tables(void) + de->name[0] = 0x05; + de->attr = ATTR_VOLUME; + if (create_time != (time_t)-1) { +- if (!invariant) ++ if (!invariant && !getenv("SOURCE_DATE_EPOCH")) + ctime = localtime(&create_time); + else + ctime = gmtime(&create_time); +@@ -1477,6 +1477,7 @@ int main(int argc, char **argv) + int blocks_specified = 0; + struct timeval create_timeval; + long long conversion; ++ char *source_date_epoch = NULL; + + enum {OPT_HELP=1000, OPT_INVARIANT, OPT_MBR, OPT_VARIANT, OPT_CODEPAGE, OPT_OFFSET}; + const struct option long_options[] = { +@@ -1497,8 +1498,20 @@ int main(int argc, char **argv) + program_name = p + 1; + } + +- if (gettimeofday(&create_timeval, NULL) == 0 && create_timeval.tv_sec != (time_t)-1) ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) { ++ errno = 0; ++ conversion = strtoll(source_date_epoch, &tmp, 10); ++ create_time = conversion; ++ if (!isdigit((unsigned char)*source_date_epoch) || *tmp != '\0' ++ || errno != 0 || (long long)create_time != conversion) { ++ die("SOURCE_DATE_EPOCH is too big or contains non-digits: \"%s\"", ++ source_date_epoch); ++ } ++ } else if (gettimeofday(&create_timeval, NULL) == 0 && create_timeval.tv_sec != (time_t)-1) { + create_time = create_timeval.tv_sec; ++ } ++ + volume_id = generate_volume_id(); + check_atari(); + diff --git a/tools/dosfstools/patches/101-config-switch-to-AC_CHECK_LIB.patch b/tools/dosfstools/patches/101-config-switch-to-AC_CHECK_LIB.patch new file mode 100644 index 0000000000..ba2d00bf84 --- /dev/null +++ b/tools/dosfstools/patches/101-config-switch-to-AC_CHECK_LIB.patch @@ -0,0 +1,28 @@ +From e7671c2a3be03d790cbc225cd3e784b5434fb5da Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Mon, 16 Jan 2023 01:29:22 +0100 +Subject: [PATCH] config: switch to AC_CHECK_LIB + +This fixes spurious build-errors on OpenWrt, where the AM_ICONV macro +is undefined while invoking autoconfig. Later in the build, the ICONV +LDOPTIONS are set to @LIBICONV@, failing the build. + +Signed-off-by: David Bauer +--- + configure.ac | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +--- a/configure.ac ++++ b/configure.ac +@@ -70,10 +70,7 @@ AC_CHECK_DECLS([getmntent], [], [], [[#i + AC_CHECK_DECLS([getmntinfo], [], [], [[#include ]]) + + # optional iconv support +-AC_ARG_WITH([iconv], AS_HELP_STRING([--without-iconv], [build without iconv support])) +-if test "x$with_iconv" != "xno"; then +- AM_ICONV +-fi ++AC_CHECK_LIB(iconv, iconv_open) + + # xxd (distributed with vim) is used in the testsuite + AC_CHECK_PROG([XXD_FOUND], [xxd], [yes]) diff --git a/tools/dosfstools/patches/source-date-epoch.patch b/tools/dosfstools/patches/source-date-epoch.patch deleted file mode 100644 index c758caa4c1..0000000000 --- a/tools/dosfstools/patches/source-date-epoch.patch +++ /dev/null @@ -1,150 +0,0 @@ -From 8da7bc93315cb0c32ad868f17808468b81fa76ec Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= -Date: Wed, 5 Dec 2018 19:52:51 +0100 -Subject: [PATCH] Honor the SOURCE_DATE_EPOCH variable -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Implement the SOURCE_DATE_EPOCH specification[1] for reproducible -builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the -current time. - -[1] https://reproducible-builds.org/specs/source-date-epoch/ - -Signed-off-by: Bjørn Forsman ---- - src/boot.c | 23 +++++++++++++++++++++-- - src/common.c | 18 ++++++++++++++++-- - src/mkfs.fat.c | 19 ++++++++++++++++--- - 3 files changed, 53 insertions(+), 7 deletions(-) - ---- a/src/boot.c -+++ b/src/boot.c -@@ -33,6 +33,8 @@ - #include - #include - #include -+#include -+#include - - #include "common.h" - #include "fsck.fat.h" -@@ -672,6 +674,7 @@ void write_volume_label(DOS_FS * fs, cha - { - time_t now; - struct tm *mtime; -+ char *source_date_epoch = NULL; - off_t offset; - int created; - DIR_ENT de; -@@ -687,8 +690,24 @@ void write_volume_label(DOS_FS * fs, cha - if (de.name[0] == 0xe5) - de.name[0] = 0x05; - -- now = time(NULL); -- mtime = (now != (time_t)-1) ? localtime(&now) : NULL; -+ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); -+ if (source_date_epoch) { -+ char *tmp = NULL; -+ long long conversion = 0; -+ errno = 0; -+ conversion = strtoll(source_date_epoch, &tmp, 10); -+ now = conversion; -+ if (!isdigit((unsigned char)*source_date_epoch) || *tmp != '\0' -+ || errno != 0 || (long long)now != conversion) { -+ die("SOURCE_DATE_EPOCH is too big or contains non-digits: \"%s\"", -+ source_date_epoch); -+ } -+ mtime = gmtime(&now); -+ } else { -+ now = time(NULL); -+ mtime = (now != (time_t)-1) ? localtime(&now) : NULL; -+ } -+ - if (mtime && mtime->tm_year >= 80 && mtime->tm_year <= 207) { - de.time = htole16((unsigned short)((mtime->tm_sec >> 1) + - (mtime->tm_min << 5) + ---- a/src/common.c -+++ b/src/common.c -@@ -30,6 +30,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -298,8 +299,21 @@ void check_atari(void) - uint32_t generate_volume_id(void) - { - struct timeval now; -+ char *source_date_epoch = NULL; - -- if (gettimeofday(&now, NULL) != 0 || now.tv_sec == (time_t)-1 || now.tv_sec < 0) { -+ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); -+ if (source_date_epoch) { -+ char *tmp = NULL; -+ long long conversion = 0; -+ errno = 0; -+ conversion = strtoll(source_date_epoch, &tmp, 10); -+ if (!isdigit((unsigned char)*source_date_epoch) || *tmp != '\0' -+ || errno != 0) { -+ die("SOURCE_DATE_EPOCH is too big or contains non-digits: \"%s\"", -+ source_date_epoch); -+ } -+ return (uint32_t)conversion; -+ } else if (gettimeofday(&now, NULL) != 0 || now.tv_sec == (time_t)-1 || now.tv_sec < 0) { - srand(getpid()); - /* rand() returns int from [0,RAND_MAX], therefore only 31 bits */ - return (((uint32_t)(rand() & 0xFFFF)) << 16) | ((uint32_t)(rand() & 0xFFFF)); ---- a/src/mkfs.fat.c -+++ b/src/mkfs.fat.c -@@ -1074,7 +1074,7 @@ static void setup_tables(void) - } - - /* If is not available then generate random 32 bit disk signature */ -- if (invariant) -+ if (invariant || getenv("SOURCE_DATE_EPOCH")) - disk_sig = volume_id; - else if (!disk_sig) - disk_sig = generate_volume_id(); -@@ -1287,7 +1287,7 @@ static void setup_tables(void) - de->name[0] = 0x05; - de->attr = ATTR_VOLUME; - if (create_time != (time_t)-1) { -- if (!invariant) -+ if (!invariant && !getenv("SOURCE_DATE_EPOCH")) - ctime = localtime(&create_time); - else - ctime = gmtime(&create_time); -@@ -1477,6 +1477,7 @@ int main(int argc, char **argv) - int blocks_specified = 0; - struct timeval create_timeval; - long long conversion; -+ char *source_date_epoch = NULL; - - enum {OPT_HELP=1000, OPT_INVARIANT, OPT_MBR, OPT_VARIANT, OPT_CODEPAGE, OPT_OFFSET}; - const struct option long_options[] = { -@@ -1497,8 +1498,20 @@ int main(int argc, char **argv) - program_name = p + 1; - } - -- if (gettimeofday(&create_timeval, NULL) == 0 && create_timeval.tv_sec != (time_t)-1) -+ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); -+ if (source_date_epoch) { -+ errno = 0; -+ conversion = strtoll(source_date_epoch, &tmp, 10); -+ create_time = conversion; -+ if (!isdigit((unsigned char)*source_date_epoch) || *tmp != '\0' -+ || errno != 0 || (long long)create_time != conversion) { -+ die("SOURCE_DATE_EPOCH is too big or contains non-digits: \"%s\"", -+ source_date_epoch); -+ } -+ } else if (gettimeofday(&create_timeval, NULL) == 0 && create_timeval.tv_sec != (time_t)-1) { - create_time = create_timeval.tv_sec; -+ } -+ - volume_id = generate_volume_id(); - check_atari(); -