GettingSetUpForUbuntuDev

Dev Week -- Getting set up for Ubuntu development -- dholbach -- Tue, Aug 28th, 2012

   1 [16:01] <dholbach> Excellent - welcome back to session number two at https://wiki.ubuntu.com/UbuntuDeveloperWeek :)
   2 [16:01] <dholbach> for those of you who joined in late, please also make sure you're in #ubuntu-classroom-chat so you can ask your questions there
   3 [16:02] <dholbach> and please prefix them with QUESTION: so the bot will pick them up
   4 [16:02] <dholbach> In this session we will set up our development environment, configure the tools and everything, so you're ready for the upcoming sessions and for getting involved
   5 [16:03] <dholbach> if we get through everything quick enough we can even have a look at a package and what to do with it
   6 [16:03] <dholbach> this session will be practical, so you might want to open a terminal already
   7 [16:03] <dholbach> There are a number of things you need to do to get started developing for Ubuntu.
   8 [16:03] <dholbach> We'll get your computer set up so that you can start working with packages, and upload your packages to Ubuntu's hosting platform, Launchpad.
   9 [16:03] <dholbach> Here's what we'll do:
  10 [16:04] <dholbach>  - Installing packaging-related software. This includes: Ubuntu-specific packaging utilities, Encryption software so your work can be verified as being done by you, Additional encryption software so you can securely transfer files.
  11 [16:04] <dholbach>  - Cover the creation and configuring of your account on Launchpad
  12 [16:04] <dholbach>  - Setting up your development environment to help you do local builds of packages, interact with other developers, and propose your changes on Launchpad.
  13 === qwerty is now known as Guest18258
  14 [16:04] <dholbach> It is advisable to do packaging work using the current development version of Ubuntu. Doing so will allow you to test changes in the same environment where those changes will actually be applied and used.
  15 [16:05] <dholbach> This means that you will need to run Ubuntu Quantal (12.10) in some form.
  16 [16:05] <dholbach> Don't despair - you can run it in a chroot or virtual machine if that suits you for testing, or in a separate partition, or something along those lines.
  17 [16:05] <dholbach> Still it's very important to test your fixes in a live environment.
  18 [16:05] <dholbach> https://wiki.ubuntu.com/UsingDevelopmentReleases explains how to do it safely.
  19 [16:06] <dholbach> If you are now on 12.04, you're fine - you can still go through the instructions and repeat them later on.
  20 [16:06] <dholbach> There are a number of tools that will make your life as an Ubuntu developer much easier. You will encounter these tools later on. To install most of the tools you will need run this command:
  21 [16:06] <dholbach>   sudo apt-get install packaging-dev
  22 [16:07] <dholbach> This will take a while, so just keep it running.
  23 [16:07] <dholbach> This command will install the following software:
  24 [16:07] <dholbach>  - gnupg – GNU Privacy Guard contains tools you will need to create a cryptographic key with which you will sign files you want to upload to Launchpad.
  25 [16:07] <dholbach>  - pbuilder – a tool to do a reproducible builds of a package in a clean and isolated environment.
  26 [16:07] <dholbach>  - ubuntu-dev-tools (and devscripts, a direct dependency) – a collection of tools that make many packaging tasks easier.
  27 [16:07] <dholbach>  - bzr-builddeb (and bzr, a dependency) – distributed version control with Bazaar, a new way of working with packages for Ubuntu that will make it easy for many developers to collaborate and work on the same code while keeping it trivial to merge each others work.
  28 [16:07] <dholbach>  - apt-file provides an easy way to find the binary package that contains a given file.
  29 [16:08] <dholbach> ... and obviously many many many other good things we won't cover in this tutorial. :)
  30 [16:08] <dholbach> Any questions so far?
  31 [16:08] <ClassBot> NickE asked: What VM does TestDrive use?
  32 [16:09] <dholbach> NickE, I think it uses kvm.
  33 [16:09] <ClassBot> nja asked: Is it usual to get "apt-file update needed" after installing those packages?
  34 [16:09] <dholbach> nja, not for now, I don't think
  35 [16:09] <ClassBot> conner_bw asked: Is bzr etched in stone? Will git be supported someday?
  36 [16:10] <dholbach> conner_bw, I don't know - you could try to ask in #launchpad though
  37 [16:10] <dholbach> personally I love bzr because it's quite easy to learn, but I know others prefer git or some other version control system
  38 [16:10] <dholbach> the good thing is that Launchpad can import git branches and others as well, so you can work on them natively with bzr
  39 [16:11] <dholbach> Ok, let's crack on.
  40 [16:11] <dholbach> The Debian/Ubuntu packaging tools need to learn about you . So please simply open your ~/.bashrc in a text editor and add something like this to the bottom of it:
  41 [16:11] <dholbach> export DEBFULLNAME="Bob Dobbs"
  42 [16:12] <dholbach> export DEBEMAIL="subgenius@example.com"
  43 [16:12] <dholbach> Please use YOUR email address and YOUR name. :)
  44 [16:12] <dholbach> Now save the file and either restart your terminal or run:
  45 [16:13] <dholbach>   source ~/.bashrc
  46 [16:13] <dholbach> (If you do not use the default shell, which is bash, please edit the configuration file for that shell accordingly.)
  47 [16:13] <dholbach> Now that this is done, the packaging tools will always use your name and email address by default.
  48 [16:14] <ClassBot> nja asked: Is bash the shell integrated in Lernid?
  49 [16:14] <dholbach> nja, yes, lernid uses whatever shell you normally use - the default is bash
  50 [16:14] <dholbach> Now that this is done, let's create GPG key.
  51 [16:14] <dholbach> If you have a key already, you're fine - you don't need another.
  52 [16:15] <dholbach> GPG stands for GNU Privacy Guard and it implements the OpenPGP standard which allows you to sign and encrypt messages and files. This is useful for a number of purposes.
  53 [16:15] <dholbach> In our case it is important that you can sign files with your key so they can be identified as something that you worked on. If you upload a source package to Launchpad, it will only accept the package if it can absolutely determine who uploaded the package.
  54 [16:15] <dholbach> To generate a new GPG key, run:
  55 [16:15] <dholbach>   gpg --gen-key
  56 [16:15] <dholbach> GPG will first ask you which kind of key you want to generate. Choosing the default (RSA and DSA) is fine. Next it will ask you about the keysize. The default (currently 2048) is fine, but 4096 is more secure.
  57 [16:15] <dholbach> Afterwards, it will ask you if you want it to expire the key at some stage. It is safe to say “0”, which means the key will never expire.
  58 === patrick is now known as Guest90143
  59 [16:16] <dholbach> The last questions will be about your name and email address. Just pick the ones you are going to use for Ubuntu development here, you can add additional email addresses later on.
  60 [16:16] <dholbach> Adding a comment is not necessary. Then you will have to set a passphrase, choose a safe one (a passphrase is just a password which is allowed to include spaces).
  61 [16:16] <dholbach> Now GPG will create a key for you, which can take a little bit of time; it needs random bytes, so if you give the system some work to do it will be just fine.
  62 === raiden is now known as Guest47874
  63 [16:16] <dholbach> Maybe we will just let it sit there for a bit and do its thing, while we take care of other business.
  64 [16:17] <dholbach> Let's create our SSH key next.
  65 [16:17] <dholbach> SSH stands for Secure Shell, and it is a protocol that allows you to exchange data in a secure way over a network. It is common to use SSH to access and open a shell on another computer, and to use it to securely transfer files. For our purposes, we will mainly be using SSH to securely push changes to Launchpad.
  66 [16:17] <dholbach> To generate an SSH key, enter:
  67 [16:17] <dholbach>   ssh-keygen -t rsa
  68 [16:18] <dholbach> The default file name usually makes sense, so you can just leave it as it is. For security purposes, it is recommended that you use a passphrase.
  69 [16:19] <ClassBot> nja asked: Can the passphrase be changed later?
  70 [16:19] <dholbach> nja, yes
  71 [16:19] <dholbach> Next, let's set up pbuilder.
  72 [16:19] <dholbach> pbuilder allows you to build packages locally on your machine. It serves a couple of purposes:
  73 [16:19] <dholbach>  - The build will be done in a minimal and clean environment. This helps you make sure your builds succeed in a reproducible way, but without modifying your local system.
  74 [16:20] <dholbach>  - There is no need to install all necessary build dependencies locally
  75 [16:20] <dholbach>  - You can set up multiple instances for various Ubuntu and Debian releases.
  76 [16:20] <dholbach> Setting pbuilder up is very easy, simply run:
  77 [16:20] <dholbach>   pbuilder-dist <release> create
  78 [16:20] <dholbach> So for quantal, you'd run:
  79 [16:20] <dholbach>   pbuilder-dist quantal create
  80 [16:21] <dholbach> You can install multiple pbuilders, for each release of Ubuntu, or in the case of Debian maybe sid. This will take a while as it will download all the necessary packages for a “minimal installation”. These will be cached though.
  81 [16:21] <dholbach> Are there any questions up until now?
  82 [16:22] <ClassBot> jsjgruber-l82-p asked: Why might you need a .pbuilderrc file?
  83 [16:22] <dholbach> in .pbuilderrc you could specify a lot of things: for example using additional mirrors, installing packages into the chroots by default, etc.
  84 [16:22] <dholbach> pbuilder's manpage should give you a good idea of what you might want to use. In the most cases you don't need it though.
  85 [16:23] <ClassBot> exodus asked: Lets say I'm building a complicated package, which depends on various packages which are not already in a pbuilder slate. PackageA depends on PackageB & PackageC. After I build B & C, does pbuilder know B & C as a dependency for A. Is there a special set-up for the packages installed in pbuilder environment?
  86 [16:24] <dholbach> exodus, Good questions. Sometimes you might want to build a couple of packages in a certain sequence, for instance you want to transition 10 packages from libsomething1 to libsomething 2
  87 [16:25] <dholbach> in this case you can teach pbuilder to re-use packages you already built and to add them to its sources
  88 [16:25] <ClassBot> lengau asked: Why does pbuilder require root permissions?
  89 [16:25] <dholbach> lengau, because it uses chroot internally to create a completely separate minimal system in which it performs the build
  90 [16:26] <ClassBot> TheLordOfTime asked: How do you teach pbuilder to use the already-built packages, in the hypothetical exodus presented?
  91 [16:26] <dholbach> TheLordOfTime, https://wiki.ubuntu.com/PbuilderHowto is one I know about.
  92 [16:27] <dholbach> If it's outdated, I'd recommend to ask in #ubuntu-motu
  93 [16:27] <dholbach> Ok. I assume GPG finished creating the key for you already. Let's move on with the key then. :)
  94 [16:27] <dholbach> You might have gotten a message similar to this one:
  95 [16:27] <dholbach> pub   4096R/43CDE61D 2010-12-06
  96 [16:27] <dholbach>       Key fingerprint = 5C28 0144 FB08 91C0 2CF3  37AC 6F0B F90F 43CD E61D
  97 [16:27] <dholbach> uid                  Daniel Holbach <dh@mailempfang.de>
  98 [16:27] <dholbach> sub   4096R/51FBE68C 2010-12-06
  99 [16:27] <dholbach> In this case 43CDE61D is the key ID.
 100 [16:28] <dholbach> Next, you need to upload the public part of your key to a keyserver so the world can identify messages and files as yours. To do so, enter:
 101 [16:28] <dholbach>   gpg --send-keys <KEY ID>
 102 [16:28] <dholbach> This will send your key to one keyserver, but a network of keyservers will automatically sync the key between themselves. Once this syncing is complete, your signed public key will be ready to verify your contributions around the world.
 103 [16:28] <ClassBot> nja asked: What are all these generated keys for?
 104 [16:29] <dholbach> nja, if you upload a package to Launchpad (for instance to your personal package archive), it will check if the package was really done by you
 105 [16:29] <dholbach> the GPG key is used to sign a package and make sure it wasn't tampered with and that it originates from you
 106 [16:30] <dholbach> the SSH key is used for Bazaar, which I'll talk a bit more in a minute - it basically pushes your changes to LP using a secure connection
 107 [16:30] <dholbach> With a basic local configuration in place, your next step will be to configure your system to work with Launchpad.
 108 [16:30] <dholbach> Launchpad is the central piece of infrastructure we use in Ubuntu. It not only stores our packages and our code, but also things like translations, bug reports, and information about the people who work on Ubuntu and their team memberships. You will also use Launchpad to publish your proposed fixes, and get other Ubuntu developers to review and sponsor them.
 109 [16:31] <dholbach> Sponsoring basically means "upload a package for somebody else". This is what needs to be done if you want to get a fix into Ubuntu and you don't have upload rights yet.
 110 [16:31] <dholbach> You will need to register with Launchpad and provide a minimal amount of information. This will allow you to download and upload code, submit bug reports, and more.
 111 [16:32] <dholbach> Besides hosting Ubuntu, Launchpad can host any Free Software project. https://help.launchpad.net/ has more information if you should generally get stuck somewhere.
 112 [16:32] <dholbach> If you don't already have a Launchpad account, you can easily create one (https://launchpad.net/+login). If you have a Launchpad account but cannot remember your Launchpad id, you can find this out by going to https://launchpad.net/~ and looking for the part after the ~ in the URL.
 113 [16:32] <ClassBot> TheLordOfTime asked: I've seen this thing about the Ubuntu Code of Conduct.  Do I need to sign that to develop for Ubuntu?
 114 [16:33] <dholbach> TheLordOfTime, yes - if you want to become part of the team, become an Ubuntu member (get voting rights, an @ubuntu.com address and be generally recognised for your work), you will have to sign it
 115 [16:33] <dholbach> there's no hidden clauses or anything crazy in there - you won't sign up for a washing machine you'll have to pay
 116 [16:33] <dholbach> the code of conduct basically says to us all: be excellent to each other
 117 [16:34] <dholbach> and that's generally a good thing to comply with :)
 118 [16:34] <ClassBot> man_let asked: can less intelligent people contribute?
 119 [16:34] <dholbach> man_let, We have enough tasks for everyone in Ubuntu. No matter what your interest, ability or preference might be.
 120 [16:35] <ClassBot> nja asked: HELP! My LaunchPad password reset won't arrive!
 121 [16:35] <dholbach> nja, I think somebody mentioned it in the chat window already, but you can ask in #launchpad for help.
 122 [16:35] <dholbach> and you can follow the instructions from the log or the documentation later on
 123 [16:36] <dholbach> Launchpad's registration process will ask you to choose a display name. It is encouraged for you to use your real name here so that your Ubuntu developer colleagues will be able to get to know you better.
 124 [16:36] <dholbach> When you register a new account, Launchpad will send you an email with a link you need to open in your browser in order to verify your email address. If you don't receive it, check in your spam folder.
 125 [16:36] <dholbach> The new account help page (https://help.launchpad.net/YourAccount/NewAccount) on Launchpad has more information about the process and additional settings you can change.
 126 [16:37] <dholbach> You need to tell Launchpad about GPG key, so to find about your GPG fingerprint, please run:
 127 [16:37] <dholbach>   gpg --fingerprint <email@address.com>
 128 [16:37] <dholbach> and it will print out something like:
 129 [16:37] <dholbach> pub   4096R/43CDE61D 2010-12-06
 130 [16:37] <dholbach>       Key fingerprint = 5C28 0144 FB08 91C0 2CF3  37AC 6F0B F90F 43CD E61D
 131 [16:37] <dholbach> uid                  Daniel Holbach <dh@mailempfang.de>
 132 [16:37] <dholbach> sub   4096R/51FBE68C 2010-12-06
 133 [16:37] <dholbach> Head to https://launchpad.net/~/+editpgpkeys and copy the “Key fingerprint” into the text box. In the case above this would be 5C28 0144 FB08 91C0 2CF3  37AC 6F0B F90F 43CD E61D. Now click on “Import Key”.
 134 [16:37] <dholbach> Launchpad will use the fingerprint to check the Ubuntu key server for your key and, if successful, send you an encrypted email asking you to confirm the key import. Check your email account and read the email that Launchpad sent you.
 135 [16:37] <dholbach>  If your email client supports OpenPGP encryption, it will prompt you for the password you chose for the key when GPG generated it. Enter the password, then click the link to confirm that the key is yours.
 136 [16:38] <dholbach> Back on the Launchpad website, use the Confirm button and Launchpad will complete the import of your OpenPGP key.
 137 [16:38] <dholbach> Find more information at https://help.launchpad.net/YourAccount/ImportingYourPGPKey
 138 [16:38] <dholbach> And then you can do the same with your SSH key.
 139 [16:38] <dholbach> Open https://launchpad.net/~/+editsshkeys in a web browser, also open ~/.ssh/id_rsa.pub in a text editor.
 140 [16:39] <dholbach> Make sure it's ~/.ssh/id_rsa.pub (public part) and not ~/.ssh/id_rsa (secret part)
 141 [16:39] <dholbach> :)
 142 [16:39] <dholbach> This is the public part of your SSH key, so it is safe to share it with Launchpad. Copy the contents of the file and paste them into the text box on the web page that says “Add an SSH key”. Now click “Import Public Key”.
 143 [16:39] <dholbach> For more information on this process, visit the creating an SSH keypair page on Launchpad: https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair
 144 [16:39] <ClassBot> thotp asked: might the GPG key changes when i re-install the operating system?
 145 [16:40] <dholbach> thotp: it might be worth backing up the ~/.gnupg directory
 146 [16:40] <dholbach> you should be able to just copy it back
 147 [16:40] <dholbach> The last thing I wanted to mention briefly - I know we rushed through a lot, so I want to make some time for more questions - is setting up Bazaar, which should be pretty quick.
 148 [16:40] <dholbach> Bazaar is the tool we use to store code changes in a logical way, to exchange proposed changes and merge them, even if development is done concurrently. It is used for the new Ubuntu Distributed Development method of working with Ubuntu packages.
 149 [16:41] <dholbach> o tell Bazaar who you are, simply run:
 150 [16:41] <dholbach>   bzr whoami "Bob Dobbs <subgenius@example.com>"
 151 [16:41] <dholbach>   bzr launchpad-login subgenius
 152 [16:41] <dholbach> whoami will tell Bazaar which name and email address it should use for your commit messages. With launchpad-login you set your Launchpad ID. This way code that you publish in Launchpad will be associated with you.
 153 [16:41] <dholbach> Again: If you can not remember the ID, go to https://launchpad.net/~ and see where it redirects you. The part after the “~” in the URL is your Launchpad ID.)
 154 [16:42] <dholbach> And that should be pretty much it.
 155 [16:42] <dholbach> One thing you also might want to do is open the "software properties" and make sure the "Sources" part is checked. This will let you download sources from all packages in Ubuntu easily.
 156 [16:43] <dholbach> or just make sure you have   deb-src   lines in /etc/apt/sources.list
 157 [16:43] <ClassBot> eklok asked: what keeps you motivated to programm/debug? isnt it exhausting to deal with this every day. I want to motivate myself but i always fail
 158 [16:43] <dholbach> eklok, the people and the feeling that if a bug is fixed, it's not just fixed for me but for many millions of users out there
 159 [16:43] <dholbach> also do I learn something new all the time, which is great
 160 [16:44] <dholbach> of course it can be hard to solve a problem, but you can always ask for help
 161 [16:44] <ClassBot> man_let asked: what if 2 ppl have the same public key?
 162 [16:44] <dholbach> man_let, there have been collisions of gpg keys already, but they are very rare - can somebody dig out a link about this?
 163 [16:44] <ClassBot> nja asked: What can I do if I have 2 subkeys.  How do I know which one to delete?
 164 [16:45] <dholbach> I hope http://www.gnupg.org/gph/en/manual.html#AEN282 can help you with it
 165 [16:45] <dholbach> Any more questions? :)
 166 [16:46] <ClassBot> nja asked: Can I not see what one was created most recently?
 167 [16:46] <dholbach> If you mean GPG, I'm afraid I don't have the answer right now. Maybe somebody in #ubuntu-classroom-chat or #ubuntu-motu can help.
 168 [16:46] <dholbach> Sorry
 169 [16:47] <dholbach> If you followed all the instructions, the following example should work:
 170 [16:47] <dholbach> Please run:
 171 [16:47] <dholbach>   bzr branch ubuntu:hello
 172 [16:47] <dholbach> This will give you a Bazaar branch of the "hello world" package in Ubuntu and all its revisions in Ubuntu.
 173 [16:47] <dholbach> then please:
 174 [16:47] <dholbach>   cd hello
 175 [16:48] <dholbach>   bzr bd -- -S
 176 [16:48] <dholbach> which will build a source package from the branch - so it will recreate what the original source was and what we need to modify to make it build the "Debian or Ubuntu way"
 177 [16:49] <dholbach> if you type    ls ..    it should show you something like this:
 178 [16:49] <dholbach> hello_2.8-2.debian.tar.gz  hello_2.8-2_source.changes
 179 [16:49] <dholbach> hello_2.8-2.dsc            hello_2.8.orig.tar.gz
 180 [16:49] <dholbach> now please run:
 181 [16:50] <dholbach>   pbuilder-dist quantal build ../hello_2.8-2.dsc
 182 [16:50] <dholbach> This will build the package from the source in our shiny new pbuilder instance.
 183 [16:50] <dholbach> It will first download relevant build-dependencies (so packages required to build the package), then perform the build.
 184 [16:50] <ClassBot> There are 10 minutes remaining in the current session.
 185 [16:51] <dholbach> The resulting package then should be available in ~/pbuilder/quantal_result/
 186 [16:51] <ClassBot> nja asked: When running bzr bd -- -s: Help - http://paste.ubuntu.com/1172150/
 187 [16:51] <dholbach> Yes, that's a warning which is safe to ignore:
 188 [16:51] <dholbach> gpg: skipped "Santiago Vila <sanvila@debian.org>": secret key not available
 189 [16:51] <dholbach> gpg: /tmp/debsign.16cckC0A/hello_2.8-2.dsc: clearsign failed: secret key not available
 190 [16:52] <dholbach> It merely means that the last person who worked on the package (cf debian/changelog) was Santiago Vila, whose GPG key you obviously don't have.
 191 [16:52] <dholbach> We could have added "-us -uc" to the "bzr bd -- -S" command which would have avoided this
 192 === prashanth92 is now known as prashanth
 193 [16:52] <dholbach> but it's safe to ignore.
 194 [16:53] <dholbach> In this small examples (just 3-4 commands) we went from source branch (all revisions in Ubuntu are stored in there), to source package (just the latest source revision as tarball and additional modifications - this is what we use to upload to Launchpad for builds) then then the resulting binary (.deb) packages
 195 [16:54] <dholbach> This is obviously just a taster, so I hope you will find many interesting things in the next sessions which will take you further on your way to joining the Ubuntu Developers.
 196 [16:54] <dholbach> Just do me one favour: bookmark http://developer.ubuntu.com/packaging/html/
 197 [16:55] <dholbach> and stay up to date by following @ubuntudev on identi.ca/twitter.com/facebook.com/gplus.to
 198 [16:55] <ClassBot> marcosb asked: -us -uc is not for pubilder? or really is for bzr?
 199 [16:55] <ClassBot> There are 5 minutes remaining in the current session.
 200 [16:55] <dholbach> marcosb, yes, not for pbuilder, but for bzr bd (everything behind the '--' is passed to debuild/dpkg-buildpackage internally)
 201 [16:56] <dholbach> I hope you give Ubuntu development a go, learn a lot, make the world a better place and make a bunch of friends. :)
 202 [16:57] <dholbach> Any last 2-3 questions before Oliver "ogra" Grawert takes over to talk about ARM?
 203 [16:57] <ClassBot> nja asked: After running "bzr bd -- -S -us -uc" now what?  I'm really behind now.
 204 [16:57] <dholbach> nja, pbuilder-dist quantal build ../hello_2.8-2.dsc
 205 [16:58] <dholbach> but you should be able to find this in the docs (http://developer.ubuntu.com/packaging/html/) as well
 206 [16:58] <dholbach> and in the logs which will go up on https://wiki.ubuntu.com/UbuntuDeveloperWeek later on
 207 [16:58] <ClassBot> marcosb asked: another session to create patches for hello package? :)
 208 [16:58] <dholbach> marcosb, yes it would have been too much to squeeze into 2 hours :)
 209 [16:58] <ClassBot> alucardni asked: how can I tell to bzr bd to use pbuilder to build a binary package?
 210 [16:59] <dholbach> alucardni, it's two separate commands - a pbuilder plugin for bzr might be a good idea :)
 211 [16:59] <dholbach> but I don't know if it exists :)
 212 [17:00] <dholbach> All the best everyone! Hope to see more of you soon!
 213 [17:00] <dholbach> ogra_, your stage :)

MeetingLogs/devweek1208/GettingSetUpForUbuntuDev (last edited 2012-08-29 10:31:17 by dholbach)