commit:     89c4396610b1a9b0652bed90102d4014b0e5b4f0
Author:     Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
AuthorDate: Sat May  2 09:14:45 2020 +0000
Commit:     Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
CommitDate: Sat May  2 09:20:28 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=89c43966

media-libs/svgalib: fix build with recent kernels and more

- Fix build with recent kernels by migrating from SUBDIRS to M.
- Bump to EAPI 7.
- Disable package-side man page compression.
- Fix buffer overflow in wrapdemo.c.
- Clean up ebuild and fix spec QA issues.
- Rebase patches with fuzz.

Package-Manager: Portage-2.3.82, Repoman-2.3.20
Signed-off-by: Andrew Savchenko <bircoph <AT> gentoo.org>

 .../svgalib/files/svgalib-1.9.25-linux_2.6.patch   |   2 +-
 .../svgalib/files/svgalib-1.9.25-linux_3.4.patch   |  58 +++++-----
 .../svgalib/files/svgalib-1.9.25-linux_3.9.patch   |  11 +-
 .../files/svgalib-1.9.25-no-man-compression.patch  |  26 +++++
 .../svgalib-1.9.25-wrapdemo-buf-overflow.patch     |  14 +++
 media-libs/svgalib/svgalib-1.9.25-r6.ebuild        | 124 +++++++++++++++++++++
 6 files changed, 200 insertions(+), 35 deletions(-)

diff --git a/media-libs/svgalib/files/svgalib-1.9.25-linux_2.6.patch 
b/media-libs/svgalib/files/svgalib-1.9.25-linux_2.6.patch
index 20ab1fe1ed1..113a2391cdf 100644
--- a/media-libs/svgalib/files/svgalib-1.9.25-linux_2.6.patch
+++ b/media-libs/svgalib/files/svgalib-1.9.25-linux_2.6.patch
@@ -22,7 +22,7 @@
 +++ svgalib/kernel/svgalib_helper/Makefile.alt
 @@ -37,7 +37,7 @@
  CFLAGS += -DSVGALIB_HELPER_MAJOR=$(SVGALIB_HELPER_MAJOR)
- 
+                                                                               
                    
  ifeq (1,$(findstring 1,$(MODVER)))
 -      CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h
 +      CFLAGS += -DMODVERSIONS -DCONFIG_MODVERSIONS=1

diff --git a/media-libs/svgalib/files/svgalib-1.9.25-linux_3.4.patch 
b/media-libs/svgalib/files/svgalib-1.9.25-linux_3.4.patch
index 5e2d1e527cb..ce9c74ccd20 100644
--- a/media-libs/svgalib/files/svgalib-1.9.25-linux_3.4.patch
+++ b/media-libs/svgalib/files/svgalib-1.9.25-linux_3.4.patch
@@ -1,29 +1,29 @@
-diff -Naur svgalib-1.9.25/kernel/svgalib_helper/main.c 
svgalib-1.9.25_new/kernel/svgalib_helper/main.c
---- svgalib-1.9.25/kernel/svgalib_helper/main.c    2006-01-12 
18:17:53.000000000 +0000
-+++ svgalib-1.9.25_new/kernel/svgalib_helper/main.c    2012-06-25 
15:02:11.000000000 +0100
-@@ -33,7 +33,9 @@
- 
- #include <asm/processor.h>
- #include <asm/uaccess.h>
--#include <asm/system.h>   /* cli(), *_flags */
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
-+  #include <asm/system.h>   /* cli(), *_flags */
-+#endif
- #include <asm/segment.h>  /* memcpy and such */
- #include <asm/io.h>
- #include <asm/pgtable.h>
-diff -Naur svgalib-1.9.25/kernel/svgalib_helper/Makefile 
svgalib-1.9.25_new/kernel/svgalib_helper/Makefile
---- svgalib-1.9.25/kernel/svgalib_helper/Makefile    2006-05-20 
13:31:04.000000000 +0100
-+++ svgalib-1.9.25_new/kernel/svgalib_helper/Makefile    2012-06-25 
13:39:38.000000000 +0100
-@@ -11,9 +11,11 @@
-    PWD    := $(shell pwd)
-    TARGET  := svgalib_helper
- 
-+   ifneq ($(TOPDIR),)
-       ifeq ($(PATCHLEVEL),4)
-          include $(TOPDIR)/Rules.make
-       endif
-+   endif 
- 
- else
- 
\ No newline at end of file
+diff '--color=auto' -Naurd svgalib-1.9.25.prev/kernel/svgalib_helper/Makefile 
svgalib-1.9.25/kernel/svgalib_helper/Makefile
+--- svgalib-1.9.25.prev/kernel/svgalib_helper/Makefile 2020-05-02 
09:49:05.072052128 +0300
++++ svgalib-1.9.25/kernel/svgalib_helper/Makefile      2020-05-02 
09:50:14.748043187 +0300
+@@ -11,9 +11,11 @@
+    PWD        := $(shell pwd)
+    TARGET  := svgalib_helper
+ 
++   ifneq ($(TOPDIR),)
+       ifeq ($(PATCHLEVEL),4)
+          include $(TOPDIR)/Rules.make
+       endif
++   endif 
+ 
+ else
+ 
+diff '--color=auto' -Naurd svgalib-1.9.25.prev/kernel/svgalib_helper/main.c 
svgalib-1.9.25/kernel/svgalib_helper/main.c
+--- svgalib-1.9.25.prev/kernel/svgalib_helper/main.c   2020-05-02 
09:49:05.075052085 +0300
++++ svgalib-1.9.25/kernel/svgalib_helper/main.c        2020-05-02 
09:50:14.751043144 +0300
+@@ -38,7 +38,9 @@
+ 
+ #include <asm/processor.h>
+ #include <asm/uaccess.h>
+-#include <asm/system.h>   /* cli(), *_flags */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
++  #include <asm/system.h>   /* cli(), *_flags */
++#endif
+ #include <asm/segment.h>  /* memcpy and such */
+ #include <asm/io.h>
+ #include <asm/pgtable.h>

