Dev Week -- Various ways to patch a package - Christophe Sauthier and Didier Roche -- Wed, Sep 3

(04:02:25 PM) didrocks: ok, I think this is the time :)
(04:02:25 PM) didrocks: huats: are you ready?
(04:03:24 PM) didrocks: so, waiting for huats, who is around? :)
(04:03:29 PM) nijaba: o/
(04:03:34 PM) Kurt: o/
(04:04:03 PM) huats: I am here :)
(04:04:05 PM) sebner: \o
(04:04:22 PM) didrocks: great, so, I think there is no need to use -chat for the questions
(04:04:41 PM) didrocks: just ask them here prefixing them with QUESTION:
(04:04:53 PM) didrocks: Welcome to the hands-on training session about how to patch Ubuntu source packages!
(04:05:01 PM) didrocks: First, we really want to thank pitti for his previous sessions on february from which this session is largerly inspired of.
(04:05:04 PM) mcas is now known as mcas_away
(04:05:08 PM) didrocks: this session intends only to go through the different patches system encountered in various packages. It will not teach you how to create a package or what a package is composed of. For this, see dholbach's excellent session on this (
(04:05:21 PM) didrocks: really focus on doing stuffs that we are showing you and not taking notes. This is an hands-on demo! The IRC log will be available at when the session will be over.
(04:05:31 PM) didrocks: please install few packages during the general introduction of what is a patching a source (for that, you have to have the deb-src repository activated in your source.list)
(04:05:41 PM) didrocks: sudo apt-get install dpatch cdbs quilt patchutils devscripts debhelper fakeroot
(04:05:46 PM) didrocks: mkdir patchtraining
(04:05:51 PM) didrocks: cd patchtraining
(04:05:56 PM) didrocks: apt-get source cron udev keepalived ed xterm
(04:06:01 PM) didrocks: wget
(04:06:18 PM) didrocks: chmod 755 dsrc-new-patch
(04:07:49 PM) didrocks: for those who have already followed pitti's sesssion, we are taken the same examples (namely cron, udev, keepalived, ed and xterm) as they are little pacakges which illustrates each one "one way to pach a source".
(04:07:49 PM) didrocks: So, during the dowload time, just a quick introduction
(04:07:49 PM) didrocks: == Why use separate patches? ==
(04:07:49 PM) didrocks: in earlier times, people just applied patches inline (ie. directly in the source code tree).
(04:07:49 PM) didrocks: however a package contains a diff.gz file, showing the differences beetween the pristine source and every modifications made by downstream, this makes it very hard to extract patches later to modify them.
(04:07:49 PM) didrocks: (tell me is I speed to much)
(04:07:49 PM) didrocks: indeed, how to distinguish the patch you wish to extract and the other modifications? How to send simply only your modification to upstream (as their development has gone further since, so every patches aren't good to be applied...)?
(04:07:55 PM) didrocks: also this means that new upstream versions are a pain, since they generate a lot of rejections when applying the package diff.gz to them.
(04:08:17 PM) didrocks: so, using separate patches is clearly a good way to ensure it will be easy for you and for other's to add/remove a patch when it will be no more usefull.
(04:08:18 PM) didrocks: the ideal state is a complete unmodified tarball from upstream, plus the packaging bits in debian/ and all the clean and separate patches in it.
(04:08:31 PM) didrocks: to sum up, that mainly means that "lsdiff -z <sourcepackage>.diff.gz" only contains "debian/"
(04:08:45 PM) didrocks: the first idea was to create regular patch files and store them in debian/patches/. Then, adding some patch/patch -R snippets to debian/rules. This worked for small patches, but provided no tools for editing these patches, updating them for new upstream versions, etc.
(04:09:00 PM) didrocks: this is way several standard patch systems were created. Those are easy enough to use and provide some tools for editing previous patch, applying one or more patch, unapplying others... well... just to play :)
(04:09:19 PM) didrocks: hands on when you will be here and/or if you have questions :)
(04:09:34 PM) sebner: \o/
(04:09:54 PM) didrocks: sebner: is everything ok?
(04:10:04 PM) sebner: didrocks: sure ^^
(04:10:39 PM) didrocks: every downloads are finished?
(04:11:22 PM) huats: didrocks: wait a bit more...
(04:11:32 PM) didrocks: ok huats ;)
(04:11:45 PM) didrocks: if anyone have a question, this is the right time :)
(04:11:58 PM) huats: questions already ?
(04:12:00 PM) huats: ;)
(04:12:26 PM) didrocks: hum, well, everything's fine, so enough speech, time to play! Are you ready to put your hands on? ^^
(04:13:16 PM) didrocks: let's assume yes :D (it is late, let's say that some people will read the log :))
(04:13:17 PM) chombium: \o/
(04:13:27 PM) didrocks: == cron example: inline patches ==
(04:13:35 PM) didrocks: the first package is the simplier one, with no patch system at all. A counter-example against the "old" style of packaging, that you surely not follow appart from the original maintainer use this.
(04:13:50 PM) didrocks: with this "system", we directly edit the code in the source tree, reposing in the fact that those content will be available in the diff.gz, but all mixed together... making this very inconvenient for submitting patches upstream.
(04:14:08 PM) didrocks: ... or reviewing for merges (patch 1 is fixed in the new upstream version, but not patch 2), how to easy know which files to take?
(04:14:25 PM) didrocks: if you do 'lsdiff -z cron*.diff.gz', you see changes which are not in debian/. So, you can see that we have such a package.
(04:14:34 PM) didrocks: (you can try it right now)
(04:14:55 PM) didrocks: you can also take a look at it to see how all patches are lumped together. Can anybody in a second told me to which files corresponds the current statement "Use latest lsb logging functions" in the changelog?
(04:15:31 PM) didrocks: … I am sure, you can't :) No file explicitely declared in the changelog and you will strike…
(04:16:11 PM) didrocks: if you have any question regarding this way of "not patching", this is the right time :)
(04:16:55 PM) didrocks: lsdiff if very great to determine in a diff.gz file has other directories/files than just debian/ one
(04:16:55 PM) huats: does anybody is following ? are we moving too fast ? please tell us right now :)
(04:17:06 PM) Kurt: I'm following :)
(04:17:14 PM) chombium: me too :)
(04:17:23 PM) huats: ok great !
(04:17:37 PM) didrocks: yeah, two people are alive \o/
(04:17:38 PM) huats: sorry didrocks but it was neede I think :)
(04:17:46 PM) sebner: QUESTION: what does the -z option does? *too lazy to search manpage*
(04:17:58 PM) huats: it is for the compression sebner
(04:18:06 PM) didrocks: it tells than the diff file is a gunzip one
(04:18:13 PM) didrocks: so, compressed, yes :)
(04:18:24 PM) sebner: k, thx :)
(04:18:29 PM) sebner: and yes I'm also here ^^
(04:18:46 PM) didrocks: just look again at the diff.gz to see how packaging and code changes are wildly mixed and, let's move on the first (and the most manual) patch mechanis
(04:18:58 PM) didrocks: sebner: thanks ;)
(04:19:13 PM) didrocks: == udev: separate patches, but no standard/automated patch system ==
(04:19:35 PM) didrocks: this is the logical evolution of the previous statement. Let's patch something by doing some diff between the previous states of the source code and our one.
(04:20:01 PM) didrocks: so, everything has to be done manually, making it the most complicated patch system. All others patch system relies on this one and automate it. So, you will first have to understand how it works "beyond the gears" (no no, not Google one ;)).
(04:20:22 PM) didrocks: due to this complexity, this manual mechanism is rarely used by maintainers, and even it can appears as being difficult for people who has never done this before, you will have to understand it to see how patch system works.
(04:20:37 PM) didrocks: so please, do not hesitate to ask questions. As we are the latest, we have (almost) all the night/the rest of the day, depending your time (Ok, we want to sleep also ;)).
(04:20:59 PM) didrocks: pitti strongly advise you to print and hang over your desk this general approach, so, I will quote him :)
(04:21:11 PM) didrocks: 1. copy the clean source tree to a temporary directory /tmp/old
(04:21:22 PM) didrocks: 2. apply all previous patches up to the one you want to edit; if you want to create a new patch, apply all existing ones (this is necessary since in general patches depend on previous patches).
(04:21:37 PM) didrocks: 3. copy the whole source tree again: cp -a /tmp/old /tmp/new
(04:21:46 PM) didrocks: 4. go into /tmp/new, do your modifications
(04:21:56 PM) didrocks: 5. go back into /tmp and generate the patch with diff -Nurp old new > mypatchname.patch
(04:22:05 PM) didrocks: 6. move the newly generated patch to <original source dir>/debian/patches/mypatchname.patch
(04:22:24 PM) didrocks: diff -Nurp is used because, in general, we want the following diff options:
(04:22:30 PM) didrocks: -N -> include new files
(04:22:38 PM) didrocks: -u -> unified patches (context diffs are <bad/ugly/wathever word you can find> to read)
(04:22:50 PM) didrocks: -r -> recursive
(04:22:55 PM) didrocks: -p -> bonus, you can see the name of the affected C and some other language function in the patch
(04:23:16 PM) didrocks: anybody has a question about the principal method?
(04:23:26 PM) didrocks: (we will do a hands-on example now, to burn this in your mind forever :))
(04:24:05 PM) chombium: lets get our hands dirty :)
(04:24:25 PM) didrocks: chombium: hehe, sure you will :)
(04:24:41 PM) didrocks: so, if there is no question, let's move on
(04:24:48 PM) didrocks: open a shell in you favorite console tool!
(04:25:04 PM) didrocks: $ cd udev-* # -117 on hardy and -124 on intrepid
(04:25:10 PM) didrocks: => we are now in our original source tree where we want to add a new patch
(04:25:23 PM) didrocks: $ cp -a . /tmp/old
(04:25:30 PM) didrocks: => we create a copy of the clean sources as reference tree (always use name like old, origin, pristine...). We have done with step 1
(04:25:51 PM) didrocks: $ pushd /tmp/old
(04:26:13 PM) didrocks: does everybody know pushd?
(04:26:23 PM) sebner: nope
(04:26:25 PM) Kurt: the directory stack :)
(04:26:33 PM) didrocks: Kurt: yes :)
(04:26:37 PM) didrocks: => "pushd" is equivalent to cd, but it will use a stack for to remember the previous directory, so, that it will be easy later to go to our <patchtraining/udev-*> directory with "popd"
(04:26:56 PM) didrocks: sebner: is it ok?
(04:27:28 PM) sebner: didrocks: ah I already heard of it but forgot it ^^ /me is quite tired already ^^
(04:28:11 PM) didrocks: sebner: be brave, it's time to manipulate :)
(04:28:23 PM) didrocks: $ debian/rules patch
(04:28:28 PM) didrocks: => all well-configured debian/rules file has a "patch" (or patch-stamp, apply-patch, setup, unpack...) target that able us to apply every existing patch in debian/patches/ or something similar. This is better than applying all patches one by one, in the right order with the "patch" command. You have to look in debian/rules how it is called.
(04:28:28 PM) sebner: ^^
(04:29:01 PM) didrocks: If you just want to apply a subset of patch to modify an existing one, you will (but we will not treat this case in this example) only apply them manually (with patch command).
(04:29:01 PM) chombium: QUESTION: cp -a ./tmp/old returns cp: missing destination file operand after `./tmp/old'
(04:29:07 PM) didrocks: Step 2 is now over
(04:29:23 PM) didrocks: chombium: this is a space beetween . and /
(04:29:39 PM) didrocks: you copy the current directory . to /tmp/old
(04:29:40 PM) chombium: didrocks: tx
(04:29:49 PM) chombium: got it :(
(04:29:57 PM) didrocks: you're welcome :)
(04:30:12 PM) didrocks: has everyone applied their patch?
(04:30:21 PM) didrocks: just shout when it's done :)
(04:30:36 PM) ***Ampelbein shouts
(04:30:48 PM) ***didrocks is afraid :)
(04:31:10 PM) Kurt: done
(04:31:39 PM) didrocks: chombium: ok?
(04:31:41 PM) ***sebner will read the logs tomorrow again xD /me -> bed
(04:31:53 PM) chombium: o/
(04:31:58 PM) huats: ok sebner bye
(04:32:07 PM) chombium: didrocks: yes
(04:32:07 PM) didrocks: sebner: good night. Sleep time has triumphed :)
(04:32:14 PM) didrocks: great!
(04:32:20 PM) sebner: huats: didrocks : great work so far. ROCK ON and I'll read the logs ;)
(04:32:23 PM) didrocks: let's go on
(04:32:39 PM) didrocks: sebner: contact us on IRC if you have any question in reading the log :)
(04:32:46 PM) didrocks: (huats or I)
(04:32:56 PM) sebner: kk, gn8 fols
(04:32:58 PM) didrocks: ok, so, next step is
(04:33:02 PM) didrocks: $ cp -a . /tmp/new; cd ../new
(04:33:14 PM) didrocks: chombium: be careful, there is a space again :)
(04:33:21 PM) didrocks: => just copy the content with applied patches to /tmp/new where we will begin to work with. This corresponds to step 3.
(04:33:58 PM) didrocks: so, at this time, /tmp/old and /tmp/new are identical
(04:34:21 PM) chombium: didrocks: :)
(04:34:27 PM) didrocks: both contain the patched source code
(04:34:54 PM) didrocks: Now, let's hack and make a new beautiful patch:
(04:35:00 PM) didrocks: $ sed -i 's#Linux#GNU/Linux#g' README
(04:35:10 PM) didrocks: RMS will enjoy, I'm pretty sure! This simply replace all Linux instance in the README file by GNU/Linux one. You can obviously hack with the tools you prefer (editors like vim/emacs or IDE like eclipse/anjuta/kdevelop).
(04:35:39 PM) didrocks: just do the changes you desire with the tool you want. As the idea is to keep it minimal here, sed will be ok for us :) This step 4 can length a long time before being completed.
(04:36:02 PM) ***didrocks hopes everyone know sed :)
(04:36:45 PM) didrocks: are you ok?
(04:36:48 PM) chombium: didrocks: depends on the bugs we need to take care of ;)
(04:36:50 PM) Kurt: I am
(04:36:56 PM) chombium: me too
(04:36:58 PM) didrocks: chombium: yes, of course :)
(04:37:12 PM) didrocks: it's time to create the patch now! For this, we will compared the old tree to the new one (all have previous patches applied, appart from your current hack and extra work).
(04:37:20 PM) didrocks: $ cd ..
(04:37:29 PM) didrocks: => for this, we prefer to go back to /tmp (the patch that we would see will state /tmp/old/README vs /tmp/new/README which is better than comparing ../old/README vs README)
(04:37:39 PM) didrocks: $ diff -Nurp old new > 90_happy_rms.patch
(04:37:58 PM) didrocks: => so there, we compare the previous source (old) to our hacked tree (new). And we put the differences in the file 90-rms.patch
(04:38:11 PM) didrocks: oupss, 90_happy_rms.patch
(04:38:21 PM) didrocks: Step 5 completed! (ignore the 'recursive directory loop' warnings)
(04:38:49 PM) didrocks: is your patch created?
(04:39:01 PM) chombium: yes
(04:39:08 PM) didrocks: note that it is a good idea to use number prefix for patch names as generally they will be applied in a asciibetical order. As many patches depends on others (ie. you modify a file that is already modified by a previous patch, so the context of the patch has changed), you ensure that everyone will apply that in the same logical order. Some patches will not applied in the pristine code!
(04:39:31 PM) didrocks: $ popd
(04:39:35 PM) didrocks: => as previously said, as we have stacked the previous directory, this will lead you the <patchtraining/udev-*> recorded one
(04:39:58 PM) didrocks: $ rm -rf /tmp/old /tmp/new
(04:40:03 PM) didrocks: => it's everytime a good idea to clean what has to be cleaned, as we will never use that again :)
(04:40:13 PM) didrocks: $ less /tmp/90_happy_rms.patch
(04:40:17 PM) didrocks: => have a look at your patch (you can use gedit/kate if you prefer) to see to what it looks and ensure everything seems fine.
(04:40:41 PM) Kurt: I notice that SELinux was replaced by SEGNU/Linux
(04:40:46 PM) didrocks: tell me when everything is all right. Just a few step has to be done now
(04:41:06 PM) didrocks: Kurt: yes, so, when you use sed, be careful with what you do :)
(04:41:19 PM) Kurt: didrocks: heh :)
(04:41:19 PM) didrocks: this is the case here, but sed was just use to make a quick hack
(04:41:26 PM) didrocks: used*
(04:41:37 PM) didrocks: $ mv /tmp/90_happy_rms.patch debian/patches
(04:41:39 PM) didrocks: => copy the patch to the patches directory of your current source package directory (remember, you are in <patchtraining/udev-*>) so that your debian/rules will be able to find it and apply it during the build of the package.
(04:41:42 PM) chombium: Kurt: the regular expression was bad
(04:41:54 PM) didrocks: => Step 6 done! We can take a breath, our patch is perfect ;)
(04:42:16 PM) didrocks: chombium: yes, I know. That was not the goal of this classroom to teach regular expression :)
(04:42:20 PM) didrocks: ping when you are ready!
(04:42:37 PM) didrocks: you can test in calling debian/rules patch and confirm that your patch apply correctly!
(04:42:51 PM) chombium: didrock: yes rigth. I was just explaining to Kurt
(04:43:32 PM) Kurt: lol yeah I was just making a remark, I realized what had happened.  Sorry for the fuss :)
(04:43:48 PM) chombium: seems good
(04:43:51 PM) didrocks: Kurt: no problem :)
(04:44:12 PM) didrocks: Kurt: but that shows that you are following, that's good!
(04:45:07 PM) didrocks: are you all right?
(04:45:17 PM) didrocks: just 2 remaining persons apparently :)
(04:45:21 PM) Kurt: I am
(04:45:29 PM) chombium: o/
(04:45:35 PM) didrocks: obviously, this is not trivial for a complete beginner, but after doing this a couple of times, you should understand exactly what is involved and how it work with every system patches.
(04:45:44 PM) didrocks: so, let's confess that doing this everyday is simply tiring and boring. The idea will be more to concentrate on hacking and fixing stuff than generating the patch itself.
(04:45:56 PM) didrocks: Pitti has created a script called "dsrc-new-patch" for automating this, and we will see later that other patch systems have something quite similar.
(04:46:07 PM) didrocks: $ cd ..; rm -r udev-*; dpkg-source -x udev_*.dsc; cd udev-*
(04:46:14 PM) didrocks: => First, let's clean our work and download again an untouched udev-* source tree.
(04:46:34 PM) didrocks: step 1 to 3 are completed in simply calling the script:
(04:46:39 PM) didrocks: $ ../dsrc-new-patch 90_happy_rms.patch
(04:46:56 PM) didrocks: => it drops you into a shell where you can edit the code and hack whatever you want
(04:47:09 PM) didrocks: $ sed -i 's#Linux#GNU/Linux#g' README
(04:47:21 PM) didrocks: (yeah, the same bad regexp again :))
(04:47:29 PM) didrocks: => make all your modification and then, press <Control-D> or type "exit 0" to leave the subshell.
(04:47:44 PM) didrocks: then, step 5 & 6 are automatically completed. Nice, isn't it? You will have a debian/patches/90_happy_rms.patch which is exactly the same than the one you created before.
(04:48:23 PM) didrocks: Are both of you created successfully the patch?
(04:48:33 PM) didrocks: s/Are/does
(04:48:48 PM) Kurt: I got stuck at the  $ ../dsrc-new-patch 90_happy_rms.patch     part
(04:48:57 PM) chombium: yes
(04:49:16 PM) didrocks: Kurt: wrong paste, maybe? What is doing the script?
(04:49:19 PM) Kurt:     $ ../dsrc-new-patch 90_happy_rms.patch
(04:49:25 PM) Kurt: oops
(04:49:46 PM) didrocks: so, when you execute it, you will see a new shell
(04:49:59 PM) didrocks: then, you perform your modifications
(04:50:11 PM) didrocks: and then "exit 0" or <control D>
(04:50:19 PM) didrocks: (to return to your previous shell)
(04:51:00 PM) didrocks: Kurt: don't hesitate to ask some more question if you still get stuck
(04:51:45 PM) didrocks: I think Kurt is lost in its subshell :)
(04:52:26 PM) Kurt: sorry, I didn't see the wget for the dsrc up there
(04:52:29 PM) Kurt: catching up now :)
(04:53:13 PM) didrocks: :)
(04:53:29 PM) didrocks: ok !
(04:53:33 PM) didrocks: if you like the script, you can put it in your $PATH (~/bin is a good place for that).
(04:53:44 PM) didrocks: so, doing this by hand or automatically, always remember (as previously said) to apply the patch in the right order.
(04:53:56 PM) didrocks: dsrc-new-patch is a hack which mostly works for packages without a real patch system, but split-out patches
(04:54:08 PM) didrocks: but appart from this hack, some patch system has been invented so that hacker can be more concentrated on the code than the tools to generate the result of their work. That's the reason why they are used by 90% of the archive's sources packages.
(04:54:18 PM) didrocks: for the remaining one, you will have to complete the previous manual approach.
(04:54:29 PM) didrocks: if there is no more question (shout NOW!), let's look at the most popular ones now.
(04:54:55 PM) laga: didrocks: did you see my question in ubuntu-classroom-chat?
(04:55:13 PM) huats: laga: sure...
(04:55:16 PM) didrocks: the rocking huats is going to go on on the session to present you some rocking patch system
(04:55:19 PM) huats: he will answer there :)
(04:55:26 PM) huats: ok guys.
(04:55:27 PM) didrocks: yes :)
(04:55:27 PM) laga: yay
(04:55:36 PM) didrocks: <laga> QUESTION: not following the tutorial right now, but i wonder if you have a good way to mangle the patch level (ie file paths) in patches. that's often useful if you take patches  from other sources
(04:55:50 PM) didrocks: laga: do you speak about the patch system?
(04:55:59 PM) didrocks: how to determine the patch system of a package?
(04:56:19 PM) huats: didrocks: switch to -chat :)
(04:56:27 PM) huats: First of all thanks didrocks ! That was great :)
(04:56:38 PM) didrocks: laga: ok, will continue on -chat :)
(04:56:41 PM) didrocks: thx huats ;)
(04:56:58 PM) huats: Right now we will focus on patching systems...
(04:57:11 PM) huats: of course the old way, that didrocks showed us are nice
(04:57:28 PM) huats: but you'll enjoy evoluates systems too !
(04:57:32 PM) huats: first of all
(04:57:40 PM) huats: let's have a look at dpatch !
(04:57:51 PM) huats: To do so, we'll use ed
(04:58:04 PM) huats: so if you have the sources
(04:58:07 PM) huats: cd ../ed-07
(04:58:19 PM) huats: is it ok for everyone ?
(04:58:33 PM) huats: (well for both of you :))
(04:58:40 PM) Kurt: yes for me
(04:58:42 PM) chombium: yes
(04:58:44 PM) huats: ok
(04:58:46 PM) huats: great
(04:58:56 PM) huats: A few words on dpatch, let me quote master pitti :
(04:58:57 PM) huats: "dpatch is a pretty robust and proven patch system which also ships a script 'dpatch-edit-patch' packages which use this build-depend on 'dpatch', and debian/rules includes ''
(04:59:06 PM) huats: The two most important things you should be aware of:
(04:59:07 PM) huats: * dpatch does not apply debian/patches/*, but instead applies all patches mentioned in debian/patches/00list, in the mentioned order. That means that you do not have to rely on asciibetical ordering of the patches and can easily disable patches, but you have to make sure to not forget to update 00list if you add a new patch.
(04:59:07 PM) huats: (forgetting to update 00list is a common cause of followup uploads :-) )
(04:59:07 PM) huats: * dpatch patches are actually scripts that are executed, not just patches fed to 'patch'. That means you can also do fancy things like calling autoconf or using sed in a dpatch if you want."
(04:59:22 PM) nxvl: huats: slow down!
(04:59:31 PM) huats: nxvl: sure :)
(04:59:36 PM) huats: o/ nxvl
(05:00:02 PM) huats: dpatch comes with some interesting scripts to enables us to get info/manipulates patches. Their names are quite explanatory, by instance dpatch-list-patch will list you all existing patches in the packages.
(05:00:24 PM) huats: dpatch-list-patch
(05:00:36 PM) huats: if you type that in your current shell
(05:00:45 PM) huats: you'll have the whole list
(05:01:09 PM) huats: of  patches, with their corresponding authors and descriptions
(05:01:24 PM) huats: But by far, you'll mostly use dpatch-edit-patch. This is the command that will enable you to create/modify a dpatch !
(05:01:35 PM) huats: Let's start with editing a patch :
(05:01:46 PM) huats: type :
(05:01:50 PM) huats: dpatch-edit-patch 07_ed.1-spelling-fixes
(05:02:06 PM) huats: (note that 07_ed.1-spelling-fixes is a current existing patch)
(05:02:18 PM) huats: You are now in a new shell were the patch is already applied. You can edit the files you want.
(05:02:43 PM) huats: By instance:
(05:02:43 PM) huats: $ echo "UbuntuDevWeekAugust08" >> README
(05:03:04 PM) huats: Once you are OK with your results, just press Ctrl+D.
(05:03:04 PM) huats: Otherwise, if you are not happy with your changes, exit the shell with a non zero value, by instance exit 230.
(05:03:04 PM) huats: The patch will be untouched !
(05:03:24 PM) huats: but in that case type exit 0
(05:03:45 PM) huats: now simply look at the debian/patches/07_ed.1-spelling-fixes file
(05:04:05 PM) huats: at the end of the file you'll notice what e have added...
(05:04:11 PM) huats: is it ok for everyone ?
(05:04:14 PM) hggdh:   cool
(05:04:25 PM) Kurt: yep
(05:04:42 PM) huats: ok
(05:04:53 PM) huats: chombium: too ?
(05:05:16 PM) chombium: yep
(05:05:21 PM) huats: ok great
(05:05:24 PM) huats: Now let's create a patch ! Here again we'll use dpatch-edit-patch.
(05:05:24 PM) huats: $ dpatch-edit-patch 08_developper_week_patch
(05:05:44 PM) huats: If you are not happy with your changes, exit the shell with a non zero value, by instance exit 230.
(05:05:44 PM) huats: The patch will not be created !
(05:05:44 PM) huats: You are once again in a new shell. You can edit the files as you want.
(05:06:02 PM) huats: (it is the same process than for editing)
(05:06:20 PM) huats: once again
(05:06:22 PM) huats: do
(05:06:32 PM) huats:  echo "UbuntuDevWeekAugust08-again" >> README
(05:06:53 PM) huats: and press Ctrl+D
(05:07:09 PM) huats: The patch has been created
(05:07:22 PM) huats: But so far it won't be applied automatically
(05:07:30 PM) huats: Does anybody can tell me why ?
(05:07:43 PM) hggdh: because of petential order conflict
(05:07:49 PM) cocooncrash: huats: It's not in 00list.
(05:07:51 PM) Kurt: it isn't in the 00list?
(05:07:57 PM) huats: hggdh: nope
(05:08:04 PM) huats: cocooncrash: and Kurt exactly
(05:08:12 PM) hggdh: what I meant isL it is not in 00list
(05:08:18 PM) hggdh: because of ...
(05:08:20 PM) huats: ok hggdh
(05:08:31 PM) huats: so it can be done with
(05:08:33 PM) huats: echo 08_developper_week_patch.dpatch >> debian/patches/00list
(05:08:51 PM) huats: Please have a look at the file debian/patches/08_developper_week_patch.dpatch
(05:08:51 PM) huats: Note that exacly like in the debian/changelog you need to put your name and email in the patch !
(05:08:51 PM) huats: You also have to edit the description of the patch. It is the line that follows ## DP:
(05:08:51 PM) huats: So please do it. Having one of them missing is a very common cause for a sponsor to refuse your request !
(05:09:20 PM) huats: Note that you can create your patch in relation with another patch. Simply add the patch you want to be applied before your on the command line. Like that:
(05:09:39 PM) huats: $ dpatch-edit-patch 08_developper_week_patch 07_ed.1-spelling-fixes
(05:09:39 PM) huats: 07_ed.1-spelling-fixes has not been chose randomly. The output of dpatch-list-patch has showed us that it was the last one to be applied.
(05:10:04 PM) huats: And indeed here notice that all patches are applied. How do I notice that ?
(05:11:24 PM) chombium: QUESTION: will the patches be sorted by the file name when adding in 00list?
(05:11:57 PM) huats: chombium: yes
(05:12:05 PM) didrocks: huats: not sure
(05:12:05 PM) huats: hum
(05:12:06 PM) huats: no
(05:12:19 PM) huats: they will be treated in the file order
(05:12:23 PM) didrocks: chombium: it's the file order
(05:12:25 PM) didrocks: :)
(05:12:36 PM) huats: sorry I missread
(05:12:42 PM) didrocks: just copy one question from -chat
(05:12:44 PM) didrocks: <laga> QUESTION: if i take a patch from another source and turn it into a dpatch, do i still need to put my name as the author?
(05:12:51 PM) didrocks: <huats> laga:  you have too
(05:12:57 PM) didrocks: <huats> otherwise you'll have lintian warnings
(05:12:59 PM) didrocks: (for the log)
(05:13:02 PM) huats: hum
(05:13:06 PM) huats: once again I missread
(05:13:14 PM) huats: you have to put the author name
(05:13:19 PM) cocooncrash: QUESTION: Should you put your name or the original author?
(05:13:21 PM) huats: (not yours in that case)
(05:13:32 PM) didrocks: huats: yes, it's getting late, I know :)
(05:13:50 PM) huats: but put a name is needed... otherwise lintian will complain
(05:13:55 PM) nxvl: we love huats
(05:14:00 PM) ***nxvl waves on huats 
(05:14:00 PM) huats: :)
(05:14:25 PM) huats: the answer of my question was that you'll notice : patch XXXX apply on
(05:14:26 PM) ***didrocks is jalous :)
(05:14:37 PM) huats: before getting the subshell
(05:14:48 PM) huats: That was pretty simple right ?
(05:14:56 PM) huats: any other questions with dpatch ?
(05:15:15 PM) huats: Oh one last word about dpatch. It is needed to modify the debian/rules file (for automatic patching and unpatching). But I won't demonstrate that now. If you want to see how to do that, have a look at the debian/rules file and search for patch :)
(05:15:18 PM) hggdh: QUESTION: new patch, new version number. How is it done under DPATCH?
(05:15:32 PM) huats: you have to choose the number
(05:15:39 PM) huats: yourself
(05:15:45 PM) huats: version number ?
(05:16:09 PM) hggdh: version.release.subversion etc. So no auto-increment?
(05:16:32 PM) cocooncrash: hggdh: Patches don't affect the package version number. That is determined by the changelog entry.
(05:16:34 PM) ***nxvl waves on didrocks too
(05:16:43 PM) huats: hggdh: cocooncrash has answered :)
(05:16:54 PM) hggdh: :-)
(05:16:55 PM) huats: hggdh: didrocks will explain that to you on -chat
(05:16:56 PM) didrocks: (nxvl: thanks, you rock :))
(05:17:05 PM) huats: let's move
(05:17:18 PM) huats: since we already have lasted longer than supposed...
(05:17:21 PM) huats: == keepalived : cdbs with simple-patchsys ==
(05:17:21 PM) huats: Let's move to cdbs. For this example we'll have a closer look at keepalived (once again pitti example).
(05:17:35 PM) huats: oups
(05:17:40 PM) huats: it was not pitti example
(05:17:41 PM) huats: :(
(05:17:48 PM) huats: it is getting way to late :)
(05:17:51 PM) huats:  cd ../keepalived-1.1.15
(05:18:01 PM) huats: First let's have a look at debian/rules.
(05:18:01 PM) huats: You'll notice that the only reference to the patching system include
(05:18:01 PM) huats: Pretty magic :)
(05:18:26 PM) huats: pitti has the good idea to write a script called 'cdbs-edit-patch' that works closely like dpatch-edit-patch.
(05:18:26 PM) huats: This script is contained in the normal cdbs package.
(05:18:26 PM) huats: You just supply the name of a patch to the script, and depending on whether it already exists or not, it will create a new patch or edit an existing one.
(05:18:40 PM) huats: Let's add a new patch !
(05:18:52 PM) huats: $ cdbs-edit-patch 05-simple-readme.patch
(05:18:52 PM) huats: $ echo 'This should document keepalived' > UbuntuDevWeek.README
(05:19:07 PM) huats: <press Control-D to leave the subshell>
(05:19:32 PM) huats: Here again if you are not happy with your changes, just type exit 230 in the subshell.
(05:19:32 PM) huats: The edition of an existing patch work exactly the same way...
(05:19:32 PM) huats: Questions ?
(05:20:00 PM) huats: (I won't be long here since it is pretty the same thing than dpatch-edit-patch)
(05:20:04 PM) cocooncrash: QUESTION: Are the patches still stored in debian/patches?
(05:20:16 PM) huats: cocooncrash: it is the debian policy yes
(05:20:21 PM) cocooncrash: QUESTION: Is 00list is used, or are all patches applied?
(05:20:45 PM) huats: 00list is for dpatch
(05:21:02 PM) huats: and only patch in it will be applied
(05:21:40 PM) huats: Is it ok for everyone ?
(05:21:54 PM) huats: If so, I am moving on :)
(05:21:54 PM) chombium: yep
(05:22:02 PM) huats: == xterm: quilt ==
(05:22:02 PM) huats: The last patch system that we will detail is quilt. We will study it on xterm.
(05:22:02 PM) huats: It is non-trivial to set up and has a lot of advanced commands which make it very flexible, but not very easy to use.
(05:22:32 PM) huats: $ cd ../xterm-229
(05:22:41 PM) huats: Like dpatch, it has a list of patches to apply in patches/series (to use debian/patches, packages need to add a sylink) or set $QUILT_PATCHES to debian/patches
(05:23:04 PM) huats: it is needed to respect the debian policy for patches... and thus to satisfy your question cocooncrash
(05:23:14 PM) huats: Let's have a look at debian/rules. You'll notice the line that does the trick :
(05:23:14 PM) huats: QUILT_PATCHES = patches/
(05:23:49 PM) huats: So to work right now, let's export that right now (since we won't use debian/rules tonight)
(05:23:49 PM) huats: $ export QUILT_PATCHES=debian/patches
(05:24:18 PM) huats: Unlike cdbs-edit-pattch, and dpatch-edit-patch, quilt doesn't create temporary directories with a copy, but remembers old versions of the files and uses the normal working tree a bit like version control (svn, bzr, etc.).
(05:24:42 PM) huats: Now let's edit the already existing patch 901_xterm_manpage.diff:
(05:24:42 PM) huats: $ quilt push 901_xterm_manpage.diff
(05:24:42 PM) huats: This will apply all patches (inline remember) in the stack up to the given one.
(05:25:07 PM) huats: Now let's edit a file that is already touched by the original patch
(05:25:07 PM) huats: $ sed -i 's/Copyright/Copyleft/'
(05:25:27 PM) huats: Let's commit the change:
(05:25:28 PM) huats: First updates the patch file with your recent changes
(05:25:28 PM) huats: $ quilt refresh 901_xterm_manpage.diff
(05:25:35 PM) huats: Than unapplies all patches to go back to pristine source tree
(05:25:35 PM) huats: $ quilt pop -a
(05:25:42 PM) huats: Ok, I'll stop a bit :)
(05:25:47 PM) huats: to let you do that :)
(05:26:01 PM) huats: Ping once you have finished to do that :)
(05:27:18 PM) didrocks: well, everytime, and especially for quilt, look at the man before executing anything you are not quite sure :)
(05:27:28 PM) huats: So have you done it ?
(05:27:37 PM) Kurt: yes
(05:27:41 PM) huats: Look at debian/patches/901_xterm_manpage.diff to see the effect :)
(05:27:41 PM) huats: Does anyone can point it to me ?
(05:28:18 PM) huats: anyone ?
(05:28:42 PM) Kurt: copyrights switched to copylefts
(05:28:49 PM) huats: Kurt: thanks !
(05:28:50 PM) huats: :)
(05:28:53 PM) huats: indeed :)
(05:29:06 PM) huats: it means that the patch has been modified !
(05:29:30 PM) huats: Finally to end our patching tour : let's create our own patch
(05:29:42 PM) huats: $ quilt push -a
(05:29:49 PM) huats: This will apply all the patches (-a for all)
(05:29:56 PM) huats: $ quilt new UbuntuDevWeekAugust08.diff
(05:29:56 PM) huats: This is the creation of the patch !
(05:30:08 PM) huats: $ quilt add README
(05:30:09 PM) huats: It is needed to tell quilt all the files that you want to be incoporated in your patch (likewise version control stuffs).
(05:30:19 PM) huats: $ echo "UbuntuDevWeekAugust08" >> README
(05:30:19 PM) huats: Some modification.
(05:30:28 PM) huats: $ quilt refresh
(05:30:28 PM) huats: Update the currently edited patch
(05:30:39 PM) huats: $ quilt pop -a
(05:30:39 PM) huats: This will finally create debian/patches/UbuntuDevWeekAugust08.diff with the changes to README
(05:31:04 PM) huats: And that it is :)
(05:31:09 PM) huats: Does anybody can tell me what we need to check ?
(05:31:18 PM) huats: to be sure that the patch is applied ?
(05:31:28 PM) huats: (hint: it is a bit like dpatch :))
(05:31:43 PM) hggdh: :debian/patches/series?
(05:31:50 PM) huats: hggdh: exactly
(05:32:08 PM) hggdh: but this time it is already added in
(05:32:14 PM) huats: exactly
(05:32:23 PM) didrocks: hggdh: yeah, quilt rocks \o/
(05:32:27 PM) huats: You don't edit it manually usually.
(05:32:48 PM) huats: That is pretty it guys !
(05:32:57 PM) huats: Questions ?
(05:33:07 PM) Kurt: thanks for the session huats and didrocks :) It was great
(05:33:15 PM) hggdh: thank you
(05:33:20 PM) huats: Kurt: thanks to you guys
(05:33:28 PM) didrocks: Always remember that there is the ubuntu wiki for more details:
(05:33:32 PM) huats: if you have any questions please ping us on IRC :)
(05:33:42 PM) huats: or ping master pitti :)
(05:33:48 PM) didrocks: thanks Kurt & hggdh gor having followed until the end :)
(05:34:02 PM) didrocks: of ping nxvl, he really loves questions :)
(05:34:09 PM) didrocks: s/of/or
(05:34:13 PM) huats: thanks a lot guys
(05:34:13 PM) nxvl: and if pitti tells you he doesn't know, ask anyway, he knows
(05:34:20 PM) nxvl: that's why we love pitti
(05:34:29 PM) didrocks: nxvl: \o/
(05:34:37 PM) huats: bye bye everyone !
(05:34:41 PM) Kurt left the room.
(05:34:42 PM) didrocks: thanks a lot to everyone! Bye!
(05:34:50 PM) chombium: thanks a log guys
(05:35:01 PM) chombium: \o/
(05:35:41 PM) didrocks: thanks chombium \o/

MeetingLogs/devweek0809/PackagePatches (last edited 2008-09-04 07:42:30 by 91)