特殊:Badtitle/NS100:UpdatingADeb:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Oneleaf留言 | 贡献
无编辑摘要
Wikibot留言 | 贡献
无编辑摘要
第2行: 第2行:
{{Languages|UbuntuHelp:UpdatingADeb}}
{{Languages|UbuntuHelp:UpdatingADeb}}
This howto explains how to rebuild yourself software that is packaged in ubuntu.
This howto explains how to rebuild yourself software that is packaged in ubuntu.
Reasons for rebuilding a package that is already in ubuntu:
Reasons for rebuilding a package that is already in ubuntu:
 
* apply a patch
** apply a patch
* use a version that doesn't have a .deb
** use a version that doesn't have a .deb
* use different build options, in the uncommon case optional features were disabled.
** use different build options, in the uncommon case optional features were disabled.
 
This is roughly based on BuildingWineFromSource.  It is the basic commands needed for the simple cases.  Not everything is simple, so it may or may not work for any one package. Once you are fluent with this you may want to contribute your packages, or even package software that never was in ubuntu. For more information about this, see the [https://wiki.ubuntu.com/MOTU Masters of the universe] site, and the [https://wiki.ubuntu.com/MOTU/School MOTU school] there.
This is roughly based on BuildingWineFromSource.  It is the basic commands needed for the simple cases.  Not everything is simple, so it may or may not work for any one package. Once you are fluent with this you may want to contribute your packages, or even package software that never was in ubuntu. For more information about this, see the [https://wiki.ubuntu.com/MOTU Masters of the universe] site, and the [https://wiki.ubuntu.com/MOTU/School MOTU school] there.
----
----
=== Install the build dependencies ===
=== Install the build dependencies ===
The purpose of this step is to install any dependencies necessary to the build process.
The purpose of this step is to install any dependencies necessary to the build process.
<pre><nowiki>
<pre><nowiki>
sudo apt-get build-dep <package>
sudo apt-get build-dep <package>
第22行: 第15行:
</nowiki></pre>
</nowiki></pre>
=== Download the source ===
=== Download the source ===
<pre><nowiki>
<pre><nowiki>
mkdir src; cd src
mkdir src; cd src
第28行: 第20行:
cd <newly created dir>  
cd <newly created dir>  
</nowiki></pre>
</nowiki></pre>
At this point, I generally do the "Build Time!" process now to make sure everything is in order.
At this point, I generally do the "Build Time!" process now to make sure everything is in order.
Sometimes the reason you're building from source is because you need to patch the stock release.  Now is when you do that.
Sometimes the reason you're building from source is because you need to patch the stock release.  Now is when you do that.
<pre><nowiki>
<pre><nowiki>
patch -p1 < SomePackagePatch.patch
patch -p1 < SomePackagePatch.patch
</nowiki></pre>
</nowiki></pre>
For the bold, using the vanilla source isn't hard.  If you are lucky, there is a debian dir that has everything you need to just do Build Time!  otherwise, I have been able to copy the debian/ dir to the source tree and build from there.  (how dangerous is this?)   
For the bold, using the vanilla source isn't hard.  If you are lucky, there is a debian dir that has everything you need to just do Build Time!  otherwise, I have been able to copy the debian/ dir to the source tree and build from there.  (how dangerous is this?)   
Be sure to update debian/control so that your new package gets a proper version number. This will prevent it from being upgraded to the original ubuntu version. This command will do it semi-automatically:
Be sure to update debian/control so that your new package gets a proper version number. This will prevent it from being upgraded to the original ubuntu version. This command will do it semi-automatically:
<pre><nowiki>
<pre><nowiki>
第43行: 第31行:
</nowiki></pre>
</nowiki></pre>
Change version number in the first line to something like 0.8.3-svn-158, or like <previous-version>.customised.1; then add some comment.
Change version number in the first line to something like 0.8.3-svn-158, or like <previous-version>.customised.1; then add some comment.
=== Build time! ===
=== Build time! ===
<pre><nowiki>
<pre><nowiki>
dpkg-buildpackage -rfakeroot -us -uc -b
dpkg-buildpackage -rfakeroot -us -uc -b
</nowiki></pre>
</nowiki></pre>
=== Install the new deb ===
=== Install the new deb ===
The build process will create one or more .deb(s) in the parent directory.  
The build process will create one or more .deb(s) in the parent directory.  
Install the new package.  (package name may be funky - if you got this far you can figure it out.)
Install the new package.  (package name may be funky - if you got this far you can figure it out.)
<pre><nowiki>
<pre><nowiki>
sudo debi
sudo debi
</nowiki></pre>
</nowiki></pre>
=== Clean up ===
=== Clean up ===
Once you're satisfied that <package> is working properly, you can now clean up the files used for building, as this frees up quite a bit of disk. Of course, deleting make's working files will mean that if you need to rebuild, make will have to start right from the beginning.
Once you're satisfied that <package> is working properly, you can now clean up the files used for building, as this frees up quite a bit of disk. Of course, deleting make's working files will mean that if you need to rebuild, make will have to start right from the beginning.
----
----
第69行: 第49行:
gocr
gocr
spe
spe
mplayer maintains the debian/ dir as part of it's source, so no need for <code><nowiki>apt-get source mplayer</nowiki></code> and shuffling files around, just
mplayer maintains the debian/ dir as part of it's source, so no need for <code><nowiki>apt-get source mplayer</nowiki></code> and shuffling files around, just
<pre><nowiki> svn co svn://svn.mplayerhq.hu/mplayer/trunk
<pre><nowiki> svn co svn://svn.mplayerhq.hu/mplayer/trunk
第75行: 第54行:
dpkg-buildpackage -rfakeroot -uc -b
dpkg-buildpackage -rfakeroot -uc -b
</nowiki></pre>  
</nowiki></pre>  
----
----
Script that tries to do the whole process, you need to tweak the few things at the top.  I left in what works for various packages I have used this on.
Script that tries to do the whole process, you need to tweak the few things at the top.  I left in what works for various packages I have used this on.
<pre><nowiki>
<pre><nowiki>
# updeb.sh
# updeb.sh
# updates a deb.  well, makes a deb from current source.
# updates a deb.  well, makes a deb from current source.
# based on https://help.ubuntu.com/community/UpdatingADeb
# based on https://help.ubuntu.com/community/UpdatingADeb
set -xe
set -xe
# ----------------------------------
# ----------------------------------
第106行: 第81行:
# cd qemu
# cd qemu
# ----------------------------------
# ----------------------------------
# DEBFULLNAME="Carl Karsten"
# DEBFULLNAME="Carl Karsten"
mkdir $PACKAGE  
mkdir $PACKAGE  
cd $PACKAGE
cd $PACKAGE
# needed to get source, compile and build debs
# needed to get source, compile and build debs
sudo apt-get --assume-yes install build-essential fakeroot subversion cvs dpkg-dev devscripts
sudo apt-get --assume-yes install build-essential fakeroot subversion cvs dpkg-dev devscripts
# get the $PACKAGE deps and source from apt repository  
# get the $PACKAGE deps and source from apt repository  
# (and debian/ dir needed to build the .deb)
# (and debian/ dir needed to build the .deb)
sudo apt-get --assume-yes build-dep $PACKAGE
sudo apt-get --assume-yes build-dep $PACKAGE
apt-get source $PACKAGE
apt-get source $PACKAGE
# cd into the apt-got dir.  
# cd into the apt-got dir.  
# this will need to be changed as the version changes.
# this will need to be changed as the version changes.
# this is a hack.  not sure how else to figure out what to cd into
# this is a hack.  not sure how else to figure out what to cd into
cd $PACKAGE*  
cd $PACKAGE*  
exit
exit
# hide the apt-got source
# hide the apt-got source
# mv $SRCDIR $SRCDIR.apt-got
# mv $SRCDIR $SRCDIR.apt-got
# get working copy
# get working copy
$GETSRCCMD
$GETSRCCMD
# bump the version number
# bump the version number
# if this is not done, the new deb will be the same version as the current, so won't install. ($0 is the name of this script)
# if this is not done, the new deb will be the same version as the current, so won't install. ($0 is the name of this script)
debchange --nmu $0
debchange --nmu $0
# build the .deb
# build the .deb
dpkg-buildpackage -rfakeroot -uc -b
dpkg-buildpackage -rfakeroot -uc -b
# install the deb.  
# install the deb.  
# using this command, on your own :)
# using this command, on your own :)

2007年11月30日 (五) 22:01的版本

{{#ifexist: :UpdatingADeb/zh | | {{#ifexist: UpdatingADeb/zh | | {{#ifeq: {{#titleparts:UpdatingADeb|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:UpdatingADeb|1|-1|}} | zh | | }}

This howto explains how to rebuild yourself software that is packaged in ubuntu. Reasons for rebuilding a package that is already in ubuntu:

  • apply a patch
  • use a version that doesn't have a .deb
  • use different build options, in the uncommon case optional features were disabled.

This is roughly based on BuildingWineFromSource. It is the basic commands needed for the simple cases. Not everything is simple, so it may or may not work for any one package. Once you are fluent with this you may want to contribute your packages, or even package software that never was in ubuntu. For more information about this, see the Masters of the universe site, and the MOTU school there.


Install the build dependencies

The purpose of this step is to install any dependencies necessary to the build process.

sudo apt-get build-dep <package>
sudo apt-get install build-essential fakeroot devscripts

Download the source

mkdir src; cd src
apt-get source <package>
cd <newly created dir> 

At this point, I generally do the "Build Time!" process now to make sure everything is in order. Sometimes the reason you're building from source is because you need to patch the stock release. Now is when you do that.

patch -p1 < SomePackagePatch.patch

For the bold, using the vanilla source isn't hard. If you are lucky, there is a debian dir that has everything you need to just do Build Time! otherwise, I have been able to copy the debian/ dir to the source tree and build from there. (how dangerous is this?) Be sure to update debian/control so that your new package gets a proper version number. This will prevent it from being upgraded to the original ubuntu version. This command will do it semi-automatically:

debchange -i

Change version number in the first line to something like 0.8.3-svn-158, or like <previous-version>.customised.1; then add some comment.

Build time!

dpkg-buildpackage -rfakeroot -us -uc -b

Install the new deb

The build process will create one or more .deb(s) in the parent directory. Install the new package. (package name may be funky - if you got this far you can figure it out.)

sudo debi

Clean up

Once you're satisfied that <package> is working properly, you can now clean up the files used for building, as this frees up quite a bit of disk. Of course, deleting make's working files will mean that if you need to rebuild, make will have to start right from the beginning.


used this for: wine pidgin gocr spe mplayer maintains the debian/ dir as part of it's source, so no need for apt-get source mplayer and shuffling files around, just

 svn co svn://svn.mplayerhq.hu/mplayer/trunk
cd trunk
dpkg-buildpackage -rfakeroot -uc -b

Script that tries to do the whole process, you need to tweak the few things at the top. I left in what works for various packages I have used this on.

# updeb.sh
# updates a deb.  well, makes a deb from current source.
# based on https://help.ubuntu.com/community/UpdatingADeb
set -xe
# ----------------------------------
PACKAGE=spe
SRCDIR=_spe
GETSRCCMD="svn checkout svn://svn.berlios.de/python/$PACKAGE/trunk/_spe"
# ----------------------------------
# PACKAGE=gocr
SRCDIR=src
GETSRCCMD="cvs -d:pserver:[email protected]:/cvsroot/jocr login && cvs -z3 -d:pserver:[email protected]:/cvsroot/jocr co -P jocr/src"
# ----------------------------------
PACKAGE=python-kinterbasdb
SRCDIR=src
GETSRCCMD=" cvs -d:pserver:[email protected]:/cvsroot/kinterbasdb login && cvs -z3 -d:pserver:[email protected]:/cvsroot/kinterbasdb co -P Kinterbasdb-3.0 ./"
# -----------------
PACKAGE=qemu
SRCDIR=#_spe
GETSRCCMD="cvs -z3 -d:pserver:[email protected]:/sources/qemu co qemu"
# need to move debian/ and cd into the cvs source:
# mv qemu-*/debian qemu/
# cd qemu
# ----------------------------------
# [email protected]
# DEBFULLNAME="Carl Karsten"
mkdir $PACKAGE 
cd $PACKAGE
# needed to get source, compile and build debs
sudo apt-get --assume-yes install build-essential fakeroot subversion cvs dpkg-dev devscripts
# get the $PACKAGE deps and source from apt repository 
# (and debian/ dir needed to build the .deb)
sudo apt-get --assume-yes build-dep $PACKAGE
apt-get source $PACKAGE
# cd into the apt-got dir. 
# this will need to be changed as the version changes.
# this is a hack.  not sure how else to figure out what to cd into
cd $PACKAGE* 
exit
# hide the apt-got source
# mv $SRCDIR $SRCDIR.apt-got
# get working copy
$GETSRCCMD
# bump the version number
# if this is not done, the new deb will be the same version as the current, so won't install. ($0 is the name of this script)
debchange --nmu $0
# build the .deb
dpkg-buildpackage -rfakeroot -uc -b
# install the deb. 
# using this command, on your own :)
echo sudo gdebi $PACKAGE*.deb

CarlKarsten GabrielDePerthuis