diff --git a/media-libs/svgalib/files/svgalib-1.9.25-linux_3.9.patch 
b/media-libs/svgalib/files/svgalib-1.9.25-linux_3.9.patch
index be10e394707..2e1f87d7c6f 100644
--- a/media-libs/svgalib/files/svgalib-1.9.25-linux_3.9.patch
+++ b/media-libs/svgalib/files/svgalib-1.9.25-linux_3.9.patch
@@ -1,8 +1,9 @@
---- svgalib-1.9.25/kernel/svgalib_helper/main.c.orig   2016-02-22 
11:10:25.000000000 +0300
-+++ svgalib-1.9.25/kernel/svgalib_helper/main.c        2016-02-22 
11:17:16.223529679 +0300
-@@ -170,8 +170,12 @@
+diff '--color=auto' -Naurd svgalib-1.9.25.prev/kernel/svgalib_helper/main.c 
svgalib-1.9.25/kernel/svgalib_helper/main.c
+--- svgalib-1.9.25.prev/kernel/svgalib_helper/main.c   2020-05-02 
09:50:14.751043144 +0300
++++ svgalib-1.9.25/kernel/svgalib_helper/main.c        2020-05-02 
09:51:44.564742599 +0300
+@@ -171,8 +171,12 @@
  #else
