Simplest Enterprise Continuous Integration Solutions

Saturday, August 11, 2012

Enterprise Linux: Build a binary RPM for EL6


# Build el6 RPM from el6 OS

# root setup rpm build requires RPMs - redhat-rpm-config, rpm-build on EL6:

[root@linux.el6.x86_64-rpm-server ~]# uname -a
Linux linux.el6.x86_64-rpm-server 2.6.32-279.el6.x86_64 #1 SMP Thu Jun 21 15:00:18 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@linux.el6.x86_64-rpm-server ~]# rpmbuild --version
RPM version 4.8.0
[root@linux.el6.x86_64-rpm-server ~]# yum install redhat-rpm-config
Loaded plugins: security
ol6_u3_base                                                                                                               | 1.4 kB     00:00
ol6_u3_base/primary                                                                                                       | 2.7 MB     00:03
ol6_u3_base                                                                                                                            8452/8452
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package redhat-rpm-config.noarch 0:9.0.3-39.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================
Package                                 Arch                         Version                            Repository                         Size
=================================================================================================================================================
Installing:
redhat-rpm-config                       noarch                       9.0.3-39.el6                       ol6_u3_base                        58 k

Transaction Summary
=================================================================================================================================================
Install       1 Package(s)

Total download size: 58 k
Installed size: 135 k
Is this ok [y/N]: y
Downloading Packages:
redhat-rpm-config-9.0.3-39.el6.noarch.rpm                                                                                 |  58 kB     00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Retrieving key from http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
Importing GPG key 0xEC551F03:
Userid: "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
From  : http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : redhat-rpm-config-9.0.3-39.el6.noarch                                                                                         1/1
  Verifying  : redhat-rpm-config-9.0.3-39.el6.noarch                                                                                         1/1

Installed:
  redhat-rpm-config.noarch 0:9.0.3-39.el6

Complete!
[root@linux.el6.x86_64-rpm-server ~]# yum install rpm-build
Loaded plugins: security
Setting up Install Process
Package rpm-build-4.8.0-27.el6.x86_64 already installed and latest version
Nothing to do

# none root user (i.e. rpm_build_user) setup RPM build environment:

[root@linux.el6.x86_64-rpm-server ~]# su - rpm_build_user
[rpm_build_user@linux.el6.x86_64-rpm-server ~]$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
[rpm_build_user@linux.el6.x86_64-rpm-server ~]$  mkdir -p ~/rpmbuild/RPMS/{noarch,i686,x86_64}
[rpm_build_user@linux.el6.x86_64-rpm-server ~]$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
[rpm_build_user@linux.el6.x86_64-rpm-server ~]$ rpm --eval '%{_sourcedir}'
/home/rpm_build_user/rpmbuild/SOURCES 

# RPM spec file example

#
# spec file for package 'name' (version 'v')
#
# The software is released as specified below.
#
Name: <software_name>
Version: <software_version>
Release: <software_release>%{?dist}
Summary: <software_name>
Vendor: <vendor_name>
License: <Commercial | Free>
URL: <vendor_url>
Group: <Server | Application>
BuildArch: <noarch | i686 | x86_64>
Prefix: /usr/local

%description
This RPM contains <software_name> from <vendor_name>

%pre

%post

%preun

%files
%defattr(-,root,root)
%doc

/usr/local/<software_name>

%changelog
* Sat Aug 11 2012 <rpm_build_user> rpm_build_user@rpm_build_user.com

# none root user (i.e. rpm_build_user) build RPM for el6 OS with x86_64 RPM arch

[rpm_build_user@linux.el6.x86_64-rpm-server ~]$ mkdir -p <rpm_build_root>
[rpm_build_user@linux.el6.x86_64-rpm-server ~]$ rpmbuild -bb /home/rpm_build_user/rpmbuild/SPECS/<software_name>.spec --target x86_64 --buildroot <rpm_build_root>
Building target platforms: x86_64
Building for target x86_64
Processing files: <software_name>-4.0.0.0-20121204.15.8067.el6.x86_64
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(pre): /bin/sh
Requires(post): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files <rpm_build_root>
warning: Could not canonicalize hostname: linux.el6.x86_64-rpm-server
Wrote: /home/rpm_build_user/rpmbuild/RPMS/x86_64/<software_name>-<software_release>-<software_version>.el6.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.qC8Bx1
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ /bin/rm -rf <rpm_build_root>
+ exit 0

# query installed rpm package information

[root@linux.el6.x86_64-dev-server 4.0]# rpm -qi <software_name>
Name        : <software_name>       Relocations: /usr/local
Version     : <software_verion>                           Vendor: <vendor_name>
Release     : <software_release>.el6          Build Date: Tue 22 Jan 2013 04:22:06 AM EST
Install Date: Tue 22 Jan 2013 04:22:29 AM EST      Build Host: linux.el6.x86_64-rpm-server
Group       : <Server | Application>               Source RPM: <software_name>-<software_release>-<software_version>.el6.src.rpm
Size        : 0                                License: Commercial
Signature   : (none)
URL         : <vendor_url>
Summary     : <software_name>
Description :
This RPM contains <software_name> from <vendor_name>


# Build el6 RPM from el5 OS

# none root user (i.e. rpm_build_user) build RPM for el6 OS with x86_64 RPM arch

[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ mkdir -p <rpm_build_root>
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ rpmbuild -bb /home/rpm_build_user/rpmbuild/SPECS/<software_name>.spec --target x86_64 --buildroot <rpm_build_root> --define 'dist .el6'
Building target platforms: x86_64
Building for target x86_64
Processing files: <software_name>-<software_release>-<software_version>.el6
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(pre): /bin/sh
Requires(post): /bin/sh
Requires: /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files <rpm_build_root>
Wrote: /home/<rpm_build_user>/rpmbuild/RPMS/x86_64/<software_name>-<software_release>-<software_version>.el6.x86_64.rpm

Saturday, August 4, 2012

Enterprise Linux: Oracle Linux 6.3 without UEK

kickstart file

An example ks.cfg content

# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Use text mode install
text
lang en_US.UTF-8
keyboard us
# Do not configure the X Window System
skipx
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted $1$PNv3UQZ4$gG61y7oaw8JCUhlzH.k1X0
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc America/New_York
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

%packages

Oracle Linux 6.3 kickstart installation 

Type in after vmlinux initrd=initrd.img ks=http://<http_server>/ks.cfg


































Configure kernel to Red Hat compatible Kernel 2.6.32-279

After reboot, switch Unbreakable Enterprise Kernel Release 2 [kernel-uek-2.6.39-200.24.1.el6uek] Installed and booted by default to Red Hat compatible Kernel [kernel-2.6.32-279.el6]

cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
#title Oracle Linux Server-uek (2.6.39-200.24.1.el6uek.x86_64)
#       root (hd0,0)
#       kernel /vmlinuz-2.6.39-200.24.1.el6uek.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us  rhgb quiet rd_NO_DM rhgb quiet
#       initrd /initramfs-2.6.39-200.24.1.el6uek.x86_64.img
title Oracle Linux Server (2.6.32-279.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-279.el6.x86_64.img
cat /etc/sysconfig/kernel
# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes

# DEFAULTKERNEL specifies the default kernel package type
#DEFAULTKERNEL=kernel-uek
DEFAULTKERNEL=kernel

/etc/yum.repos.d/public-yum-ol6.repo


[ol6_u3_base]
name=Oracle Linux $releasever Update 3 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/3/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1