mt76: ensure that the metapackage gets built as .ipk
[lede.git] / package / system / opkg / patches / 200-usign_support.patch
1 --- a/configure.ac
2 +++ b/configure.ac
3 @@ -169,6 +169,15 @@ if test "x$want_gpgme" = "xyes"; then
4    fi
5  fi
6  
7 +AC_ARG_ENABLE(usign,
8 +    AC_HELP_STRING([--enable-usign], [Enable signature checking with usign
9 +      [[default=yes]] ]),
10 +    [want_usign="$enableval"], [want_usign="yes"])
11 +
12 +if test "x$want_usign" = "xyes"; then
13 +  AC_DEFINE(HAVE_USIGN, 1, [Define if you want usign support])
14 +fi
15 +
16  AC_SUBST(GPGME_CFLAGS)
17  AC_SUBST(GPGME_LIBS)
18  
19 --- a/libopkg/opkg.c
20 +++ b/libopkg/opkg.c
21 @@ -599,7 +599,7 @@ opkg_update_package_lists(opkg_progress_
22                 }
23                 free(url);
24  
25 -#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
26 +#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
27                 if (conf->check_signature) {
28                         char *sig_file_name;
29                         /* download detached signitures to verify the package lists */
30 --- a/libopkg/opkg_cmd.c
31 +++ b/libopkg/opkg_cmd.c
32 @@ -169,7 +169,7 @@ opkg_update_cmd(int argc, char **argv)
33                             list_file_name);
34           }
35           free(url);
36 -#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
37 +#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
38            if (conf->check_signature) {
39                /* download detached signitures to verify the package lists */
40                /* get the url for the sig file */
41 --- a/libopkg/opkg_install.c
42 +++ b/libopkg/opkg_install.c
43 @@ -1288,7 +1288,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up
44       }
45  
46       /* check that the repository is valid */
47 -     #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
48 +     #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
49       char *list_file_name, *sig_file_name, *lists_dir;
50  
51       /* check to ensure the package has come from a repository */
52 --- a/libopkg/opkg_download.c
53 +++ b/libopkg/opkg_download.c
54 @@ -19,6 +19,7 @@
55  
56  #include "config.h"
57  
58 +#include <sys/wait.h>
59  #include <stdio.h>
60  #include <unistd.h>
61  #include <libgen.h>
62 @@ -342,7 +343,28 @@ opkg_prepare_url_for_install(const char
63  int
64  opkg_verify_file (char *text_file, char *sig_file)
65  {
66 -#if defined HAVE_GPGME
67 +#if defined HAVE_USIGN
68 +       int status = -1;
69 +       int pid;
70 +
71 +    if (conf->check_signature == 0 )
72 +        return 0;
73 +
74 +       pid = fork();
75 +       if (pid < 0)
76 +               return -1;
77 +
78 +       if (!pid) {
79 +               execl("/usr/sbin/opkg-key", "opkg-key", "verify", sig_file, text_file, NULL);
80 +               exit(255);
81 +       }
82 +
83 +       waitpid(pid, &status, 0);
84 +       if (!WIFEXITED(status) || WEXITSTATUS(status))
85 +               return -1;
86 +
87 +       return 0;
88 +#elif defined HAVE_GPGME
89      if (conf->check_signature == 0 )
90          return 0;
91      int status = -1;