[Pkg-dspam-misc] sed script to automatically split configuration file

Julien Valroff julien at kirya.net
Sun Jun 20 19:45:20 UTC 2010


I am trying to automatically split DSPAM main configuration file into
smaller snippets which are shipped in the various packages (eg.
mysql.conf for libdspam7-drv-mysql).

Thanks to Stevan Bajic, I could extract the relevant parts of the
configuration file as follows:

for foo in Hash=hash ExtLookup=extlookup SQLite=sqlite MySQL=mysql PostgreSQL=pgsql;
        sed -n -e "/^#[\t ]\{1,99\}\-\{2,3\}[\t ]\{1,99\}${foo%=*}[\t ]\{1,99\}\-\{2,3\}[\t ]*$/,/^#[\t ]\{1,99\}\-\{2,3\}[\t ]\{1,99\}[^-]\{1,99\}\-\{2,3\}[\t ]*$/ {x;p}" src/dspam.conf.in > debian/config/${foo#*=}.conf;
        sed -i -e '1d' debian/config/${foo#*=}.conf;

I am not a sed guru, and I am sure this can be improved (I haven't been
able to shorten this into a single call to sed).

Now, I am unfrotunately not able to find something that would delete the
extracted parts from the original file.

Any hint?


Julien Valroff <julien at kirya.net>
GPG key: 4096R/290D20C5 
092F 4CB5 5F19 E006 1CFD  B489 D32B 8D66 290D 20C5

More information about the Pkg-dspam-misc mailing list