Best Practices of Software Change Configuration & Release Management
Saturday, December 8, 2012
Saturday, November 10, 2012
Enterprise Linux: Subversion migration
Example 1: svnadmin load from a subversion backup full dump file
Note:If the subversion backup full dump file is a .dump.zip zip binary, you need unzip it to .dump file. Otherwise you will get error as below
svnadmin: E140001: Malformed dumpfile header 'PK'
[root@svn-server ~]# unzip my-project-bkup-r0_6-20120604000034.dump.zip
Archive: my-project-bkup-r0_6-20120604000034.dump.zip
inflating: my-project-bkup-r0_6-20120604000034.dump
# Create an empty svn repo for my-new-project
[root@svn-server ~]# svnadmin load /opt/csvn/data/repositories/my-new-project < /opt/csvn/data/dumps/my-project/my-project-bkup-r0_6-20120604000034.dump
<<< Started new transaction, based on original revision 1* adding path : branches ... done.
* adding path : tags ... done.
* adding path : trunk ... done.
------- Committed revision 1 >>>
<<< Started new transaction, based on original revision 2
* adding path : trunk/ActionTypes-Report.aspx ... done.
* adding path : trunk/ActionTypes-Report.aspx.vb ... done.
* adding path : trunk/Images ... done.
* adding path : trunk/Images/icon-calendar.gif ... done.
* adding path : trunk/Images/icon-cancel.gif ... done.
------- Committed revision 2 >>>
<<< Started new transaction, based on original revision 3
* editing path : trunk/Images/icon-calendar.gif ... done.
------- Committed revision 3 >>>
<<< Started new transaction, based on original revision 4
* editing path : trunk/ActionTypes-Report.aspx ... done.
------- Committed revision 4 >>>
<<< Started new transaction, based on original revision 5
* editing path : trunk/ActionTypes-Report.aspx ... done.
------- Committed revision 5 >>>
<<< Started new transaction, based on original revision 6
* adding path : trunk/foo.sh ... done.
------- Committed revision 6 >>>
Example 2: svnadmin load from a subversion backup full dump file with new parent-dir
# Create an empty svn repo for my-new-project, with projects/demo folder under svn repository root
[root@svn-server ~]# svnadmin load /opt/csvn/data/repositories/my-new-project --parent-dir projects/demo < /opt/csvn/data/dumps/my-project/my-project-bkup-r0_6-20120604000034.dump
<<< Started new transaction, based on original revision 1* adding path : projects/demo/branches ... done.
* adding path : projects/demo/tags ... done.
* adding path : projects/demo/trunk ... done.
------- Committed new rev 2 (loaded from original rev 1) >>>
<<< Started new transaction, based on original revision 2
* adding path : projects/demo/trunk/ActionTypes-Report.aspx ... done.
* adding path : projects/demo/trunk/ActionTypes-Report.aspx.vb ... done.
* adding path : projects/demo/trunk/Images ... done.
* adding path : projects/demo/trunk/Images/icon-calendar.gif ... done.
* adding path : projects/demo/trunk/Images/icon-cancel.gif ... done.
------- Committed new rev 3 (loaded from original rev 2) >>>
<<< Started new transaction, based on original revision 3
* editing path : projects/demo/trunk/Images/icon-calendar.gif ... done.
------- Committed new rev 4 (loaded from original rev 3) >>>
<<< Started new transaction, based on original revision 4
* editing path : projects/demo/trunk/ActionTypes-Report.aspx ... done.
------- Committed new rev 5 (loaded from original rev 4) >>>
<<< Started new transaction, based on original revision 5
* editing path : projects/demo/trunk/ActionTypes-Report.aspx ... done.
------- Committed new rev 6 (loaded from original rev 5) >>>
<<< Started new transaction, based on original revision 6
* adding path : projects/demo/trunk/foo.sh ... done.
------- Committed new rev 7 (loaded from original rev 6) >>>
Note:
In case, you received error message as below
svnadmin: E160013: File not found: transaction '1-1', path 'projects/demo',
please run below "svn mkdir" command
/opt/csvn/bin/svn mkdir https://<svn-repo-server>/svn/my-new-project/projects/demo -m "import under projects/demo folder"
Saturday, October 27, 2012
Enterprise Linux: Auto sign custom RPM package with GPG key
[root@linux64-rpm-build-server ~]# yum install expect.x86_64
[buildmaster@linux64-rpm-build-server ~]$ cat ~/.rpmmacros
%_topdir %(echo $HOME)/rpmbuild
%_signature gpg
%_gpg_name Build Master
[buildmaster@linux64-rpm-build-server ~]$ cat /tmp/rpm-sign.exp
#!/usr/bin/expect -f
### rpm-sign.exp -- Sign RPMs by sending the passphrase.
spawn rpm --addsign {*}$argv
expect -exact "Enter pass phrase: "
send -- "<your_gpg_secret_key>\r"
expect eof
## end of rpm-sign.exp
[buildmaster@linux64-rpm-build-server ~]$ /tmp/rpm-sign.exp /<full_path_to_the_custom_RPM_package>
[buildmaster@linux64-rpm-build-server ~]$ cat ~/.rpmmacros
%_topdir %(echo $HOME)/rpmbuild
%_signature gpg
%_gpg_name Build Master
[buildmaster@linux64-rpm-build-server ~]$ cat /tmp/rpm-sign.exp
#!/usr/bin/expect -f
### rpm-sign.exp -- Sign RPMs by sending the passphrase.
spawn rpm --addsign {*}$argv
expect -exact "Enter pass phrase: "
send -- "<your_gpg_secret_key>\r"
expect eof
## end of rpm-sign.exp
[buildmaster@linux64-rpm-build-server ~]$ /tmp/rpm-sign.exp /<full_path_to_the_custom_RPM_package>
Saturday, October 6, 2012
Enterprise Linux: Generate GPG key
[buildmaster@linux64-rpm-build-server ~]$ cd
[buildmaster@linux64-rpm-build-server ~]$ mkdir .gnupg
[buildmaster@linux64-rpm-build-server ~]$ gpg --gen-key
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
gpg: keyring `/home/buildmaster/.gnupg/secring.gpg' created
gpg: keyring `/home/buildmaster/.gnupg/pubring.gpg' created
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: Build Master
Email address: buildmaster@my-company-name.com
Comment: RPM Development
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.<your_gpg_secret_key>
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
++++++++++.+++++++++++++++.+++++++++++++++++++++++++++++++++++.+++++++++++++++.++++++++++.+++++.++++++++++++++++++++++++++++++++++++++++>++++++++++.............<+++++......................>+++++..............+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.+++++++++++++++++++++++++.....+++++.+++++.+++++++++++++++.+++++.+++++.++++++++++++++++++++...+++++++++++++++.+++++++++++++++.++++++++++++++++++++++++++++++++++++++++>+++++>.+++++<+++++...............................>+++++.......<..+++++..+++++^^^
gpg: /home/buildmaster/.gnupg/trustdb.gpg: trustdb created
gpg: key 49A8C4DE marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 1024D/49A8C4DE 2012-05-26
Key fingerprint = 914C 356A 2C59 3FE1 C602 B650 9A8F 0821 49A8 C4DE
uid Build Master <buildmaster@my-company-name.com>
sub 2048g/60FA8C11 2012-05-26
[buildmaster@linux64-rpm-build-server ~]$
[buildmaster@linux64-rpm-build-server ~]$ gpg --list-keys
/home/buildmaster/.gnupg/pubring.gpg
---------------------------------
pub 1024D/49A8C4DE 2012-05-26
uid Build Master <buildmaster@my-company-name.com>
sub 2048g/60FA8C11 2012-05-26
[buildmaster@linux64-rpm-build-server ~]$ gpg --export -a 'Build Master' > MYCOMPANY-RPM-GPG-KEY
[buildmaster@linux64-rpm-build-server ~]$ file MYCOMPANY-RPM-GPG-KEY
MYCOMPANY-RPM-GPG-KEY: PGP armored data public key block
[buildmaster@linux64-rpm-build-server ~]$ echo "%_signature gpg" >> ~/.rpmmacros
[buildmaster@linux64-rpm-build-server ~]$ echo "%_gpg_name Build Master" >> ~/.rpmmacros
[buildmaster@linux64-rpm-build-server ~]$ cat ~/.rpmmacros
%_signature gpg
%_gpg_name Build Master
[buildmaster@linux64-rpm-build-server ~]$ mkdir .gnupg
[buildmaster@linux64-rpm-build-server ~]$ gpg --gen-key
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
gpg: keyring `/home/buildmaster/.gnupg/secring.gpg' created
gpg: keyring `/home/buildmaster/.gnupg/pubring.gpg' created
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: Build Master
Email address: buildmaster@my-company-name.com
Comment: RPM Development
You selected this USER-ID:
"Build Master (RPM Development) <buildmaster@my-company-name.com>"Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.<your_gpg_secret_key>
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
++++++++++.+++++++++++++++.+++++++++++++++++++++++++++++++++++.+++++++++++++++.++++++++++.+++++.++++++++++++++++++++++++++++++++++++++++>++++++++++.............<+++++......................>+++++..............+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.+++++++++++++++++++++++++.....+++++.+++++.+++++++++++++++.+++++.+++++.++++++++++++++++++++...+++++++++++++++.+++++++++++++++.++++++++++++++++++++++++++++++++++++++++>+++++>.+++++<+++++...............................>+++++.......<..+++++..+++++^^^
gpg: /home/buildmaster/.gnupg/trustdb.gpg: trustdb created
gpg: key 49A8C4DE marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 1024D/49A8C4DE 2012-05-26
Key fingerprint = 914C 356A 2C59 3FE1 C602 B650 9A8F 0821 49A8 C4DE
uid Build Master <buildmaster@my-company-name.com>
sub 2048g/60FA8C11 2012-05-26
[buildmaster@linux64-rpm-build-server ~]$
[buildmaster@linux64-rpm-build-server ~]$ gpg --list-keys
/home/buildmaster/.gnupg/pubring.gpg
---------------------------------
pub 1024D/49A8C4DE 2012-05-26
uid Build Master <buildmaster@my-company-name.com>
sub 2048g/60FA8C11 2012-05-26
[buildmaster@linux64-rpm-build-server ~]$ gpg --export -a 'Build Master' > MYCOMPANY-RPM-GPG-KEY
[buildmaster@linux64-rpm-build-server ~]$ file MYCOMPANY-RPM-GPG-KEY
MYCOMPANY-RPM-GPG-KEY: PGP armored data public key block
[buildmaster@linux64-rpm-build-server ~]$ echo "%_signature gpg" >> ~/.rpmmacros
[buildmaster@linux64-rpm-build-server ~]$ echo "%_gpg_name Build Master" >> ~/.rpmmacros
[buildmaster@linux64-rpm-build-server ~]$ cat ~/.rpmmacros
%_signature gpg
%_gpg_name Build Master
Saturday, September 22, 2012
Puppet Deployment: MCollective in Puppet 3.x
Puppet master/agent deployment approach is a pull-based mode (by default) fetching the master node controlled catalog to target agent nodes and apply to target agent nodes periodically (30 minutes, by default).
Puppet 2.7 Out-Of-Box puppet kick (Remotely control puppet agent) has been deprecated in Puppet 3.0.
The Marionette Collective (MCollective for short) is a tool for system administration. It can run commands on large numbers of servers in parallel, and uses a broadcast architecture so that you can administer a large network without the need for a central master server or asset database.
Each node runs an MCollective daemon that listens for requests, and can execute commands locally or return information about the server. This can be used to filter the list of target nodes. So, for example, you could use MCollective to execute a given command on all nodes that match certain criteria. You can think of MCollective as a complement to Puppet.
For example, your provisioning process for a new node might require firewall changes on other machines, permissions granted on a database server, and so on, which is not very easy to do with Puppet. Although you could automate specific jobs using shell scripts and SSH, MCollective provides a powerful and flexible way to solve this general problem.
In order to have a Puppet master/agent deployment infrastructure with a push-based mode and deploy the master nodes controlled catalog into target agent nodes on demand.
Here is the puppet 3.0.2 + mcollective configuration example to achieve a Puppet master/agent deployment infrastructure in a push-mode mode:
1. Within a Puppet master/agent deployment infrastrucutre with cert sign (make sure all of puppet nodes sync with Network Time Protocol otherwise there will be some difficulties to do puppet cert sign)
2. On puppet agent nodes, configured puppet agent service to non-daemonized
3. Installation of RPMs:
Puppet 2.7 Out-Of-Box puppet kick (Remotely control puppet agent) has been deprecated in Puppet 3.0.
The Marionette Collective (MCollective for short) is a tool for system administration. It can run commands on large numbers of servers in parallel, and uses a broadcast architecture so that you can administer a large network without the need for a central master server or asset database.
Each node runs an MCollective daemon that listens for requests, and can execute commands locally or return information about the server. This can be used to filter the list of target nodes. So, for example, you could use MCollective to execute a given command on all nodes that match certain criteria. You can think of MCollective as a complement to Puppet.
For example, your provisioning process for a new node might require firewall changes on other machines, permissions granted on a database server, and so on, which is not very easy to do with Puppet. Although you could automate specific jobs using shell scripts and SSH, MCollective provides a powerful and flexible way to solve this general problem.
Here is the puppet 3.0.2 + mcollective configuration example to achieve a Puppet master/agent deployment infrastructure in a push-mode mode:
1. Within a Puppet master/agent deployment infrastrucutre with cert sign (make sure all of puppet nodes sync with Network Time Protocol otherwise there will be some difficulties to do puppet cert sign)
2. On puppet agent nodes, configured puppet agent service to non-daemonized
3. Installation of RPMs:
- yum install activemq activemq-info-provider on a middle-ware node
- yum install mcollective mcollective-client mcollective-puppet-agent mcollective-puppet-client on mcollective client node where the requests come from
- yum install mcollective mcollective-puppet-agent on puppet agent nodes
4. Configuration
cat /etc/mcollective/server.cfg
# main config
libdir = /usr/libexec/mcollective
logfile = /var/log/mcollective.log
loglevel = info
daemonize = 1
# connector plugin config
connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = <activemq_middle-ware_node>
plugin.activemq.pool.1.port = 61613
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = secret
# facts
factsource = yaml
plugin.yaml = /etc/mcollective/facts.yaml
# Plugins
securityprovider = psk
plugin.psk = unset
# puppet
plugin.puppet.command = puppet agent
plugin.puppet.splay = true
plugin.puppet.splaylimit = 30
plugin.puppet.config = /etc/puppet/puppet.conf
plugin.puppet.resource_allow_managed_resources = true
5. mcollective command with puppet plugin
[root@linux64-client ~]# mco puppet runonce -v
Discovering hosts using the mc method for 2 second(s) .... 2
* [ ============================================================> ] 2 / 2
linux64-node2 : OK
{:summary=> "Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command"}
linux64-client : OK
{:summary=> "Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command"}
---- rpc stats ----
Nodes: 2 / 2
Pass / Fail: 2 / 0
Start Time: Tue May 14 21:58:51 -0400 2013
Discovery Time: 2015.99ms
Agent Time: 1148.63ms
Total Time: 3164.62ms
[root@linux64-client ~]# mco puppet status linux64-node2 -v
Discovering hosts using the mc method for 2 second(s) .... 2
* [ ============================================================> ] 2 / 2
linux64-client: Currently stopped; last completed run 12 seconds ago
linux64-node2: Currently applying a catalog; last completed run 9 minutes 32 seconds ago
Summary of Applying:
true = 1
false = 1
Summary of Daemon Running:
running = 1
stopped = 1
Summary of Enabled:
enabled = 2
Summary of Idling:
false = 2
Summary of Status:
stopped = 1
applying a catalog = 1
---- rpc stats ----
Nodes: 2 / 2
Pass / Fail: 2 / 0
Start Time: Tue May 14 21:59:31 -0400 2013
Discovery Time: 2015.43ms
Agent Time: 50.95ms
Total Time: 2066.38ms
- make mcollective daemon is up running on all of nodes
- example of /etc/mcollective/server.cfg
cat /etc/mcollective/server.cfg
# main config
libdir = /usr/libexec/mcollective
logfile = /var/log/mcollective.log
loglevel = info
daemonize = 1
# connector plugin config
connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = <activemq_middle-ware_node>
plugin.activemq.pool.1.port = 61613
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = secret
# facts
factsource = yaml
plugin.yaml = /etc/mcollective/facts.yaml
# Plugins
securityprovider = psk
plugin.psk = unset
# puppet
plugin.puppet.command = puppet agent
plugin.puppet.splay = true
plugin.puppet.splaylimit = 30
plugin.puppet.config = /etc/puppet/puppet.conf
plugin.puppet.resource_allow_managed_resources = true
5. mcollective command with puppet plugin
[root@linux64-client ~]# mco puppet runonce -v
Discovering hosts using the mc method for 2 second(s) .... 2
* [ ============================================================> ] 2 / 2
linux64-node2 : OK
{:summary=> "Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command"}
linux64-client : OK
{:summary=> "Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command"}
---- rpc stats ----
Nodes: 2 / 2
Pass / Fail: 2 / 0
Start Time: Tue May 14 21:58:51 -0400 2013
Discovery Time: 2015.99ms
Agent Time: 1148.63ms
Total Time: 3164.62ms
[root@linux64-client ~]# mco puppet status linux64-node2 -v
Discovering hosts using the mc method for 2 second(s) .... 2
* [ ============================================================> ] 2 / 2
linux64-client: Currently stopped; last completed run 12 seconds ago
linux64-node2: Currently applying a catalog; last completed run 9 minutes 32 seconds ago
Summary of Applying:
true = 1
false = 1
Summary of Daemon Running:
running = 1
stopped = 1
Summary of Enabled:
enabled = 2
Summary of Idling:
false = 2
Summary of Status:
stopped = 1
applying a catalog = 1
---- rpc stats ----
Nodes: 2 / 2
Pass / Fail: 2 / 0
Start Time: Tue May 14 21:59:31 -0400 2013
Discovery Time: 2015.43ms
Agent Time: 50.95ms
Total Time: 2066.38ms
Saturday, September 8, 2012
Puppet Deployment: puppet kick in Puppet 2.7
Puppet master/agent deployment approach is a pull-based mode (be default) fetching the master node controlled catalog to target agent nodes and apply to target agent nodes periodically (30 minuts, by default).
Puppet 2.7 Out-Of-Box puppet kick (Remotely control puppet agent) needs puppet agent on the target node to be running as a daemon, be configured to listen for incoming network connection, and have an appropriate security configuration.
In order to have a Puppet master/agent deployment infrastructure with a push-based mode and deploy the master nodes controlled catalog into target agent nodes on demand.
Here is my puppet kick configuration example to achieve a Puppet master/agent deployment infrastructure in a push-mode mode:
1. Within a Puppet master/agent deployment infrastrucutre with cert sign (make sure all of puppet nodes sync with Network Time Protocol otherwise there will be some difficulties to do puppet cert sign)
2. On puppet agent nodes, snippets of /etc/puppet/auth.conf and /etc/puppet/puppet.conf
Puppet 2.7 Out-Of-Box puppet kick (Remotely control puppet agent) needs puppet agent on the target node to be running as a daemon, be configured to listen for incoming network connection, and have an appropriate security configuration.
In order to have a Puppet master/agent deployment infrastructure with a push-based mode and deploy the master nodes controlled catalog into target agent nodes on demand.
Here is my puppet kick configuration example to achieve a Puppet master/agent deployment infrastructure in a push-mode mode:
1. Within a Puppet master/agent deployment infrastrucutre with cert sign (make sure all of puppet nodes sync with Network Time Protocol otherwise there will be some difficulties to do puppet cert sign)
2. On puppet agent nodes, snippets of /etc/puppet/auth.conf and /etc/puppet/puppet.conf
cat /etc/puppet/auth.conf
path /run
method save
auth no
allow <puppet-master-node>
cat /etc/puppet/puppet.conf
...
[agent]
...
listen = true
ignorecache = true
...
3. Trigger puppet kick from puppet master catalog to multiple puppet target nodes
puppet kick --host <puppet_agent_node>
Triggering <puppet_agent_node>
Getting status
status is success
<puppet_agent_node> finished with exit code 0
Finished
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 -aLinux 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
Saturday, July 28, 2012
Enterprise Linux: Build a binary RPM package
# Build el5 RPM from el5 OS
# root setup rpm build requires RPMs - redhat-rpm-config, rpm-build on EL5:
[root@linux.el5.x86_64-rpm-server ~]# uname -aLinux linux64-rpm-server 2.6.32-100.0.19.el5 #1 SMP Fri Sep 17 17:51:41 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@linux.el5.x86_64-rpm-server ~]# rpmbuild --version
RPM version 4.4.2.3
[root@linux.el5.x86_64-rpm-server ~]# yum install redhat-rpm-config
Loaded plugins: security
Setting up Install Process
Package redhat-rpm-config-8.0.45-32.0.1.el5.noarch already installed and latest version
Nothing to do
[root@linux.el5.x86_64-rpm-server ~]# yum install rpm-build
Loaded plugins: security
Setting up Install Process
Package rpm-build-4.4.2.3-18.el5.x86_64 already installed and latest version
Nothing to do
# none root user (i.e. rpm_build_user) setup RPM build environment:
su - rpm_build_user[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ mkdir -p ~/rpmbuild/RPMS/{noarch,i686,x86_64}
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
[rpm_build_user@linux.el5.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 Jul 28 2012 <rpm_build_user> <rpm_build_user@rpm_build_user.com>
- Initial Spec File
# RPM spec file location
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ find /home/rpm_build_user/rpmbuild/home/rpm_build_user/rpmbuild
/home/rpm_build_user/rpmbuild/RPMS
/home/rpm_build_user/rpmbuild/RPMS/x86_64
/home/rpm_build_user/rpmbuild/RPMS/i386
/home/rpm_build_user/rpmbuild/RPMS/noarch
/home/rpm_build_user/rpmbuild/BUILD
/home/rpm_build_user/rpmbuild/SOURCES
/home/rpm_build_user/rpmbuild/SPECS
/home/rpm_build_user/rpmbuild/SPECS/<software_name>.spec
/home/rpm_build_user/rpmbuild/SRPMS
# build RPM binary package
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ rpmbuild -bb /home/rpm_build_user/rpmbuild/SPECS/<software_name>.spec --target <noarch|i686|x86_64>Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.27208
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.27208
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.27208
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: <software_name>-<software_version>-<software_release>
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
Wrote: /home/rpm_build_user/rpmbuild/RPMS/noarch/<software_name>-<software_version>-<software_release>.<noarch | i686 | x86_64>.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.88637
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ exit 0
# query installed rpm package information
[root@linux.el5.x86_64-dev-server ~]# rpm -qi <software_name>Name : <software_name> Relocations: /usr/local
Version : <software_version> Vendor: <vendor_name>
Release : <software_release> Build Date: Sat 28 Jul 2012 03:28:58 PM EDT
Install Date: Sat 28 Jul 2012 03:32:54 PM EDT Build Host: linux.el5.x86_64-rpm-server
Group : <Server | Application> Source RPM: <software_name>-<software_version>-<software_release>.<noarch | i686 | x86_64>.src.rpm
Size : 17173222 License: <Commercial | Free>
Signature : (none)
URL : <vendor_url>
Summary : <software_name>-<software_version>-<software_release>.<noarch | i686 | x86_64>
Description :
This RPM contains <software_name> from <vendor_name>
Subscribe to:
Posts (Atom)