From 3da5568eb34f864e8f37fe5b86083a671ae756d4 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 17 Aug 2014 13:20:39 +0200 Subject: [PATCH] Install DB schema files using cmake fixes #6881 --- components/db_ido_mysql/CMakeLists.txt | 12 +++++++++ components/db_ido_pgsql/CMakeLists.txt | 12 +++++++++ debian/icinga2-ido-mysql.install | 4 +-- debian/icinga2-ido-pgsql.install | 4 +-- doc/2-getting-started.md | 35 ++++++++------------------ icinga2.spec | 6 +++-- 6 files changed, 42 insertions(+), 31 deletions(-) diff --git a/components/db_ido_mysql/CMakeLists.txt b/components/db_ido_mysql/CMakeLists.txt index 333e144ae..59f2def0e 100644 --- a/components/db_ido_mysql/CMakeLists.txt +++ b/components/db_ido_mysql/CMakeLists.txt @@ -38,4 +38,16 @@ if(MYSQL_FOUND) RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 ) + + install( + DIRECTORY schema + DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql + FILES_MATCHING PATTERN "*.sql" + ) + + install( + DIRECTORY schema/upgrade + DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql/schema + FILES_MATCHING PATTERN "*.sql" + ) endif() diff --git a/components/db_ido_pgsql/CMakeLists.txt b/components/db_ido_pgsql/CMakeLists.txt index 2e50daa51..7e589a27e 100644 --- a/components/db_ido_pgsql/CMakeLists.txt +++ b/components/db_ido_pgsql/CMakeLists.txt @@ -40,4 +40,16 @@ if(PostgreSQL_FOUND) RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 ) + + install( + DIRECTORY schema + DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql + FILES_MATCHING PATTERN "*.sql" + ) + + install( + DIRECTORY schema/upgrade + DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql/schema + FILES_MATCHING PATTERN "*.sql" + ) endif() diff --git a/debian/icinga2-ido-mysql.install b/debian/icinga2-ido-mysql.install index 47a5925de..3980a8ae2 100644 --- a/debian/icinga2-ido-mysql.install +++ b/debian/icinga2-ido-mysql.install @@ -1,4 +1,4 @@ -components/db_ido_mysql/schema/*.sql usr/share/icinga2-ido-mysql/schema -components/db_ido_mysql/schema/upgrade/*.sql usr/share/icinga2-ido-mysql/schema/upgrade +usr/share/icinga2-ido-mysql/schema/*.sql +usr/share/icinga2-ido-mysql/schema/upgrade/*.sql debian/ido-mysql.conf-sample usr/share/icinga2/tmpl usr/lib/*/icinga2/libdb_ido_mysql* diff --git a/debian/icinga2-ido-pgsql.install b/debian/icinga2-ido-pgsql.install index 41b7f62c5..c21353a90 100644 --- a/debian/icinga2-ido-pgsql.install +++ b/debian/icinga2-ido-pgsql.install @@ -1,4 +1,4 @@ -components/db_ido_pgsql/schema/*.sql usr/share/icinga2-ido-pgsql/schema -components/db_ido_pgsql/schema/upgrade/*.sql usr/share/icinga2-ido-pgsql/schema/upgrade +usr/share/icinga2-ido-pgsql/schema/*.sql +usr/share/icinga2-ido-pgsql/schema/upgrade/*.sql debian/ido-pgsql.conf-sample usr/share/icinga2/tmpl usr/lib/*/icinga2/libdb_ido_pgsql* diff --git a/doc/2-getting-started.md b/doc/2-getting-started.md index 5f98d75c3..c0162dc0d 100644 --- a/doc/2-getting-started.md +++ b/doc/2-getting-started.md @@ -484,24 +484,17 @@ setting up a MySQL database for Icinga 2: After creating the database you can import the Icinga 2 IDO schema using the following command: - # mysql -u root -p icinga < /usr/share/doc/icinga2-ido-mysql-*/schema/mysql.sql - -The schema file location differs by the distribution used: - - Distribution | Schema Files - --------------|--------------------- - RHEL | `/usr/share/doc/icinga2-ido-mysql-*/schema` (* means package version). - SUSE | `/usr/share/doc/packages/icinga2-ido-mysql/schema` - Debian/Ubuntu | `/usr/share/icinga2-ido-mysql/schema` + # mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql #### Upgrading the MySQL database -Check the `schema/upgrade` directory for an incremental schema upgrade file. -If there isn't an upgrade file available there's nothing to do. +Check the `/usr/share/icinga2-ido-mysql/schema/upgrade` directory for an +incremental schema upgrade file. If there isn't an upgrade file available +there's nothing to do. Apply all database schema upgrade files incrementially. - # mysql -u root -p icinga < /usr/share/doc/icinga2-ido-mysql-*/schema/upgrade/.sql + # mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/.sql The Icinga 2 DB IDO module will check for the required database schema version on startup and generate an error message if not satisfied. @@ -565,26 +558,18 @@ After creating the database and permissions you can import the Icinga 2 IDO sche using the following command: # export PGPASSWORD=icinga - # psql -U icinga -d icinga < /usr/share/doc/icinga2-ido-pgsql-*/schema/pgsql.sql - -The schema file location differs by the distribution used: - - Distribution | Schema Files - --------------|--------------------- - RHEL | `/usr/share/doc/icinga2-ido-pgsql-*/schema` (* means package version). - SUSE | `/usr/share/doc/packages/icinga2-ido-pgsql/schema` - Debian/Ubuntu | `/usr/share/icinga2-ido-pgsql/schema` - + # psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql #### Upgrading the PostgreSQL database -Check the `schema/upgrade` directory for an incremental schema upgrade file. -If there isn't an upgrade file available there's nothing to do. +Check the `/usr/share/icinga2-ido-pgsql/schema/upgrade` directory for an +incremental schema upgrade file. If there isn't an upgrade file available +there's nothing to do. Apply all database schema upgrade files incrementially. # export PGPASSWORD=icinga - # psql -U icinga -d icinga < /usr/share/doc/icinga2-ido-pgsql-*/schema/upgrade/.sql + # psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/.sql The Icinga 2 DB IDO module will check for the required database schema version on startup and generate an error message if not satisfied. diff --git a/icinga2.spec b/icinga2.spec index 715fedc2c..980762dec 100644 --- a/icinga2.spec +++ b/icinga2.spec @@ -516,13 +516,15 @@ exit 0 %files ido-mysql %defattr(-,root,root,-) -%doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog +%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog %{_libdir}/%{name}/libdb_ido_mysql* +%{_datadir}/icinga2-ido-mysql %files ido-pgsql %defattr(-,root,root,-) -%doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog +%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog %{_libdir}/%{name}/libdb_ido_pgsql* +%{_datadir}/icinga2-ido-pgsql %files classicui-config %defattr(-,root,root,-)