summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD32
-rw-r--r--swarm.patch114
3 files changed, 137 insertions, 13 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 57222581000b..002cf8934d0f 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = libgaminggear
pkgdesc = Provides functionality for gaming input devices
pkgver = 0.11.0
- pkgrel = 1
+ pkgrel = 2
url = http://sourceforge.net/projects/libgaminggear/
arch = i686
arch = x86_64
@@ -13,7 +13,9 @@ pkgbase = libgaminggear
depends = gtk2
depends = sqlite3>=3.7
source = http://downloads.sourceforge.net/project/libgaminggear/libgaminggear-0.11.0.tar.bz2
+ source = swarm.patch
md5sums = 83e7ddb2ba40c6f53fd7f91beb1022da
+ md5sums = 997f81df70a67195aaac9397ced3a263
pkgname = libgaminggear
diff --git a/PKGBUILD b/PKGBUILD
index 6ee4bca31b71..97fce6b07c93 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,28 +1,36 @@
# Maintainer: Aaron Fischer <mail@aaron-fischer.net>
# Contributor: Zachary Lund <admin@computerquip.com>
-
+# Contributor: Edward Noname <edward.81@gmail.com>
+
pkgname=libgaminggear
pkgver=0.11.0
-pkgrel=1
+pkgrel=2
pkgdesc="Provides functionality for gaming input devices"
arch=('i686' 'x86_64')
license=('GPL')
url="http://sourceforge.net/projects/libgaminggear/"
depends=('libnotify' 'libcanberra' 'gtk2' 'sqlite3>=3.7')
makedepends=('cmake>=3.0' 'doxygen')
-source=(http://downloads.sourceforge.net/project/libgaminggear/${pkgname}-${pkgver}.tar.bz2)
-md5sums=('83e7ddb2ba40c6f53fd7f91beb1022da')
+source=(http://downloads.sourceforge.net/project/libgaminggear/${pkgname}-${pkgver}.tar.bz2
+ swarm.patch)
+md5sums=('83e7ddb2ba40c6f53fd7f91beb1022da'
+ '997f81df70a67195aaac9397ced3a263')
+
+prepare() {
+ cd "${srcdir}/libgaminggear-${pkgver}"
+ patch -p1 < "${startdir}/swarm.patch"
+}
build() {
- cd "${srcdir}/${pkgname}-${pkgver}"
- cmake \
- -DCMAKE_INSTALL_PREFIX="/usr" \
- -DINSTALL_LIBDIR="/usr/lib" \
- -DINSTALL_CMAKE_MODULESDIR="/usr/share/cmake-3.3/Modules"
- make
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ cmake \
+ -DCMAKE_INSTALL_PREFIX="/usr" \
+ -DINSTALL_LIBDIR="/usr/lib" \
+ -DINSTALL_CMAKE_MODULESDIR="/usr/share/cmake-3.3/Modules"
+ make
}
package() {
- cd "${srcdir}/${pkgname}-${pkgver}/"
- make DESTDIR=${pkgdir} install
+ cd "${srcdir}/${pkgname}-${pkgver}/"
+ make DESTDIR=${pkgdir} install
}
diff --git a/swarm.patch b/swarm.patch
new file mode 100644
index 000000000000..21bcb2250b4c
--- /dev/null
+++ b/swarm.patch
@@ -0,0 +1,114 @@
+--- a/libgaminggear/macros_converter_roccat_swarm.c
++++ b/libgaminggear/macros_converter_roccat_swarm.c
+@@ -64,36 +64,46 @@
+ g_strlcpy((gchar *)(macro->name), new_name, SWARM_MACRO_NAME_LENGTH);
+ }
+
++static gboolean myread(int fd, void *buffer, size_t nbytes, GError **error) {
++ int result;
++
++ result = read(fd, buffer, nbytes);
++ if (result == 0) {
++ g_set_error(error, G_FILE_ERROR, G_FILE_ERROR_IO, _("Trying to read behind file boundaries"));
++ return FALSE;
++ } else if (result < 0) {
++ g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), _("Could not read: %s"), g_strerror(errno));
++ return FALSE;
++ }
++ return TRUE;
++}
++
+ static gboolean read32be(int fd, guint32 *value, GError **error) {
+ guint32 buffer;
+ int result;
+
+- result = read(fd, &buffer, sizeof(guint32));
+- if (result == 0) {
+- g_set_error(error, G_FILE_ERROR, G_FILE_ERROR_IO, _("Trying to read behind file boundaries"));
+- return FALSE;
+- } else if (result < 0) {
+- g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), _("Could not read: %s"), g_strerror(errno));
+- return FALSE;
+- }
++ result = myread(fd, &buffer, sizeof(guint32), error);
++ if (!result)
++ return FALSE;
+
+ *value = GUINT32_FROM_BE(buffer);
++
++ return TRUE;
++}
++
++static gboolean mywrite(int fd, void const *buffer, size_t nbytes, GError **error) {
++ if (write(fd, buffer, nbytes) < 0) {
++ g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), _("Could not write: %s"), g_strerror(errno));
++ return FALSE;
++ }
+ return TRUE;
+ }
+
+ static gboolean write32be(int fd, guint32 value, GError **error) {
+ guint32 buffer;
+- int result;
+-
+ buffer = GUINT32_TO_BE(value);
+
+- result = write(fd, &buffer, sizeof(guint32));
+- if (result < 0) {
+- g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), _("Could not write: %s"), g_strerror(errno));
+- return FALSE;
+- }
+-
+- return TRUE;
++ return mywrite(fd, &buffer, sizeof(guint32), error);
+ }
+
+ static void utf16_from_be(gunichar2 *data, guint length) {
+@@ -165,7 +175,7 @@
+ glong size;
+ int fd;
+
+- fd = open(filename, O_WRONLY | O_CREAT);
++ fd = open(filename, O_WRONLY | O_CREAT, 0666);
+ if (fd < 0) {
+ g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), _("Could not open %2$s macro file %1$s: %3$s"), filename, "Roccat Swarm", g_strerror(errno));
+ return FALSE;
+@@ -181,7 +191,9 @@
+ utf16_to_be(macroset_name, size);
+ if (!write32be(fd, size * 2, error))
+ goto free_macrosets;
+- write(fd, macroset_name, size * 2);
++ if (!mywrite(fd, macroset_name, size * 2, error))
++ goto free_macrosets;
++
+ g_free(macroset_name);
+
+ macros = gaminggear_macros_get_macros(gaminggear_macros, *macroset, &macro_count, error);
+@@ -202,7 +214,8 @@
+ if (!write32be(fd, sizeof(SwarmMacro), error))
+ goto free_macros;
+
+- write(fd, swarm_macro, sizeof(SwarmMacro));
++ if (!mywrite(fd, swarm_macro, sizeof(SwarmMacro), error))
++ goto free_macros;
+
+ g_free(swarm_macro);
+ }
+@@ -244,7 +257,7 @@
+ for (macroset_index = 0; macroset_index < macroset_count; ++macroset_index) {
+ if (!read32be(fd, &size, error)) goto exit;
+ raw_macroset_name = (gunichar2 *)g_malloc(size);
+- read(fd, raw_macroset_name, size);
++ if (!myread(fd, raw_macroset_name, size, error)) goto exit;
+ utf16_from_be(raw_macroset_name, size / 2);
+ macroset_name = g_utf16_to_utf8(raw_macroset_name, size / 2, NULL, NULL, NULL);
+ g_free(raw_macroset_name);
+@@ -256,7 +269,7 @@
+ g_warning("%u != %lu", size, sizeof(SwarmMacro));
+ // FIXME consequence
+ }
+- read(fd, &swarm_macro, size);
++ if (!myread(fd, &swarm_macro, size, error)) goto exit;
+
+ gaminggear_macro_keystrokes = swarm_macro_to_gaminggear_macro_keystrokes(&swarm_macro);
+ gaminggear_macro = gaminggear_macro_new(macroset_name, (gchar const *)swarm_macro.name, gaminggear_macro_keystrokes);