Dev Maintenance
Contents
Updating your code
It is best to shut your Apache instance down before doing the update process, to make sure that everything, especially scripts in cgi-bin/ are reloaded properly:
sudo /etc/init.d/apache2 stop
Okay. Let's say you've been running your Dreamwidth install and you want to pull down the latest and greatest in fixes. This is pretty easy.
cd $LJHOME bin/cvsreport.pl -update # only sync changes from the CVS to the live code bin/cvsreport.pl -sync -cvsonly bin/cvsreport.pl -sync -cvsonly
Yes, you do it twice. If the multicvs.conf file changed, then the first one pulls that file in, and the second one will notice whatever changed according to that file. 99% of the time once is enough, but every once in a while... so it's a good habit to have.
# order of commands is important $LJHOME/bin/upgrading/update-db.pl -r -p --innodb $LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb $LJHOME/bin/upgrading/texttool.pl load
Now you can restart Apache:
sudo /etc/init.d/apache2 start
Of course, in a production environment, this whole process is not too recommended as you never know what kind of code you're going to get. But for the most part, it's fairly straightforward. (And if you're doing development, this is generally safe.)
Updating to the production branch
You can see what branch you are currently on by going to $LJHOME/cvs/dw-free
:
cd $LJHOME/cvs/dw-free hg branch
Work is being done on the 'production' branch. When you create a new copy of the repository, it gets the branch with the label 'tip'. This should be the 'production' branch. You can sync to the 'tip' branch by using:
hg update -C tip
If for some reason 'tip' is not pointing to 'production', then you can sync to 'production' manually by doing 'hg update -C production'
To be running production code, you also need to sync to your live code from the repository copy:
bin/cvsreport.pl -sync -cvsonly
Updating your system
On Ubuntu, you can update the packages on your system with:
apt-get update apt-get upgrade
Or, if you want an easy command to run on your dw account in one swoop:
sudo apt-get update && sudo apt-get upgrade
Scripting
You can, of course, use scripts to make it easier for you to do most of this. Some example scripts are given below.
dwu - Updating the repos
Put this code in a file called ~/bin/dwu and make it executable with chmod ugo+x ~/bin/dwu:
#!/bin/bash hg -R $LJHOME/cvs/dw-free qpop -a && \ $LJHOME/bin/cvsreport.pl -u && \ hg -R $LJHOME/cvs/dw-free qpush -a
Now, when you type 'dwu', this script will pop out any MQ patches you may have currently in dw-free, update the code to the latest available, and push your dw-free MQ patches back.
If you need support for dw-nonfree too, just duplicate the lines mentioning dw-free and edit them to say dw-nonfree and make sure that all the lines apart from the first and last end with '&& \':
#!/bin/bash hg -R $LJHOME/cvs/dw-free qpop -a && \ hg -R $LJHOME/cvs/dw-nonfree qpop -a && \ $LJHOME/bin/cvsreport.pl -u && \ hg -R $LJHOME/cvs/dw-free qpush -a && \ hg -R $LJHOME/cvs/dw-nonfree qpush -a
dws - Syncing the live code
Put this code in a file called ~/bin/dws and make it executable with chmod ugo+x ~/bin/dws:
#!/bin/bash $LJHOME/bin/cvsreport.pl -s -c && \ $LJHOME/bin/cvsreport.pl -s -c
This script will synchronise the live code twice when you type 'dws'.
dwdb - Updating the database
Put this code in a file called ~/bin/dwdb and make it executable with chmod ugo+x ~/bin/dwdb:
#!/bin/bash $LJHOME/bin/upgrading/update-db.pl -r -p --innodb && \ $LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb && \ $LJHOME/bin/upgrading/texttool.pl load
This will update the database when you type 'dwdb'.
tocvs - Switch between /cvs and live directories
Put this code in a file called ~/bin/tocvs.real, but do not make it executable:
#!/bin/bash DIR=`pwd` REPO=${1-'dw-free'} if [[ "$REPO" == "f" ]]; then REPO="dw-free"; fi if [[ "$REPO" == "n" ]]; then REPO="dw-nonfree"; fi if [[ "$DIR" =~ ^$LJHOME ]]; then if [[ "$DIR" =~ ^$LJHOME/cvs/([^\/]+) ]]; then FROMREPO=${BASH_REMATCH[1]} if [[ "$1" == "" ]]; then DIR=${DIR/#$LJHOME\/cvs\/$FROMREPO/$LJHOME} else DIR=${DIR/#$LJHOME\/cvs\/$FROMREPO/$LJHOME\/cvs\/$REPO} fi else DIR=${DIR/#$LJHOME/$LJHOME\/cvs\/$REPO} fi fi cd $DIR
Now edit your ~/.bashrc file and add the following line to the end:
alias tocvs="source ~/bin/tocvs.real"
Then, log out and back in for the change to take effect. Now, whenever you're in a code directory, you can use 'tocvs' to switch back and forth from the live directory and the corresponding /cvs directory. It defaults to 'dw-free'; if you wish to go to another repository instead (for example, 'dw-nonfree'), give it as a parameter. (for example, 'tocvs dw-nonfree'). If you specify a repo name while you're already in a repository, it will switch to the named repository.
The repositories 'dw-free' and 'dw-nonfree' are aliased as 'f' and 'n' respectively.