From 1334840179ac9d6ec2a50b0e6c1e2348b95c1d2e Mon Sep 17 00:00:00 2001 From: Daniel Engberg Date: Mon, 14 Jan 2019 01:01:15 +0100 Subject: [PATCH] multimedia/minidlna: Update to latest commit Update minidlna to latest commit Cherry pick commits from https://github.com/xavery/minidlna Signed-off-by: Daniel Engberg --- multimedia/minidlna/Makefile | 11 +- ...es.patch => 001-dont-build-po-files.patch} | 2 +- ...tances_of_magic_container_s_as_const.patch | 125 ++++++++++++ ...ntainer_definitions_into_a_structure.patch | 118 +++++++++++ .../004-reduce_duplication_in_sql_c.patch | 192 ++++++++++++++++++ 5 files changed, 442 insertions(+), 6 deletions(-) rename multimedia/minidlna/patches/{002-dont-build-po-files.patch => 001-dont-build-po-files.patch} (90%) create mode 100644 multimedia/minidlna/patches/002-mark_all_instances_of_magic_container_s_as_const.patch create mode 100644 multimedia/minidlna/patches/003-wrap_container_definitions_into_a_structure.patch create mode 100644 multimedia/minidlna/patches/004-reduce_duplication_in_sql_c.patch diff --git a/multimedia/minidlna/Makefile b/multimedia/minidlna/Makefile index a74ad2e43..f11375bb4 100644 --- a/multimedia/minidlna/Makefile +++ b/multimedia/minidlna/Makefile @@ -8,12 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=minidlna -PKG_VERSION:=1.2.1 -PKG_RELEASE:=4 +PKG_RELEASE:=1 -PKG_SOURCE_URL:=@SF/minidlna -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_HASH:=67388ba23ab0c7033557a32084804f796aa2a796db7bb2b770fb76ac2a742eec +PKG_SOURCE_URL=git://minidlna.git.sourceforge.net/gitroot/minidlna/minidlna +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2018-04-10 +PKG_SOURCE_VERSION:=799e6cf505ec470b2bf0ae4118143380aa16b837 +PKG_MIRROR_HASH:=67cc817e671de99e5a3f5ed237f89e22470f1de94819bcaba86c0ba821104af5 PKG_LICENSE:=GPL-2.0 BSD-3-Clause PKG_LICENSE_FILES:=COPYING LICENCE.miniupnpd diff --git a/multimedia/minidlna/patches/002-dont-build-po-files.patch b/multimedia/minidlna/patches/001-dont-build-po-files.patch similarity index 90% rename from multimedia/minidlna/patches/002-dont-build-po-files.patch rename to multimedia/minidlna/patches/001-dont-build-po-files.patch index 38623246e..7d9f6b637 100644 --- a/multimedia/minidlna/patches/002-dont-build-po-files.patch +++ b/multimedia/minidlna/patches/001-dont-build-po-files.patch @@ -11,7 +11,7 @@ check_PROGRAMS = testupnpdescgen --- a/configure.ac +++ b/configure.ac -@@ -644,6 +644,8 @@ case "$target_os" in +@@ -647,6 +647,8 @@ case "$target_os" in esac diff --git a/multimedia/minidlna/patches/002-mark_all_instances_of_magic_container_s_as_const.patch b/multimedia/minidlna/patches/002-mark_all_instances_of_magic_container_s_as_const.patch new file mode 100644 index 000000000..cb1f2febc --- /dev/null +++ b/multimedia/minidlna/patches/002-mark_all_instances_of_magic_container_s_as_const.patch @@ -0,0 +1,125 @@ +From d297624e533d6d4274c750e3769749c3d7f121c8 Mon Sep 17 00:00:00 2001 +From: Daniel Kamil Kozar +Date: Sat, 15 Dec 2018 16:34:30 +0100 +Subject: [PATCH] Mark all instances of magic_container_s as const + +--- + containers.c | 38 +++++++++++++++++++------------------- + containers.h | 6 +++--- + scanner.c | 2 +- + upnpsoap.c | 6 +++--- + 4 files changed, 26 insertions(+), 26 deletions(-) + +--- a/containers.c ++++ b/containers.c +@@ -25,23 +25,23 @@ + + #define NINETY_DAYS "7776000" + +-const char *music_id = MUSIC_ID; +-const char *music_all_id = MUSIC_ALL_ID; +-const char *music_genre_id = MUSIC_GENRE_ID; +-const char *music_artist_id = MUSIC_ARTIST_ID; +-const char *music_album_id = MUSIC_ALBUM_ID; +-const char *music_plist_id = MUSIC_PLIST_ID; +-const char *music_dir_id = MUSIC_DIR_ID; +-const char *video_id = VIDEO_ID; +-const char *video_all_id = VIDEO_ALL_ID; +-const char *video_dir_id = VIDEO_DIR_ID; +-const char *image_id = IMAGE_ID; +-const char *image_all_id = IMAGE_ALL_ID; +-const char *image_date_id = IMAGE_DATE_ID; +-const char *image_camera_id = IMAGE_CAMERA_ID; +-const char *image_dir_id = IMAGE_DIR_ID; ++static const char *music_id = MUSIC_ID; ++static const char *music_all_id = MUSIC_ALL_ID; ++static const char *music_genre_id = MUSIC_GENRE_ID; ++static const char *music_artist_id = MUSIC_ARTIST_ID; ++static const char *music_album_id = MUSIC_ALBUM_ID; ++static const char *music_plist_id = MUSIC_PLIST_ID; ++static const char *music_dir_id = MUSIC_DIR_ID; ++static const char *video_id = VIDEO_ID; ++static const char *video_all_id = VIDEO_ALL_ID; ++static const char *video_dir_id = VIDEO_DIR_ID; ++static const char *image_id = IMAGE_ID; ++static const char *image_all_id = IMAGE_ALL_ID; ++static const char *image_date_id = IMAGE_DATE_ID; ++static const char *image_camera_id = IMAGE_CAMERA_ID; ++static const char *image_dir_id = IMAGE_DIR_ID; + +-struct magic_container_s magic_containers[] = ++const struct magic_container_s magic_containers[] = + { + /* Alternate root container */ + { NULL, +@@ -124,7 +124,7 @@ struct magic_container_s magic_container + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0 } + }; + +-struct magic_container_s * ++const struct magic_container_s * + in_magic_container(const char *id, int flags, const char **real_id) + { + size_t len; +@@ -154,7 +154,7 @@ in_magic_container(const char *id, int f + return NULL; + } + +-struct magic_container_s * ++const struct magic_container_s * + check_magic_container(const char *id, int flags) + { + int i; +--- a/containers.h ++++ b/containers.h +@@ -30,7 +30,7 @@ struct magic_container_s { + int required_flags; + }; + +-extern struct magic_container_s magic_containers[]; ++extern const struct magic_container_s magic_containers[]; + +-struct magic_container_s *in_magic_container(const char *id, int flags, const char **real_id); +-struct magic_container_s *check_magic_container(const char *id, int flags); ++const struct magic_container_s *in_magic_container(const char *id, int flags, const char **real_id); ++const struct magic_container_s *check_magic_container(const char *id, int flags); +--- a/scanner.c ++++ b/scanner.c +@@ -587,7 +587,7 @@ CreateDatabase(void) + } + for( i=0; magic_containers[i].objectid_match; i++ ) + { +- struct magic_container_s *magic = &magic_containers[i]; ++ const struct magic_container_s *magic = &magic_containers[i]; + if (!magic->name) + continue; + if( sql_get_int_field(db, "SELECT 1 from OBJECTS where OBJECT_ID = '%s'", magic->objectid_match) == 0 ) +--- a/upnpsoap.c ++++ b/upnpsoap.c +@@ -800,7 +800,7 @@ add_res(char *size, char *duration, char + } + + static int +-get_child_count(const char *object, struct magic_container_s *magic) ++get_child_count(const char *object, const struct magic_container_s *magic) + { + int ret; + +@@ -1292,7 +1292,7 @@ BrowseContentDirectory(struct upnphttp * + "" + "<DIDL-Lite" + CONTENT_DIRECTORY_SCHEMAS; +- struct magic_container_s *magic; ++ const struct magic_container_s *magic; + char *zErrMsg = NULL; + char *sql, *ptr; + struct Response args; +@@ -1807,7 +1807,7 @@ SearchContentDirectory(struct upnphttp * + "" + "<DIDL-Lite" + CONTENT_DIRECTORY_SCHEMAS; +- struct magic_container_s *magic; ++ const struct magic_container_s *magic; + char *zErrMsg = NULL; + char *sql, *ptr; + struct Response args; diff --git a/multimedia/minidlna/patches/003-wrap_container_definitions_into_a_structure.patch b/multimedia/minidlna/patches/003-wrap_container_definitions_into_a_structure.patch new file mode 100644 index 000000000..a4fb39bfb --- /dev/null +++ b/multimedia/minidlna/patches/003-wrap_container_definitions_into_a_structure.patch @@ -0,0 +1,118 @@ +From e0065b8343bc963a89556449e00f1d20086cc1f1 Mon Sep 17 00:00:00 2001 +From: Daniel Kamil Kozar +Date: Sat, 15 Dec 2018 16:26:37 +0100 +Subject: [PATCH] Wrap container definitions into a structure + +--- + containers.c | 25 +++++++++++++++++++++++++ + containers.h | 8 ++++++++ + scanner.c | 33 ++++++--------------------------- + 3 files changed, 39 insertions(+), 27 deletions(-) + +--- a/containers.c ++++ b/containers.c +@@ -23,6 +23,31 @@ + #include "containers.h" + #include "log.h" + ++const struct container_s containers[] = { ++ { "0","-1", "root" }, ++ { MUSIC_ID, "0", "Music" }, ++ { MUSIC_ALL_ID, MUSIC_ID, "All Music" }, ++ { MUSIC_GENRE_ID, MUSIC_ID, "Genre" }, ++ { MUSIC_ARTIST_ID, MUSIC_ID, "Artist" }, ++ { MUSIC_ALBUM_ID, MUSIC_ID, "Album" }, ++ { MUSIC_DIR_ID, MUSIC_ID, "Folders" }, ++ { MUSIC_PLIST_ID, MUSIC_ID, "Playlists" }, ++ ++ { VIDEO_ID, "0", "Video" }, ++ { VIDEO_ALL_ID, VIDEO_ID, "All Video" }, ++ { VIDEO_DIR_ID, VIDEO_ID, "Folders" }, ++ ++ { IMAGE_ID, "0", "Pictures" }, ++ { IMAGE_ALL_ID, IMAGE_ID, "All Pictures" }, ++ { IMAGE_DATE_ID, IMAGE_ID, "Date Taken" }, ++ { IMAGE_CAMERA_ID, IMAGE_ID, "Camera" }, ++ { IMAGE_DIR_ID, IMAGE_ID, "Folders" }, ++ ++ { BROWSEDIR_ID, "0", "Browse Folders" }, ++ ++ { 0, 0, 0 } ++}; ++ + #define NINETY_DAYS "7776000" + + static const char *music_id = MUSIC_ID; +--- a/containers.h ++++ b/containers.h +@@ -16,6 +16,14 @@ + * along with MiniDLNA. If not, see . + */ + ++struct container_s { ++ const char *object_id; ++ const char *parent_id; ++ const char *name; ++}; ++ ++extern const struct container_s containers[]; ++ + struct magic_container_s { + const char *name; + const char *objectid_match; +--- a/scanner.c ++++ b/scanner.c +@@ -529,30 +529,7 @@ insert_file(const char *name, const char + int + CreateDatabase(void) + { +- int ret, i; +- const char *containers[] = { "0","-1", "root", +- MUSIC_ID, "0", _("Music"), +- MUSIC_ALL_ID, MUSIC_ID, _("All Music"), +- MUSIC_GENRE_ID, MUSIC_ID, _("Genre"), +- MUSIC_ARTIST_ID, MUSIC_ID, _("Artist"), +- MUSIC_ALBUM_ID, MUSIC_ID, _("Album"), +- MUSIC_DIR_ID, MUSIC_ID, _("Folders"), +- MUSIC_PLIST_ID, MUSIC_ID, _("Playlists"), +- +- VIDEO_ID, "0", _("Video"), +- VIDEO_ALL_ID, VIDEO_ID, _("All Video"), +- VIDEO_DIR_ID, VIDEO_ID, _("Folders"), +- +- IMAGE_ID, "0", _("Pictures"), +- IMAGE_ALL_ID, IMAGE_ID, _("All Pictures"), +- IMAGE_DATE_ID, IMAGE_ID, _("Date Taken"), +- IMAGE_CAMERA_ID, IMAGE_ID, _("Camera"), +- IMAGE_DIR_ID, IMAGE_ID, _("Folders"), +- +- BROWSEDIR_ID, "0", _("Browse Folders"), +- 0 }; +- +- ret = sql_exec(db, create_objectTable_sqlite); ++ int ret = sql_exec(db, create_objectTable_sqlite); + if( ret != SQLITE_OK ) + goto sql_failed; + ret = sql_exec(db, create_detailTable_sqlite); +@@ -576,16 +553,18 @@ CreateDatabase(void) + ret = sql_exec(db, "INSERT into SETTINGS values ('UPDATE_ID', '0')"); + if( ret != SQLITE_OK ) + goto sql_failed; +- for( i=0; containers[i]; i=i+3 ) ++ for( int i=0; containers[i].name; ++i ) + { ++ const struct container_s *c = &containers[i]; ++ const char *name = _(c->name); + ret = sql_exec(db, "INSERT into OBJECTS (OBJECT_ID, PARENT_ID, DETAIL_ID, CLASS, NAME)" + " values " + "('%s', '%s', %lld, 'container.storageFolder', '%q')", +- containers[i], containers[i+1], GetFolderMetadata(containers[i+2], NULL, NULL, NULL, 0), containers[i+2]); ++ c->object_id, c->parent_id, GetFolderMetadata(name, NULL, NULL, NULL, 0), name); + if( ret != SQLITE_OK ) + goto sql_failed; + } +- for( i=0; magic_containers[i].objectid_match; i++ ) ++ for( int i=0; magic_containers[i].objectid_match; i++ ) + { + const struct magic_container_s *magic = &magic_containers[i]; + if (!magic->name) diff --git a/multimedia/minidlna/patches/004-reduce_duplication_in_sql_c.patch b/multimedia/minidlna/patches/004-reduce_duplication_in_sql_c.patch new file mode 100644 index 000000000..c23721732 --- /dev/null +++ b/multimedia/minidlna/patches/004-reduce_duplication_in_sql_c.patch @@ -0,0 +1,192 @@ +From be9de8b2e0864b46498496af9ffdc31c0e7b764a Mon Sep 17 00:00:00 2001 +From: Daniel Kamil Kozar +Date: Sun, 16 Dec 2018 14:21:58 +0100 +Subject: [PATCH] Reduce duplication in sql.c + +--- + sql.c | 166 ++++++++++++++++++++-------------------------------------- + 1 file changed, 58 insertions(+), 108 deletions(-) + +--- a/sql.c ++++ b/sql.c +@@ -65,122 +65,72 @@ sql_get_table(sqlite3 *db, const char *s + return ret; + } + ++#define sql_get_field(type, column_get_fn) \ ++ va_list ap;\ ++ int counter, result;\ ++ char *sql;\ ++ type ret;\ ++ sqlite3_stmt *stmt;\ ++ \ ++ va_start(ap, fmt);\ ++ sql = sqlite3_vmprintf(fmt, ap);\ ++ va_end(ap);\ ++\ ++ /*DPRINTF(E_DEBUG, L_DB_SQL, "sql: %s\n", sql); */ \ ++\ ++ switch (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL))\ ++ {\ ++ case SQLITE_OK:\ ++ break;\ ++ default:\ ++ DPRINTF(E_ERROR, L_DB_SQL, "prepare failed: %s\n%s\n", sqlite3_errmsg(db), sql);\ ++ sqlite3_free(sql);\ ++ return -1;\ ++ }\ ++\ ++ for (counter = 0;\ ++ ((result = sqlite3_step(stmt)) == SQLITE_BUSY || result == SQLITE_LOCKED) && counter < 2;\ ++ counter++) {\ ++ /* While SQLITE_BUSY has a built in timeout,\ ++ * SQLITE_LOCKED does not, so sleep */\ ++ if (result == SQLITE_LOCKED)\ ++ sleep(1);\ ++ }\ ++\ ++ switch (result)\ ++ {\ ++ case SQLITE_DONE:\ ++ /* no rows returned */\ ++ ret = 0;\ ++ break;\ ++ case SQLITE_ROW:\ ++ if (sqlite3_column_type(stmt, 0) == SQLITE_NULL)\ ++ {\ ++ ret = 0;\ ++ break;\ ++ }\ ++ ret = column_get_fn(stmt, 0);\ ++ break;\ ++ default:\ ++ DPRINTF(E_WARN, L_DB_SQL, "%s: step failed: %s\n%s\n", __func__, sqlite3_errmsg(db), sql);\ ++ ret = -1;\ ++ break;\ ++ }\ ++ sqlite3_free(sql);\ ++ sqlite3_finalize(stmt);\ ++\ ++ return ret; ++ + int + sql_get_int_field(sqlite3 *db, const char *fmt, ...) + { +- va_list ap; +- int counter, result; +- char *sql; +- int ret; +- sqlite3_stmt *stmt; +- +- va_start(ap, fmt); +- sql = sqlite3_vmprintf(fmt, ap); +- va_end(ap); +- +- //DPRINTF(E_DEBUG, L_DB_SQL, "sql: %s\n", sql); +- +- switch (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL)) +- { +- case SQLITE_OK: +- break; +- default: +- DPRINTF(E_ERROR, L_DB_SQL, "prepare failed: %s\n%s\n", sqlite3_errmsg(db), sql); +- sqlite3_free(sql); +- return -1; +- } +- +- for (counter = 0; +- ((result = sqlite3_step(stmt)) == SQLITE_BUSY || result == SQLITE_LOCKED) && counter < 2; +- counter++) { +- /* While SQLITE_BUSY has a built in timeout, +- * SQLITE_LOCKED does not, so sleep */ +- if (result == SQLITE_LOCKED) +- sleep(1); +- } +- +- switch (result) +- { +- case SQLITE_DONE: +- /* no rows returned */ +- ret = 0; +- break; +- case SQLITE_ROW: +- if (sqlite3_column_type(stmt, 0) == SQLITE_NULL) +- { +- ret = 0; +- break; +- } +- ret = sqlite3_column_int(stmt, 0); +- break; +- default: +- DPRINTF(E_WARN, L_DB_SQL, "%s: step failed: %s\n%s\n", __func__, sqlite3_errmsg(db), sql); +- ret = -1; +- break; +- } +- sqlite3_free(sql); +- sqlite3_finalize(stmt); +- +- return ret; ++ sql_get_field(int, sqlite3_column_int) + } + + int64_t + sql_get_int64_field(sqlite3 *db, const char *fmt, ...) + { +- va_list ap; +- int counter, result; +- char *sql; +- int64_t ret; +- sqlite3_stmt *stmt; +- +- va_start(ap, fmt); +- sql = sqlite3_vmprintf(fmt, ap); +- va_end(ap); +- +- //DPRINTF(E_DEBUG, L_DB_SQL, "sql: %s\n", sql); +- +- switch (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL)) +- { +- case SQLITE_OK: +- break; +- default: +- DPRINTF(E_ERROR, L_DB_SQL, "prepare failed: %s\n%s\n", sqlite3_errmsg(db), sql); +- sqlite3_free(sql); +- return -1; +- } +- +- for (counter = 0; +- ((result = sqlite3_step(stmt)) == SQLITE_BUSY || result == SQLITE_LOCKED) && counter < 2; +- counter++) { +- /* While SQLITE_BUSY has a built in timeout, +- * SQLITE_LOCKED does not, so sleep */ +- if (result == SQLITE_LOCKED) +- sleep(1); +- } +- +- switch (result) +- { +- case SQLITE_DONE: +- /* no rows returned */ +- ret = 0; +- break; +- case SQLITE_ROW: +- if (sqlite3_column_type(stmt, 0) == SQLITE_NULL) +- { +- ret = 0; +- break; +- } +- ret = sqlite3_column_int64(stmt, 0); +- break; +- default: +- DPRINTF(E_WARN, L_DB_SQL, "%s: step failed: %s\n%s\n", __func__, sqlite3_errmsg(db), sql); +- ret = -1; +- break; +- } +- sqlite3_free(sql); +- sqlite3_finalize(stmt); +- +- return ret; ++ sql_get_field(int64_t, sqlite3_column_int64) + } + + char *