Creating WordPress Packages
deb http://www.coker.com.au wheezy wordpress
I maintain Debian packages of a number of WordPress themes and plugins for my personal use which I am not planning to upload to Debian due to the maintenance and security issues. Generally the way things work with WordPress packages (and apparently most things in PHP) is that new versions are released whenever the author feels like it with little documentation and often now way of determining whether it’s a security issue. When there is a security issue it’s often fixed in a new version that includes new features giving no good option for someone who was happy with the old functionality and just wants a secure system. This isn’t the way we like to do things in Debian.
The result of this is that I maintain a number of packages for my personal use (and for the benefit of any interested people on the Internet) that often get new updates. I’ve written the below script to create a new version of a Debian package. It searches my repository for the most recent .debian.tar.gz file for the package, applies that, runs dch -i to update the changelog, and then builds the package. So far this has only been tested on one package, I expect that I’ll have to put a sed command in there to cover the case where the zip file name doesn’t match what I want as the package name and I’ll probably find other bugs in future, but I think it’s good enough to publish now.
#!/bin/bash
set -e
REPOSITORY=/home/whatever
unzip $1
FILE=$(basename $1)
PACKAGE=$(echo $FILE | sed -e "s/\..*$//")
LEN=$(($(echo $PACKAGE | wc -c)+1))
VER=$(echo $FILE | cut -c ${LEN}-200 | sed -e s/.zip//)
DIRNAME=wordpress-${PACKAGE}-${VER}
mv $PACKAGE $DIRNAME
tar czf wordpress-${PACKAGE}_${VER}.orig.tar.gz ${DIRNAME}
cd $DIRNAME
tar xzf $(ls -tr ${REPOSITORY}/wordpress-${PACKAGE}_*.debian.tar.gz | tail -1)
dch -i
dpkg-buildpackage
Any suggestions for improvement will be welcome, I don’t claim to be the world’s greatest shell scripter. But please note that I generally aim to write shell scripts that can be understood by people who aren’t experts. So if you can replace the program with a single line of Perl I will be impressed but I won’t implement your solution.
Related posts:
- WordPress Maintainability For a while I’ve been maintaining my own WordPress packages....
- permalinks in wordpress, Apache redirection, and other blog stuff When I first put my new blog online I didn’t...
- WordPress Plugins I’ve just added the WordPress Minify [1] plugin to my...