우분투 20.04 rpm patch

우분투 20.04 버전의 glibc 버전은 2.31이 설치되어 있으며, 아래의 명령어로 glibc 설치 버전을 확인할 수 있다.

$ getconf -a | grep glibc

RDK 4.0 레시피 빌드 과정중 rpm에서 아래와 같은 에러가 발생하며, 이것은 호스트 환경의 glibc 버전이 2.30 이상이라면 에러가 발생한다.

| x86_64-linux-libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../rpm-5.4.15/rpmio -I.. -I../../rpm-5.4.15/rpmio -I../../rpm-5.4.15 -I../../rpm-5.4.15/build -I../../rpm-5.4.15/lib -I../lib -I../../rpm-5.4.15/rpmdb -I../../rpm-5.4.15/rpmio -I../../rpm-5.4.15/misc -I../../rpm-5.4.15/beecrypt/include -I../beecrypt/include -I../../rpm-5.4.15/beecrypt -I../beecrypt -I../../rpm-5.4.15/syck/lib -I../syck/lib -I../../rpm-5.4.15/syck -I../syck -isystem/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -DRPM_OS_LINUX=050400 -I/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -I/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -I/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -I/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -I/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include/ossp -isystem/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe -DRPM_VENDOR_WINDRIVER -DRPM_VENDOR_POKY -DRPM_VENDOR_OE -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS -g -D_GNU_SOURCE -D_REENTRANT -c ../../rpm-5.4.15/rpmio/rpmio-stub.c  -fPIC -DPIC -o .libs/rpmio-stub.o
| In file included from ../../rpm-5.4.15/rpmio/rpmgit.c:8:
| ../../rpm-5.4.15/rpmio/rpmio.h:29:9: error: unknown type name ‘_IO_off64_t’
|    29 | typedef _IO_off64_t  _libio_off_t;
|       |         ^~~~~~~~~~~
| In file included from ../../rpm-5.4.15/rpmio/rpmgit.c:9:
| ../../rpm-5.4.15/rpmio/rpmlog.h:201:7: warning: ignoring attribute ‘pure’ because it conflicts with attribute ‘const’ [-Wattributes]
|   201 |  /*@*/;
|       |       ^
| ../../rpm-5.4.15/rpmio/rpmlog.h:274:31: warning: ‘const’ attribute on function returning ‘void’ [-Wattributes]
|   274 |  /*@modifies internalState @*/;
|       |                               ^
| make[4]: *** [Makefile:2115: rpmgit.lo] Error 1
| make[4]: *** Waiting for unfinished jobs....
| In file included from ../../rpm-5.4.15/rpmio/rpmio-stub.c:6:
| ../../rpm-5.4.15/rpmio/rpmio.h:29:9: error: unknown type name ‘_IO_off64_t’
|    29 | typedef _IO_off64_t  _libio_off_t;
|       |         ^~~~~~~~~~~
| make[4]: *** [Makefile:2115: rpmio-stub.lo] Error 1

glibc 2.30 버전에서 _IO_off64_t 타입이 삭제되었기 때문에 발생한 문제이며, 아래와 같이 수정하도록 한다.

--- rpm-5.4.15_old/rpmio/rpmio.h	2020-11-05 19:09:05.511891000 +0900
+++ rpm-5.4.15_new/rpmio/rpmio.h	2020-11-06 12:21:02.000000000 +0900
@@ -23,8 +23,9 @@
  */
 /*@{*/
 #if !defined(__LCLINT__) && !defined(__UCLIBC__) && defined(__GLIBC__) && \
-	(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) && \
+	(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) && !__GLIBC_PREREQ(2,30)  && \
 	!defined(__UCLIBC__)
+
 #define USE_COOKIE_SEEK_POINTER 1
 typedef _IO_off64_t 	_libio_off_t;
 typedef _libio_off_t *	_libio_pos_t;

그리고 gettid() 함수가 충돌하는 에러가 아래와 같이 발생할 것이며, 우분투 18.04 이하 버전에서는 발생하지 않을 것이다.

| ../../rpm-5.4.15/rpmio/bson.c:3590:1: error: conflicting types for ‘gettid’
|  3590 | gettid (void)
|       | ^~~~~~
| In file included from /usr/include/unistd.h:1170,
|                  from ../../rpm-5.4.15/system.h:87,
|                  from ../../rpm-5.4.15/rpmio/bson.c:19:
| /usr/include/x86_64-linux-gnu/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
|    34 | extern __pid_t gettid (void) __THROW;
|       |                ^~~~~~
| make[4]: *** [Makefile:2115: bson.lo] Error 1
| make[4]: *** Waiting for unfinished jobs....

glibc 버전으로 인해 발생한 문제이기 때문에 아래와 같이 수정하도록 한다.

--- rpm-5.4.15_old/rpmio/bson.c	2020-11-05 19:09:06.371888000 +0900
+++ rpm-5.4.15_new/rpmio/bson.c	2020-11-06 12:20:36.000000000 +0900
@@ -3585,7 +3585,7 @@
 static bson_context_t *gContextDefault;
 
 
-#if defined(__linux__)
+#if defined(__linux__) &&  !__GLIBC_PREREQ(2,30)
 static uint16_t
 gettid (void)
 {