summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hesse2020-11-04 23:59:09 +0100
committerChristian Hesse2020-11-04 23:59:09 +0100
commit3dc682048aa6299ad6d159965a0cedb219d28447 (patch)
tree9cfca8f7c1792642346b42221ecaff45bddc331c
downloadaur-3dc682048aa6299ad6d159965a0cedb219d28447.tar.gz
commit netinstall 6.47.7-1
-rw-r--r--.SRCINFO21
-rw-r--r--PKGBUILD31
-rw-r--r--netinstall.c66
-rw-r--r--netinstall.desktop10
-rw-r--r--netinstall.install9
5 files changed, 137 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..5e06b3edaea9
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,21 @@
+pkgbase = netinstall
+ pkgdesc = Mikrotik Netinstall for RouterOS
+ pkgver = 6.47.7
+ pkgrel = 1
+ url = https://www.mikrotik.com/
+ install = netinstall.install
+ arch = i686
+ arch = x86_64
+ license = custom
+ makedepends = icoutils
+ depends = wine
+ depends = libcap
+ source = https://download.mikrotik.com/routeros/6.47.7/netinstall-6.47.7.zip
+ source = netinstall.c
+ source = netinstall.desktop
+ sha256sums = c27212f20520ccdae2eb8df78b3ebe146707c9c4464d3daacc23abad5f0e1699
+ sha256sums = 0788e62837867c93147988ff3fbd8b005aa21af7a46fd0faec97fe1e38b2af95
+ sha256sums = 742b8ebf2b66697f24a27b5e6920dd4a4b92dec0fea928e8f58e499246284623
+
+pkgname = netinstall
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..bb9ed06f794a
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,31 @@
+# Maintainer: Christian Hesse <mail@eworm.de>
+
+pkgname=netinstall
+pkgver=6.47.7
+pkgrel=1
+pkgdesc='Mikrotik Netinstall for RouterOS'
+arch=('i686' 'x86_64')
+url='https://www.mikrotik.com/'
+license=('custom')
+depends=('wine' 'libcap')
+makedepends=('icoutils')
+install=netinstall.install
+source=("https://download.mikrotik.com/routeros/${pkgver}/netinstall-${pkgver}.zip"
+ 'netinstall.c'
+ 'netinstall.desktop')
+sha256sums=('c27212f20520ccdae2eb8df78b3ebe146707c9c4464d3daacc23abad5f0e1699'
+ '0788e62837867c93147988ff3fbd8b005aa21af7a46fd0faec97fe1e38b2af95'
+ '742b8ebf2b66697f24a27b5e6920dd4a4b92dec0fea928e8f58e499246284623')
+
+build() {
+ wrestool -x -t 14 netinstall.exe > netinstall.ico
+ gcc ${CFLAGS} ${LDFLAGS} -o netinstall netinstall.c -lcap
+}
+
+package() {
+ install -D -m0755 netinstall.exe ${pkgdir}/usr/share/netinstall/netinstall.exe
+ install -D -m0755 netinstall ${pkgdir}/usr/bin/netinstall
+ install -D -m0644 netinstall.desktop ${pkgdir}/usr/share/applications/netinstall.desktop
+ install -D -m0644 netinstall.ico ${pkgdir}/usr/share/pixmaps/netinstall.ico
+ install -D -m0644 LICENSE.txt ${pkgdir}/usr/share/licenses/netinstall/LICENSE.txt
+}
diff --git a/netinstall.c b/netinstall.c
new file mode 100644
index 000000000000..89b8b582d2a0
--- /dev/null
+++ b/netinstall.c
@@ -0,0 +1,66 @@
+/*
+ * (C) 2020 by Christian Hesse <mail@eworm.de>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ * Running Mikrotik netinstall with unprivileged user requires ambient
+ * capability CAP_NET_BIND_SERVICE. This is a wrapper to run it in wine.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/capability.h>
+#include <sys/prctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+int main(int argc, char ** argv) {
+ cap_value_t newcap[1];
+ cap_t caps = cap_get_proc();
+ newcap[0] = CAP_NET_BIND_SERVICE;
+ cap_set_flag(caps, CAP_INHERITABLE, 1, newcap, CAP_SET);
+ cap_set_proc(caps);
+ cap_free(caps);
+
+ if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, CAP_NET_BIND_SERVICE, 0, 0)) {
+ perror("prctl: can not set CAP_NET_BIND_SERVICE");
+ return EXIT_FAILURE;
+ }
+
+ struct stat st;
+ const char *home = getenv("HOME");
+ char wineprefix[256];
+ snprintf(wineprefix, sizeof wineprefix, "%s/.netinstall/wine/", home);
+
+ setenv("WINEPREFIX", wineprefix, 1);
+ setenv("WINEARCH", "win64", 1);
+ setenv("WINEDLLOVERRIDES", "mscoree=", 1);
+ setenv("WINEDEBUG", "-all", 1);
+
+ if (chdir(home) == -1) {
+ perror("chdir: changing to home directory");
+ return EXIT_FAILURE;
+ }
+
+ if (stat(".netinstall/", &st) == -1) {
+ if (mkdir(".netinstall/", 0777) == -1) {
+ perror("mkdir: creating directory '.netinstall/'");
+ return EXIT_FAILURE;
+ }
+
+ if (system("wineboot -u") != 0) {
+ perror("system: running wineboot");
+ return EXIT_FAILURE;
+ }
+ }
+
+ const char *pathname = "/usr/bin/wine";
+ char * const newargv[] = { "wine", "/usr/share/netinstall/netinstall.exe", NULL };
+ execv(pathname, newargv);
+
+ /* execv() returns only on error */
+ perror("execv");
+ return EXIT_FAILURE;
+}
diff --git a/netinstall.desktop b/netinstall.desktop
new file mode 100644
index 000000000000..8729d930221a
--- /dev/null
+++ b/netinstall.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Version=1.0
+Name=Netinstall
+Comment=Mikrotik Netinstall for RouterOS
+Exec=/usr/bin/netinstall
+Icon=/usr/share/pixmaps/netinstall.ico
+Terminal=false
+Categories=Utility
+StartupWMClass=netinstall.exe
diff --git a/netinstall.install b/netinstall.install
new file mode 100644
index 000000000000..648b778b2841
--- /dev/null
+++ b/netinstall.install
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+post_install() {
+ setcap CAP_NET_BIND_SERVICE+ep usr/bin/netinstall
+}
+
+post_upgrade() {
+ post_install
+}