cloning OpenPKG: configuration

Migrating the configuration is a manual task. The commands below aid you finding out what has been configured.

Query RPM Database for all configuration files

openpkg rpm -qca | grep /

Verify integrity of all files known to the RPM Database and list those with modified MD5 hash

openpkg rpm -Va | egrep "^..5..... "

Show all rc.conf variables, their effective and default value

openpkg rc all config

Query RPM Database to find the package a given file belongs to

openpkg rpm -qf ~/etc/rc.conf

To find out the difference between a file in a package and on the filesystem, it is necessary to find the appropriate package, compute the resulting package file name, extract the file in questions to a temporary location and run diff. This code snippet does it for you. Note it assumes you kept the binary package.

# difffile.sh <file>

myfile="$1"
pkgnam=`openpkg rpm -qf $myfile`
archos=`openpkg rpm --eval '%{l_platform}'`
bintag=`openpkg rpm --eval '%{l_tag}'`
tmpdir=`openpkg rpm --eval '%{l_tmpdir}'`
rpmdir=`openpkg rpm --eval '%{_rpmdir}'`
[ ".$tmpdir" = ".$rpmdir" ] && exit 1
( cd $tmpdir &&
  openpkg rpm2cpio $rpmdir/$pkgnam.$archos-$bintag.rpm | cpio -ivd .$myfile )
diff -U0 $tmpdir/$myfile $myfile

Keep in mind that many files carry the prefix and user/group-names/ids in them. If the target machine differs in one or more of these parameters, all configuration files must be changed. Depending whether your approach is to find the difference between the original package and the original installation and apply it to the target or you prefer copying the configuration files and post-adjust them, you might find shtool subst a useful tool for searching and replacing. Run the following command to replace all occurrences of old with new, using an interactive mode which previews each change and asks whether to apply it or not.

~/lib/openpkg/shtool subst -i -e 's;old;new;g' ~/etc/*/*

Leave a Reply