← Back to team overview

maria-developers team mailing list archive

Re: how to build mariadb RPMs

 

Hi, Rich!

On Jan 28, Rich Prohaska wrote:
> Hello Sergei,
> 
> Mixed results when just using CMAKE_PACKAGING_INSTALL_PREFIX to build
> Mariadb RPMs with a non-default install prefix.
> 
> Good news:  the installed files use the supplied install prefix instead of /usr.
> 
> Bad news: the server post install script blew up and killed my

Ouch! Were you able to fix the onwership back?

> machine.  It did "chown -R mysql /" by mistake.  The problem is caused
> by %{_sbindir} not being set to the new install directory.  I hacked
> the post install script to print some debug info.
> 
> running expr : /
> expr: syntax error
> sbindir=/usr/sbin
> bindir=/usr/bin
> basedir=
> datadir=
> 
> As you can see, the expr command is run with a null datadir, which
> happens because /usr/sbin/mysqld does not exist, which happens because
> the _sbindir variable is "/usr/sbin" rather than
> CMAKE_PACKAGING_INSTALL_PREFIX/sbin.  Any ideas how to fix this?

First, it's CPACK_PACKAGING_INSTALL_PREFIX not
CMAKE_PACKAGING_INSTALL_PREFIX. I hope that's what you used, and it's a
typo in the email.

Second, I'll soon fix the postinstall script to have some basic
consistency checks on basedir/datadir before chown. It's
https://mariadb.atlassian.net/browse/MDEV-4068 

And third, I've created a patch that is supposed (as far as I've tested)
to fix this issue. I'll push it in a few days.

Note that after this patch, you're supposed to set CMAKE_INSTALL_PREFIX,
not CMAKE_PACKAGING_INSTALL_PREFIX. Like

  cmake . -DRPM=toku -DCMAKE_INSTALL_PREFIX=/opt

Regards,
Sergei

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2013-01-15 18:13:32 +0000
+++ CMakeLists.txt	2013-01-29 17:00:34 +0000
@@ -132,14 +132,10 @@ IF (NOT CPACK_GENERATOR)
   ENDIF(WIN32) 
 ENDIF(NOT CPACK_GENERATOR)
 
-IF(DEB)
-  SET(INSTALL_LAYOUT "DEB")
-ENDIF(DEB)
-
 INCLUDE(mysql_version)
-INCLUDE(cpack_rpm)
 INCLUDE(cpack_source_ignore_files)
 INCLUDE(install_layout)
+INCLUDE(cpack_rpm)
 
 # Add macros
 INCLUDE(character_sets)

=== modified file 'cmake/cpack_rpm.cmake'
--- cmake/cpack_rpm.cmake	2013-01-29 11:27:31 +0000
+++ cmake/cpack_rpm.cmake	2013-01-29 12:21:35 +0000
@@ -2,7 +2,7 @@ IF(RPM)
 
 SET(CPACK_GENERATOR "RPM")
 SET(CPACK_RPM_PACKAGE_DEBUG 1)
-SET(INSTALL_LAYOUT "RPM")
+SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
 
 SET(CPACK_RPM_COMPONENT_INSTALL ON)
@@ -49,9 +49,12 @@ MariaDB bug reports should be submitted
 SET(CPACK_RPM_SPEC_MORE_DEFINE "
 %define mysql_vendor ${CPACK_PACKAGE_VENDOR}
 %define mysqlversion ${MYSQL_NO_DASH_VERSION}
-%define mysqldatadir /var/lib/mysql
+%define mysqldatadir ${INSTALL_MYSQLDATADIR}
 %define mysqld_user  mysql
 %define mysqld_group mysql
+%define _bindir     ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}
+%define _sbindir    ${CMAKE_INSTALL_PREFIX}/${INSTALL_SBINDIR}
+%define _sysconfdir ${INSTALL_SYSCONFDIR}
 ")
 
 # this creative hack is described here: http://www.cmake.org/pipermail/cmake/2012-January/048416.html
@@ -68,18 +71,18 @@ SET(ignored
   "%ignore /etc"
   "%ignore /etc/init.d"
   "%ignore /etc/logrotate.d"
-  "%ignore /usr"
-  "%ignore /usr/bin"
-  "%ignore /usr/include"
-  "%ignore /usr/lib"
-  "%ignore /usr/lib64"
-  "%ignore /usr/sbin"
-  "%ignore /usr/share"
-  "%ignore /usr/share/aclocal"
-  "%ignore /usr/share/doc"
-  "%ignore /usr/share/man"
-  "%ignore /usr/share/man/man1*"
-  "%ignore /usr/share/man/man8*"
+  "%ignore ${CMAKE_INSTALL_PREFIX}"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/bin"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/include"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/lib"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/lib64"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/sbin"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/share"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/share/aclocal"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/share/doc"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/share/man"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man1*"
+  "%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man8*"
   )
 
 SET(CPACK_RPM_server_USER_FILELIST ${ignored} "%config(noreplace) /etc/my.cnf.d/*")

=== modified file 'cmake/install_layout.cmake'
--- cmake/install_layout.cmake	2013-01-15 18:13:32 +0000
+++ cmake/install_layout.cmake	2013-01-29 17:10:34 +0000
@@ -67,7 +67,13 @@
 # http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths
 
 IF(NOT INSTALL_LAYOUT)
-  SET(INSTALL_LAYOUT "STANDALONE")
+  IF(DEB)
+    SET(INSTALL_LAYOUT "DEB")
+  ELSEIF(RPM)
+    SET(INSTALL_LAYOUT "RPM")
+  ELSE()
+    SET(INSTALL_LAYOUT "STANDALONE")
+  ENDIF()
 ENDIF()
 
 SET(INSTALL_LAYOUT "${INSTALL_LAYOUT}"


Follow ups

References