aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO4
-rw-r--r--.gitignore6
-rw-r--r--PKGBUILD4
-rw-r--r--patch.c129
4 files changed, 108 insertions, 35 deletions
diff --git a/.SRCINFO b/.SRCINFO
index fb1eca3c45ea..8b755434f889 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = netease-cloud-music
pkgdesc = Netease Cloud Music, converted from .deb package
pkgver = 1.2.1
- pkgrel = 5
+ pkgrel = 6
url = https://music.163.com/
arch = x86_64
license = custom
@@ -15,7 +15,7 @@ pkgbase = netease-cloud-music
source = netease-cloud-music.bash
sha256sums = 1ee9f02842e6c2c8c79c48b2e932074f9c213a8eb4238e5e63f20438562fecbb
sha256sums = cf307fee4be224223ed8cf5af5e8708960683564cd05c53108fa3c382c029a0e
- sha256sums = 56ca2bef65508632b2cff48289a34082c6a780743f34eebfb9746f5480ee2015
+ sha256sums = a92650cfd889b1d5c3192adc0785627721f1c60dbfe08a35f124f6f5cc9613dc
sha256sums = 0c470e76741c549e5530b2e57d57281eaf198fd56ca3590f664154365b744cf9
sha256sums = b11bd6ab4abcc375850668f54a4912948875ad9f9b93cfc24f89de16ec1e8ea7
diff --git a/.gitignore b/.gitignore
index 7c9d4de9a0f4..05467174384d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
-*.tar.xz
+*.pkg.tar.*
service.html
*.deb
-tmp
+/tmp
+/pkg
+/src \ No newline at end of file
diff --git a/PKGBUILD b/PKGBUILD
index dc3ae741ec90..8d7b8db9720d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,7 +4,7 @@
pkgname=netease-cloud-music
pkgver=1.2.1
_pkgdate=20190428
-pkgrel=5
+pkgrel=6
pkgdesc="Netease Cloud Music, converted from .deb package"
arch=("x86_64")
url="https://music.163.com/"
@@ -19,7 +19,7 @@ source=(
)
sha256sums=('1ee9f02842e6c2c8c79c48b2e932074f9c213a8eb4238e5e63f20438562fecbb'
'cf307fee4be224223ed8cf5af5e8708960683564cd05c53108fa3c382c029a0e'
- '56ca2bef65508632b2cff48289a34082c6a780743f34eebfb9746f5480ee2015'
+ 'a92650cfd889b1d5c3192adc0785627721f1c60dbfe08a35f124f6f5cc9613dc'
'0c470e76741c549e5530b2e57d57281eaf198fd56ca3590f664154365b744cf9'
'b11bd6ab4abcc375850668f54a4912948875ad9f9b93cfc24f89de16ec1e8ea7')
diff --git a/patch.c b/patch.c
index 12c401a5c919..e1df0626237a 100644
--- a/patch.c
+++ b/patch.c
@@ -1,19 +1,50 @@
// SPDX-License-Identifier: BSD-3-Clause
-
+/**
+ * Copyright (c) 2021 kXuan. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written permission.
+ *
+ * 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 HOLDER 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.
+ *
+ */
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <sys/prctl.h>
+#include <unistd.h>
#include <vlc/vlc.h>
#include <vlc/plugins/vlc_common.h>
#include <vlc/plugins/vlc_stream.h>
-typedef int(*fn_vlc_stream_vaControl)(stream_t *s, int query, va_list args);
-
-static fn_vlc_stream_vaControl orig_vlc_stream_vaControl;
+static void *load_sym(void *override_func, const char *name)
+{
+ void *ptr = dlsym(RTLD_NEXT, name);
+ if (ptr == NULL) {
+ fprintf(stderr, "Cannot load symbol '%s' %s. Please report bug on AUR.\n", name, dlerror());
+ exit(1);
+ }
+ if (ptr == override_func) {
+ fprintf(stderr, "circular reference '%s'. Please report bug on AUR.\n", name);
+ exit(1);
+ }
+ return ptr;
+}
static int is_flac(const char *url)
{
@@ -29,43 +60,83 @@ static int is_flac(const char *url)
return strcasecmp(url + len - sizeof(suffix) + 1, suffix) == 0;
}
+/**
+ * The netease cloud music server set the Content-Type of .flac format to mpeg/audio, which results vlc unable to decode
+ * the music and play.
+ *
+ * To make vlc works correctly, we rewrite the Content-Type to audio/flac.
+ *
+ * @param s
+ * @param query
+ * @param args
+ * @return
+ */
int vlc_stream_vaControl(stream_t *s, int query, va_list args)
{
+ static typeof(vlc_stream_vaControl) *orig_fn;
+ if (orig_fn == NULL) {
+ orig_fn = load_sym(vlc_stream_vaControl, __func__);
+ }
if (query == STREAM_GET_CONTENT_TYPE && is_flac(s->psz_url)) {
*va_arg(args, char **) = strdup("audio/flac");
return VLC_SUCCESS;
} else {
- return orig_vlc_stream_vaControl(s, query, args);
+ return orig_fn(s, query, args);
}
}
-static void load_sym(void *ptrfunc, void *override_func, const char *name)
+struct string_with_len {
+ const char *s;
+ size_t len;
+};
+#define STRING_WITH_LEN_INIT(s) {s, sizeof(s)-1}
+
+/**
+ * drop all library fixes.
+ *
+ * Library fixes should only be applied to the netease-cloud-music main process. Sometime, netease-cloud-music execute
+ * external program, such as `xdg-open`, `kde-open5`. Those external programs use newer version qt and other new
+ * libraries. If we don't drop these environment variables, those programs may not work, because some symbol may not
+ * exist in the bundled old library.
+ *
+ * @param path
+ * @param argv
+ * @param envp
+ * @return
+ */
+int execve(const char *path, char *const argv[], char *const envp[])
{
- void *ptr = dlsym(RTLD_NEXT, name);
- if (ptr == NULL) {
- fprintf(stderr, "Cannot load symbol '%s' %s. Please report bug on AUR.\n", name, dlerror());
- exit(1);
- }
- if (ptr == override_func) {
- fprintf(stderr, "circular reference '%s'. Please report bug on AUR.\n", name);
- exit(1);
+ static typeof(execve) *orig_fn;
+ if (orig_fn == NULL) {
+ orig_fn = load_sym(execve, "execve");
}
- *(void **)ptrfunc = ptr;
-}
-__attribute__((constructor))
-static void init(void)
-{
- char progname[16] = {0};
- int rc;
+ static struct string_with_len drop_env[] = {
+ STRING_WITH_LEN_INIT("LD_LIBRARY_PATH="),
+ STRING_WITH_LEN_INIT("LD_PRELOAD="),
+ STRING_WITH_LEN_INIT("QT_PLUGIN_PATH="),
+ STRING_WITH_LEN_INIT("QT_QPA_PLATFORM_PLUGIN_PATH="),
+ };
- rc = prctl(PR_GET_NAME, progname);
- if (rc != 0) {
- return;
- }
- if (strcmp(progname, "netease-cloud-m") != 0) {
- return;
+ size_t nenv;
+ for (nenv = 0; envp[nenv]; nenv++);
+
+ char *new_envp[nenv + 1];
+ char *const *src = envp;
+ char **dst = new_envp;
+
+ while (*src) {
+ for (int i = 0; i < sizeof(drop_env) / sizeof(*drop_env); ++i) {
+ if (strncmp(drop_env[i].s, *src, drop_env[i].len) == 0) {
+ goto next_env;
+ }
+ }
+ *dst = *src;
+ ++dst;
+next_env:
+ ++src;
}
- load_sym(&orig_vlc_stream_vaControl, vlc_stream_vaControl, "vlc_stream_vaControl");
+ *dst = NULL;
+ return orig_fn(path, argv, new_envp);
}