I sometimes find I need to build applications from source for use on a live server. I don't like the idea of installing build tools on the server, so I want to create a virtual machine on my desktop to build the applications so all I need to do is install them on the server.
As a specific example, I have an Ubuntu-based mail server using postfix (installed from repositories). However, I need to add virtual mailbox quota support, using the patches here: http://vda.sourceforge.net/
So my theory is that I can create a new Ubuntu VM, install the postfix source package and compile tools, apply the patch, then build the .deb from that to install on the live server, replacing the version in the repositories.
Is that a sensible approach? If yes, although I have a rough idea what is needed I'm on the edge of my knowledge. Once I have the source installed and patched (assuming that the instructions with the patch help me get that far!) how do I then build the .deb, and how to I install it so that it doesn't conflict with the existing package from the repositories?
PS: Rereading the above before posting, it might come across that I'm asking for help setting up the VM - that bit I can do. It's the step sideways from a complete binary install from repositories which is making me nervous!
Mark Rogers
On Thu, Sep 20, 2007 at 10:47:31AM +0100, Mark Rogers wrote:
I sometimes find I need to build applications from source for use on a live server. I don't like the idea of installing build tools on the server, so I want to create a virtual machine on my desktop to build the applications so all I need to do is install them on the server.
As a specific example, I have an Ubuntu-based mail server using postfix (installed from repositories). However, I need to add virtual mailbox quota support, using the patches here: http://vda.sourceforge.net/
So my theory is that I can create a new Ubuntu VM, install the postfix source package and compile tools, apply the patch, then build the .deb from that to install on the live server, replacing the version in the repositories.
Is that a sensible approach? If yes, although I have a rough idea what is needed I'm on the edge of my knowledge. Once I have the source installed and patched (assuming that the instructions with the patch help me get that far!) how do I then build the .deb, and how to I install it so that it doesn't conflict with the existing package from the repositories?
You'll be wanting to learn about how debian packages work, mostly! It's worth reading the developers reference and nm guide from http://www.debian.org/devel/ to get a feel for it, the nm guide is probably going to be the most use to you at this stage.
Basic idea would be to do: apt-get source postfix
Then change in to the directory it's just created, add the patch (depending on the way postfix is packaged it might just be a case of dropping the patch in to the debian/patches directory, otherwise you can probably get away with just using patch in the normal way), then edit the debian/changelog, preferably by using dch -i or similar, and change the version number to something you specific. (dch is in the devscripts package). To build the package use dpkg-buildpackage -rfakeroot.
That should give you a reasonable hint to how to do it, *always* test the packages before going in to production with them, though.
Cheers,
Brett Parker wrote:
You'll be wanting to learn about how debian packages work, mostly! It's worth reading the developers reference and nm guide from http://www.debian.org/devel/ to get a feel for it, the nm guide is probably going to be the most use to you at this stage.
Thanks, I need some bedtime reading anyway!
Basic idea would be to do: apt-get source postfix
Thanks for that and the other hints. I also just found a guide to doing almost exactly what I needed:
http://www.howtoforge.com/virtual_users_and_domains_with_postfix_debian_etch
.. which also helps.
That should give you a reasonable hint to how to do it, *always* test the packages before going in to production with them, though.
Assuming I have built alternative .deb file "postfix_2.3.8-2_i386.deb", and already have postfix 2.3.8 installed from the repos, I know that: dpkg -i postfix_2.3.8-2_i386.deb will install it.
But, if I need to roll back to the original version, how do I do that?
(Next jobs: learn about apt pinning to stop the file being updated, and how to create my own repo to keep the file at.)
Mark Rogers
On Thu, Sep 20, 2007 at 01:01:53PM +0100, Mark Rogers wrote:
Assuming I have built alternative .deb file "postfix_2.3.8-2_i386.deb", and already have postfix 2.3.8 installed from the repos, I know that: dpkg -i postfix_2.3.8-2_i386.deb will install it.
But, if I need to roll back to the original version, how do I do that?
Should be able to do something like: apt-get --reinstall install postfix/stable
Probably. Maybe. Perhaps. ;)
Otherwise downloading the deb from the archive and installing it should work just fine.
Ta,
Mark Rogers mark@quarella.co.uk wrote:
[...] I also just found a guide to doing almost exactly what I needed: http://www.howtoforge.com/virtual_users_and_domains_with_postfix_debian_etch .. which also helps.
Ow. That does far too much as root for my liking. Also, if you give -uc -us flags to dpkg-buildpackage, it won't try to sign things, so won't complain if it can't. Putting stuff like "ignore this message" in a HOWTO makes me think its author hasn't spent much time testing and bugfixing it.
Assuming I have built alternative .deb file "postfix_2.3.8-2_i386.deb", and already have postfix 2.3.8 installed from the repos, I know that: dpkg -i postfix_2.3.8-2_i386.deb will install it.
But, if I need to roll back to the original version, how do I do that?
dpkg -i postfix_2.3.8-1_i386.deb perhaps?
You probably want to call your package 2.3.8-1quarella1 or something, instead of 2, to avoid it conflicting with repository packages. I think some flags to the "dch" command will do that for you, but I forget what they are and I'm rushing, sorry.
Returning to your original question:
So my theory is that I can create a new Ubuntu VM, install the postfix source package and compile tools, apply the patch, then build the .deb from that to install on the live server, replacing the version in the repositories.
Is that a sensible approach? [...]
Well, I'd use cowbuilder and maybe an IP alias to try it in a chroot, instead of building a whole VM. My notes on cowbuilder are http://mjr.towers.org.uk/blog/2007/debian#packaging and I think it's getting pretty common among DDs, so maybe others can offer better tips.
Hope that helps,
MJ Ray wrote:
Ow. That does far too much as root for my liking.
I only used it as a guide, to be fair, but even then most was done as root (via sudo). But then it was done in a virtual machine, partly for that reason.
Also, if you give -uc -us flags to dpkg-buildpackage, it won't try to sign things, so won't complain if it can't. Putting stuff like "ignore this message" in a HOWTO makes me think its author hasn't spent much time testing and bugfixing it.
Fair comment - and this is often the case with HowTos. There's a lot in building a Postfix-based mail server that I find hard to understand[*] (I have books on order but they've not arrived yet), and what I really want is a HowAndWhyTo not just a HowTo.
[*] Not because its complicated, but because the documentation is sparse and scattered. It might also turn out to be complicated once I've learnt enough to know :-)
dpkg -i postfix_2.3.8-1_i386.deb perhaps?
Sounds obvious now... but then I'm something of a dpkg virgin so I'm picking things up as I go.
You probably want to call your package 2.3.8-1quarella1 or something, instead of 2, to avoid it conflicting with repository packages. I think some flags to the "dch" command will do that for you, but I forget what they are and I'm rushing, sorry.
Agreed, but I couldn't see where that was set. I guess -2 was just the default? Brett's comments regarding dch (with a sprinkle of Google no doubt) will help me there too.
Returning to your original question: [...]
Well, I'd use cowbuilder and maybe an IP alias to try it in a chroot, instead of building a whole VM. My notes on cowbuilder are http://mjr.towers.org.uk/blog/2007/debian#packaging and I think it's getting pretty common among DDs, so maybe others can offer better tips.
Thanks for that, I'll take a look.
Mark Rogers
Mark Rogers wrote:
Agreed, but I couldn't see where that was set. I guess -2 was just the default? Brett's comments regarding dch (with a sprinkle of Google no doubt) will help me there too.
Hmmm, well now I've looked at the dch man page I'm none the wiser. I can see how to change the version *number* to pretty much anything I like, but not how to get "postfix_2.3.8-1myname_i386.deb" instead. I'm going to go off and see what I can learn about .deb packages in general, but if anyone can fill that particular blank in for me in the meantime I'd be grateful, as it means I can get my shiny new package installed and tested.
Mark Rogers
Mark Rogers mark@quarella.co.uk wrote:
Hmmm, well now I've looked at the dch man page I'm none the wiser. I can see how to change the version *number* to pretty much anything I like, but not how to get "postfix_2.3.8-1myname_i386.deb" instead. I'm going to go off and see what I can learn about .deb packages in general, but if anyone can fill that particular blank in for me in the meantime I'd be grateful, as it means I can get my shiny new package installed and tested.
Note that dch's version "number" seems to be 2.3.8-1myname in the above example, so I think you could set it with dch -v '2.3.8-1myname'. Or you can just edit the changelog entry directly. Confusing yet flexible.
Hope that helps,
MJ Ray wrote:
Note that dch's version "number" seems to be 2.3.8-1myname in the above example, so I think you could set it with dch -v '2.3.8-1myname'. Or you can just edit the changelog entry directly. Confusing yet flexible.
Hope that helps,
It does help, thanks.
Mark Rogers