Dev Maintenance

Updating the Dreamwidth 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:

stop-apache                    # for Dreamhacks sudo /etc/init.d/apache2 stop  # for people running their own

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.

If you accidentally write over your config-local.pl file, and you're using a Dreamhack, you will get a DB connect error when you try to run the above update-db.pl commands. In that case, you'll need to fix DBINFO in config-private.pl so that you can connect to the database.

Now you can restart Apache:

start-apache                    # for Dreamhacks sudo /etc/init.d/apache2 start  # for people running their own

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.)

If your installation was before 2010-10-01, you will also want to upgrade it to data version 9.

Updating to the correct branch
Work is being done on the 'default' branch. When you create a new copy of the repository, it automatically updates to the tip of the default branch. This should be the correct tip. You can also sync to the tip by using:

cd $LJHOME/cvs/dw-free hg update -C tip

If for some reason the active branch is not pointing to 'default', then you can sync to 'default' manually by doing 'hg update -C default'. Be careful: the '-C' option will revert any modified files, and you may need to do another tip update after switching branches.

Syncing code to live
To be running production code, you also need to sync to your live code from the repository copy:

bin/cvsreport.pl -sync -cvsonly

You will also want to delete files from your live code that have been deleted from the repository:

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

(Note, you may not need to do this step if you're on a Dreamhack and Sophie or Afuna has already done it for everyone.)

Scripting
You can, of course, use scripts to make it easier for you to do most of this.

There is an "omnibus" script available at http://dw-dev.dreamwidth.org/94822.html which incorporates all the individual scripts listed here and some others functions, and includes help information.

Some simpler 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:

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 '&& \':

dws - Syncing the live code
Put this code in a file called $LJHOME/bin/dws and make it executable with chmod ugo+x $LJHOME/bin/dws:

This script will synchronise the live code twice when you type 'dws', and then remove any stale files that remain in the live code.

dwdb - Updating the database
Put this code in a file called ~/bin/dwdb and make it executable with chmod ugo+x ~/bin/dwdb:

This will update the database when you type 'dwdb'.

tocvs - Switch between /cvs and live directories
As of Jan 13, this is already in the default .bashrc in dreamhacks, so you shouldn't need to add it.

If you don't see the line "alias tocvs="source ~/bin/tocvs.real"" in your ~/.bashrc, you can add the following function yourself:

Then, start a new shell or log in again 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.

Cleaning up your directories
If you do any amount of work, you'll find that your directories get cluttered with .orig and .rej files everywhere. This script will clean those up:

You can run it from the command line, or put it in a file called ~/bin/tidy and make it executable with "chmod +x ~/bin/tidy". If you do that, you'll be able to just type "tidy" to clean house.