- static int svgalib_helper_ioctl(struct file *filp, 
+ static long svgalib_helper_ioctl(struct file *filp,
                            unsigned int cmd, unsigned long arg) {
 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0) 
 +    struct inode *inode=file_inode(filp);
@@ -13,7 +14,7 @@
  
      io_t iov, *user_iov=(io_t *)arg;
      pcic_t pciv, *user_pciv=(pcic_t *)arg;
-@@ -586,7 +590,11 @@
+@@ -587,7 +591,11 @@
  static int svgalib_helper_mmap(struct file *filp, struct vm_area_struct *vma) 
{
     unsigned long start=vma->vm_start;
     unsigned long end=vma->vm_end;

diff --git a/media-libs/svgalib/files/svgalib-1.9.25-no-man-compression.patch 
b/media-libs/svgalib/files/svgalib-1.9.25-no-man-compression.patch
new file mode 100644
index 00000000000..e88647412f0
--- /dev/null
+++ b/media-libs/svgalib/files/svgalib-1.9.25-no-man-compression.patch
@@ -0,0 +1,26 @@
+--- svgalib-1.9.25/doc/Makefile.orig   2005-07-02 20:21:57.000000000 +0400
++++ svgalib-1.9.25/doc/Makefile        2020-05-02 00:15:00.104324667 +0300
+@@ -26,7 +26,7 @@
+ SVGALIB=$(subst man,$(srcdir)/doc/man,$(SVGALIB1))
+ VGAGL=$(subst man,$(srcdir)/doc/man,$(VGAGL1))
+ THREED=$(subst man,$(srcdir)/doc/man,$(THREED1))
+-COMPMANPAGES=$(shell cd $(srcdir)/doc; find man? -name "*.gz" -type f -print)
++COMPMANPAGES=$(shell cd $(srcdir)/doc; find man? -type f -print)
+ 
+ .PHONY: clean ascii dvi ps install gunzip gzip
+ 
+@@ -63,13 +63,12 @@
+       cat $(VGAGL) | grep -v '^\.so ' | troff -man -T$@ > vgagl.$@
+       cat $(THREED) | grep -v '^\.so ' | troff -man -T$@ > 3d.$@
+ 
+-install: gzip
++install:
+       mkdir -p $(mandir)/man1 $(mandir)/man3 $(mandir)/man5 \
+                $(mandir)/man6 $(mandir)/man7 $(mandir)/man8
+       for i in $(COMPMANPAGES); do\
+               $(INSTALL_DATA) $(srcdir)/doc/$$i $(mandir)/$$i; \
+       done
+-      make gunzip
+ ifdef MAKEWHATIS
+       @echo "Rebuilding the whatis database (this is slow!)"
+       @echo "You can comment this out in Makefile.cfg!"

diff --git 
a/media-libs/svgalib/files/svgalib-1.9.25-wrapdemo-buf-overflow.patch 
b/media-libs/svgalib/files/svgalib-1.9.25-wrapdemo-buf-overflow.patch
new file mode 100644
index 00000000000..1ea9f6a5e1e
--- /dev/null
+++ b/media-libs/svgalib/files/svgalib-1.9.25-wrapdemo-buf-overflow.patch
@@ -0,0 +1,14 @@
+Fix buffer overflow in palette when writing last non-used element:
+
+wrapdemo.c:256:29: warning: iteration 63 invokes undefined behavior 
[-Waggressive-loop-optimizations]
+--- svgalib-1.9.25/threeDKit/wrapdemo.c.orig   2020-05-01 23:41:32.000000000 
+0300
++++ svgalib-1.9.25/threeDKit/wrapdemo.c        2020-05-01 23:41:55.911933032 
+0300
+@@ -230,7 +230,7 @@
+    can be 0, 64, 128, OR 192 */
+ 
+     int i;
+-    unsigned char palette[768];
++    unsigned char palette[769];
+ 
+     for (i = 0; i < 64; i++) {
+       palette[i * 3] = i;

diff --git a/media-libs/svgalib/svgalib-1.9.25-r6.ebuild 
b/media-libs/svgalib/svgalib-1.9.25-r6.ebuild
new file mode 100644
index 00000000000..55f0bb10dda
--- /dev/null
+++ b/media-libs/svgalib/svgalib-1.9.25-r6.ebuild
@@ -0,0 +1,124 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit flag-o-matic linux-mod toolchain-funcs
+
+DESCRIPTION="A library for running svga graphics on the console"
+HOMEPAGE="http://www.svgalib.org/";
+SRC_URI="http://www.arava.co.il/matan/${PN}/${P}.tar.gz";
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="-* ~x86"
+IUSE="build +kernel-helper"
+
+MODULE_NAMES="svgalib_helper(misc:${S}/kernel/svgalib_helper)"
+BUILD_TARGETS="default"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-1.9.25-linux_2.6.patch
+       "${FILESDIR}"/${PN}-1.9.19-pic.patch
+       "${FILESDIR}"/${PN}-1.9.25-build.patch
+       "${FILESDIR}"/${PN}-1.9.25-linux_2.6.28.patch
+       "${FILESDIR}"/${PN}-1.9.25-glibc210.patch
+       "${FILESDIR}"/${PN}-1.9.25-linux_2.6.36-r1.patch
+       "${FILESDIR}"/${PN}-1.9.25-fix_buffer.patch
+       "${FILESDIR}"/${PN}-1.9.25-vga_reset.patch
+       "${FILESDIR}"/${PN}-1.9.25-missing_include.patch
+       "${FILESDIR}"/${PN}-1.9.25-linux_3.4.patch
+       "${FILESDIR}"/${PN}-1.9.25-linux_3.9.patch
+       "${FILESDIR}"/${PN}-1.9.25-no-man-compression.patch
+       "${FILESDIR}"/${PN}-1.9.25-wrapdemo-buf-overflow.patch
+)
+
+pkg_setup() {
+       linux-mod_pkg_setup
+       BUILD_PARAMS="KDIR=${KV_OUT_DIR}"
+}
+
+src_prepare() {
+       default
+       sed -i -e '/linux\/smp_lock.h/d' kernel/svgalib_helper/main.c || die
+       convert_to_m kernel/svgalib_helper/Makefile
+}
+
+src_compile() {
+       use kernel-helper || export NO_HELPER=y
+
+       export CC=$(tc-getCC)
+       # C89 extern inlines are needed, see #576260
+       append-cflags -fgnu89-inline
+
+       # First build static
+       emake OPTIMIZE="${CFLAGS}" static
+       # Then build shared ...
+       emake OPTIMIZE="${CFLAGS}" shared
+       emake OPTIMIZE="${CFLAGS}" LDFLAGS+=" -L../sharedlib" \
+               textutils lrmi utils
+       # Build threeDKit ...
+       emake OPTIMIZE="${CFLAGS}" LDFLAGS+=" -L../sharedlib" \
+               -C threeDKit lib3dkit.a
+       # Build demo's ...
+       emake OPTIMIZE="${CFLAGS} -I../gl" LDFLAGS+=" -L../sharedlib" \
+               demoprogs
+
+       ! use build && use kernel-helper && linux-mod_src_compile
+}
+
+src_install() {
+       local x
+
+       dodir /etc/svgalib /usr/{include,lib,bin,share/man}
+
+       emake \
+               TOPDIR="${D}" OPTIMIZE="${CFLAGS}" INSTALLMODULE="" \
+               install
+       ! use build && use kernel-helper && linux-mod_src_install
+
+       insinto /usr/include
+       doins gl/vgagl.h
+       dolib.a staticlib/libvga.a
+       dolib.a staticlib/libvgagl.a
+       dolib.a threeDKit/lib3dkit.a
+
+       insinto /usr/include
+       doins src/vga.h gl/vgagl.h src/mouse/vgamouse.h 
src/joystick/vgajoystick.h
+       doins src/keyboard/vgakeyboard.h kernel/svgalib_helper/svgalib_helper.h
+
+       insinto /lib/udev/rules.d
+       newins "${FILESDIR}"/svgalib.udev.rules.d.2 30-svgalib.rules
+
+       exeinto /usr/lib/svgalib/demos
+       for x in "${S}"/demos/* ; do
+               [[ -x ${x} ]] && doexe ${x}
+       done
+
+       cd "${S}"/threeDKit || die
+       exeinto /usr/lib/svgalib/threeDKit
+       local THREED_PROGS="plane wrapdemo"
+       doexe ${THREED_PROGS}
+
+       cd "${ED}/usr/$(get_libdir)" || die
+       ln -s libvga.so.${PV} libvga.so.1 || die
+       ln -s libvgagl.so.${PV} libvgagl.so.1 || die
+       ln -s lib3dkit.so.${PV} lib3dkit.so.1 || die
+       ln -sf libvga.so.1 libvga.so || die
+       ln -sf libvgagl.so.1 libvgagl.so || die
+       ln -sf lib3dkit.so.1 lib3dkit.so || die
+
+       cd "${S}" || die
+       dodoc 0-README
+       cd "${S}"/doc || die
+       dodoc CHANGES DESIGN TODO
+       docinto txt
+       dodoc Driver-programming-HOWTO add_driver svgalib.lsm \
+               README.{joystick,keymap,multi-monitor,patching,vesa}
+       # avoid installation of a broken symlink
+       newdoc ../lrmi-0.6m/README README.lrmi
+}
+
+pkg_postinst() {
+       ! use build && use kernel-helper && linux-mod_pkg_postinst
+}

Reply via email to