Показаны различия между двумя версиями страницы.
| Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
|
linux:build-rpm:centos [2011/10/20 16:59] linko22@gmail.com |
— (текущий) | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| - | ====== Как состряпать rpm под CentOS ====== | ||
| - | ===== Подготовка среды ===== | ||
| - | |||
| - | |||
| - | Для начала подготавливаем среду на той машине, | ||
| - | |||
| - | yum install rpm-build make m4 gcc-c++ autoconf automake redhat-rpm-config | ||
| - | |||
| - | Создаем каталоги для постройки rpm пакетов в своем домашнем каталоге | ||
| - | |||
| - | mkdir -p ~/ | ||
| - | |||
| - | И затем | ||
| - | |||
| - | echo ' | ||
| - | |||
| - | ===== Как собрать csync2 под CentOS 6.0 x86_64 ===== | ||
| - | |||
| - | Сам проект вроде как живет по адресу [[http:// | ||
| - | |||
| - | Сначала берем последнюю версию csync2 | ||
| - | |||
| - | # cd ~ | ||
| - | # mkdir git | ||
| - | # cd git | ||
| - | # git clone http:// | ||
| - | Initialized empty Git repository in / | ||
| - | Выясняем, | ||
| - | |||
| - | # cd csync2 | ||
| - | # cat csync2.spec | grep -e ^Version -e ^Release | ||
| - | Version: | ||
| - | Release: | ||
| - | |||
| - | Значит, | ||
| - | |||
| - | # cd .. | ||
| - | # cp -R csync2 csync2-2.0 | ||
| - | # rm -R csync2-2.0/ | ||
| - | |||
| - | csync2.spec в оригинальной поставке кривая. Кривость заключается в том, что там нет генерации сертификатов, | ||
| - | |||
| - | Делаем свою **csync2.spec**, | ||
| - | |||
| - | <code bash> | ||
| - | Summary: Cluster synchronization tool | ||
| - | Name: csync2 | ||
| - | Version: 2.0 | ||
| - | Release: 0.1.rc1 | ||
| - | Group: Applications/ | ||
| - | License: GPLv2+ | ||
| - | URL: http:// | ||
| - | Source0: csync2-%{version}.tar.gz | ||
| - | Source1: csync2-README.quickstart | ||
| - | Patch0: csync2-fix-xinetd.patch | ||
| - | |||
| - | BuildRoot: %{_tmppath}/ | ||
| - | |||
| - | Requires(post): | ||
| - | Requires: xinetd | ||
| - | BuildRequires: | ||
| - | |||
| - | %description | ||
| - | Csync2 is a cluster synchronization tool. It can be used to keep files on | ||
| - | multiple hosts in a cluster in sync. Csync2 can handle complex setups with | ||
| - | much more than just 2 hosts, handle file deletions and can detect conflicts. | ||
| - | It is expedient for HA-clusters, | ||
| - | |||
| - | %prep | ||
| - | %setup -q | ||
| - | %patch0 -p1 -b .fix-xinetd | ||
| - | install -p -m 644 %{SOURCE1} README.quickstart | ||
| - | |||
| - | |||
| - | %build | ||
| - | %configure --sysconfdir=%{_sysconfdir}/ | ||
| - | make %{? | ||
| - | |||
| - | |||
| - | %install | ||
| - | rm -rf %{buildroot} | ||
| - | make install DESTDIR=%{buildroot} | ||
| - | mkdir -p %{buildroot}%{_var}/ | ||
| - | install -p -D -m 644 csync2.xinetd %{buildroot}%{_sysconfdir}/ | ||
| - | |||
| - | # We need these empty files to be able to %%ghost them | ||
| - | touch %{buildroot}%{_sysconfdir}/ | ||
| - | touch %{buildroot}%{_sysconfdir}/ | ||
| - | |||
| - | |||
| - | %clean | ||
| - | rm -rf %{buildroot} | ||
| - | |||
| - | |||
| - | %post | ||
| - | umask 077 | ||
| - | if [ ! -f %{_sysconfdir}/ | ||
| - | / | ||
| - | fi | ||
| - | |||
| - | FQDN=`hostname` | ||
| - | if [ " | ||
| - | | ||
| - | fi | ||
| - | |||
| - | if [ ! -f %{_sysconfdir}/ | ||
| - | cat << EOF | / | ||
| - | -- | ||
| - | SomeState | ||
| - | SomeCity | ||
| - | SomeOrganization | ||
| - | |||
| - | |||
| - | |||
| - | EOF | ||
| - | fi | ||
| - | |||
| - | %preun | ||
| - | # Cleanup all databases upon last removal | ||
| - | if [ $1 -eq 0 ]; then | ||
| - | %{__rm} -f %{_var}/ | ||
| - | fi | ||
| - | |||
| - | |||
| - | %files | ||
| - | %defattr(-, | ||
| - | %doc README README.quickstart AUTHORS COPYING | ||
| - | %dir %{_sysconfdir}/ | ||
| - | %config(noreplace) %{_sysconfdir}/ | ||
| - | %config(noreplace) %{_sysconfdir}/ | ||
| - | %ghost %config %{_sysconfdir}/ | ||
| - | %ghost %config %{_sysconfdir}/ | ||
| - | %{_sbindir}/ | ||
| - | %{_sbindir}/ | ||
| - | %{_mandir}/ | ||
| - | %dir %{_var}/ | ||
| - | |||
| - | |||
| - | %changelog | ||
| - | * Tue Nov 13 2007 Matthias Saou < | ||
| - | - Change configuration directory to be / | ||
| - | quite a few files, and putting all of them in /etc/ was messy. | ||
| - | - Include certificate generation upon package installation, | ||
| - | - Rewrite the csync2-README.quickstart file. | ||
| - | - Remove db files upon last removal. | ||
| - | |||
| - | * Tue Nov 13 2007 Matthias Saou < | ||
| - | - Take ownership of the package. | ||
| - | - Update to 1.34. | ||
| - | |||
| - | * Tue Mar 27 2007 < | ||
| - | - Fix ownership of documentation directory (bz 233954) | ||
| - | |||
| - | * Thu Jan 25 2007 < | ||
| - | - Included a README.fedora with instructions on how to create a self-signed | ||
| - | certificate | ||
| - | - Included a mkcert.sh script to create a self-signed certificate | ||
| - | - Removed the creation of ssl certificate from the %%install section | ||
| - | |||
| - | * Wed Jan 22 2007 < | ||
| - | - Fixed the xinetd file so there' | ||
| - | - Create ssl certificates | ||
| - | |||
| - | * Mon Jan 22 2007 < | ||
| - | - Some cleanups as per bz review 223633 | ||
| - | |||
| - | * Sat Jan 20 2007 < | ||
| - | - Initial import | ||
| - | </ | ||
| - | |||
| - | Так же туда же в каталог ~/ | ||
| - | <code patch> | ||
| - | --- csync2-1.33/ | ||
| - | +++ csync2-1.33/ | ||
| - | @@ -1,4 +1,4 @@ | ||
| - | -# default: on | ||
| - | +# default: off | ||
| - | # description: | ||
| - | | ||
| - | { | ||
| - | @@ -9,7 +9,9 @@ | ||
| - | group = root | ||
| - | server | ||
| - | server_args | ||
| - | + | ||
| - | + | ||
| - | # | ||
| - | - | ||
| - | + | ||
| - | # only_from | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | И файл **~/ | ||
| - | <code text> | ||
| - | Getting started with csync2 : | ||
| - | |||
| - | There' | ||
| - | manual says so. Port 30865/tcp is defined in / | ||
| - | detailed here need to be executed as root, so be extra careful. | ||
| - | |||
| - | The config file for csync2 is / | ||
| - | |||
| - | mygroup { | ||
| - | host host1; | ||
| - | host host2; | ||
| - | key / | ||
| - | include / | ||
| - | include / | ||
| - | } | ||
| - | |||
| - | This will sync the csync2 configuration and / | ||
| - | host2. Create the file on host1. Note that hostnames need to be the FQDN | ||
| - | returned by " | ||
| - | |||
| - | Generate the pre-shared key used for authentication : | ||
| - | csync2 -k / | ||
| - | |||
| - | Copy the configuration file and the pre-shared key to host2: | ||
| - | scp / | ||
| - | |||
| - | The SSL key and certificate are generated upon package installation, | ||
| - | can replace them with your own if you like. The files are : | ||
| - | / | ||
| - | / | ||
| - | |||
| - | The csync2 service is disabled by default. To start it on both your hosts : | ||
| - | chkconfig csync2 on | ||
| - | chkconfig --level 345 xinetd on | ||
| - | service xinetd restart | ||
| - | |||
| - | If you are running iptables, you need to open tcp port 30865 on both hosts so | ||
| - | that the other host can connect. | ||
| - | |||
| - | Now you should be able to run and initial verbose sync on both hosts : | ||
| - | csync2 -xv | ||
| - | |||
| - | Once everything looks good, you can add a file with the following line as | ||
| - | / | ||
| - | |||
| - | */5 * * * * root csync2 -x | ||
| - | |||
| - | Happy syncing! | ||
| - | </ | ||
| - | |||
| - | Создаем архив с исходниками | ||
| - | |||
| - | # tar -pczf csync2-2.0.tar.gz csync2-2.0 | ||
| - | |||
| - | Подсовываем его в каталог **~/ | ||
| - | |||
| - | # cp csync2-2.0.tar.gz ~/ | ||
| - | Заходим в каталог с **csync2.spec** и строим .rpm файл. | ||
| - | |||
| - | # cd ~/ | ||
| - | # rpmbuild -bp csync2.spec | ||
| - | # rpmbuild -ba csync2.spec | ||
| - | |||
| - | В случае успеха у нас должно получится в каталоге **~/ | ||
| - | |||
| - | csync2-2.0-0.1.rc1.x86_64.rpm | ||
| - | csync2-debuginfo-2.0-0.1.rc1.x86_64.rpm | ||
| - | |||
| - | Которые можно устанавливать. | ||
| - | |||
| - | |||
| - | rpmbuild -ta source.tar.gz | ||
| - | |||