Cum să peticești un rpm (patch rpm)

Monday, November 30, 2009

O să vă descriu cum am aplicat un petec pentru unul dintre pachetele pentru care sunt responsabil la fedora: calibre, în timp ce așteptam să-mi vină pizza http://www.fedoraproject.ro/am-lansat-fedora-12-avans . Petecul este răspunsul la un bug report: https://bugzilla.redhat.com/show_bug.cgi?id=537525 . Calibre verifică de fiecare dată când este pornit dacă pe situl oficial a apărut o nouă versiune și dacă a apărut, îl anunță pe utilizator printr-un pop-up că trebuie să actualizeze aplicația. Cum fedora are propriul management al pachetelor și deci și al actualizărilor, este recomandat ca pachetele noi să fie instalate folosind yum; deci mesajul trebuie eliminat.

Mai întâi trebuie să descărcăm sursele actuale ale rpm-ului (în momentul în care am scris patchul, în repo-uri cea mai recentă versiune era 0.6.21-1, acum ar trebui să fie una cu patchul deja aplicat):

  $ yumdownloader --source calibre

și să le despachetăm:

  $ rpm -ivh calibre-0.6.21-1.fc12.src.rpm

Comanda va crea un nou director rpmbuild, cu subdirectoarele SPECS și SOURCES. În SPECS avem fișierul care ține toate informațiile despre cum se va construi pachetul: calibre.spec, iar în SOURCES avem sursele pachetului și toate patchurile pe care le-am creat până acum:

  $ tree rpmbuild/
  rpmbuild/
  |-- SOURCES
  |   |-- calibre-0.6.21-nofonts.tar.gz
  |   |-- calibre-cssprofiles.patch
  |   |-- calibre-manpages.patch
  |   `-- generate-tarball.sh
  `-- SPECS
  `-- calibre.spec

Mai avem de făcut un pas, ca să putem umbla prin sursele programului. Trebuie să dezarhivăm arhiva calibre-0.6.21-nofonts.tar.gz. Următoarea comandă dezarhivează și aplică patchurile pe care le avem deja:

  $ cd rpmbuild/SPECS
  $ rpmbuild -bp calibre.spec

Au apărut mai multe directoare după comanda asta:

  $ ls rpmbuild/
  BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

Cel care ne interesează este BUILD, în care au apărut sursele peticite ale programului.

Atunci când e pornit, dacă există o versiune mai nouă, calibre va afișa următorul mesaj în fereastra pop-up:

calibre has been updated to version 0.6.24. See the new features. Visit the download page?

Ca să aflăm din ce fișier vine fereastra de pop-up putem să căutăm pur și simplu o parte din textul de mai sus în sursele calibre:

  $ cd rpmbuild/BUILD/calibre/
  $ find .|xargs grep "has been updated"

Dacă ignorăm fișierele de localizare, vom afla sursa pop-up-ului:

  ./calibre/src/calibre/gui2/main.py:                    _('%s has been updated to version %s. '

Mergând în fișierul respectiv vedem că acel cod face parte dintr-o funcție numită update_found:

 
  def update_found(self, version):
  os = 'windows’ if iswindows else 'osx’ if isosx else 'linux’
  url = 'http://%s.kovidgoyal.net/download_%s’%(__appname__, os)
  self.latest_version = '<br />' + _(&#8217;<span style="color:red; font-weight:bold">'
    'Latest version: <a href="%s"><span>s</span></a></span>')(url, version)
  self.vanity.setText(self.vanity_template%\
  (dict(version=self.latest_version,
  device=self.device_info)))
  self.vanity.update()
  if config.get('new_version_notification&#8217;) and \
  dynamic.get('update to version %s&#8217;%version, True):
  if question_dialog(self, _('Update available&#8217;),
  <em class="”’%s" has="has" been="been" updated="updated" to="to" version="version"><a href="“http://calibre.kovidgoyal.net/wiki/’">new features</a>. Visit the download pa&#8217;
  'ge?&#8217;&#8221;>%(</em>_appname__, version)):
  url = 'http://calibre.kovidgoyal.net/download_&#8217;+\
  ('windows&#8217; if iswindows else 'osx&#8217; if isosx else 'linux&#8217;)
  QDesktopServices.openUrl(QUrl(url))
  dynamic.set('update to version %s&#8217;%version, False)

Ne interesează ca modificarea pe care o vom aduce să fie cât mai lizibilă pentru cei care vor modifica pachetul nostru mai târziu și să fie cât mai ușor de revenit la versiunea nemodificată. Dacă ne uităm mai atent în main, găsim următorul cod:

  if not opts.no_update_check:
  self.update_checker = CheckForUpdates()
  QObject.connect(self.update_checker,
  SIGNAL('update_found(PyQt_PyObject)'), self.update_found)
  self.update_checker.start()

Codul verifică dacă programul a fost pornit cu opțiunea no_update_check. Ar complica prea mult lucrurile dacă am modifica programul în așa fel încât să pornească de fiecare dată cu opțiunea asta așa că mai bine comentăm codul aici, ca să nu mai verifice opțiunea și deci să nu mai caute niciodată update-uri. E soluția cea mai simplă.

Ca să facem un petec ca la carte, vom face așa:

Facem o copie a fișierului main.py:

  $ cd ~/rpmbuild/BUILD/calibre/src/calibre/gui2/
  $ cp main.py main.py.no_update
  După care modificăm *fișierul inițial* și comentăm codul respectiv așa:
  # if not opts.no_update_check:
  #     self.update_checker = CheckForUpdates()
  #     QObject.connect(self.update_checker,
  #             SIGNAL('update_found(PyQt_PyObject)'), self.update_found)
  #     self.update_checker.start()

Ca să generăm petecul vom folosi gendiff din directorul de deasupra directorului rădăcină:

    $ cd ~/rpmbuild/BUILD
    $ gendiff calibre .no_update
    diff -up calibre/src/calibre/gui2/main.py.no_update calibre/src/calibre/gui2/main.py
    --- calibre/src/calibre/gui2/main.py.no_update	2009-11-16 14:21:55.200387171 +0200
    +++ calibre/src/calibre/gui2/main.py	2009-11-16 14:22:10.400510757 +0200
     -221,11 +221,11  class Main(MainWindow, Ui_MainWindow, De
    self.latest_version = ' '
    self.vanity.setText(self.vanity_template%dict(version=' ', device=' '))
    self.device_info = ' '
    -        if not opts.no_update_check:
    -            self.update_checker = CheckForUpdates()
    -            QObject.connect(self.update_checker,
    -                    SIGNAL('update_found(PyQt_PyObject)'), self.update_found)
    -            self.update_checker.start()
    +        # if not opts.no_update_check:
    +        #     self.update_checker = CheckForUpdates()
    +        #     QObject.connect(self.update_checker,
    +        #             SIGNAL('update_found(PyQt_PyObject)'), self.update_found)
    +        #     self.update_checker.start()
    ####################### Status Bar #####################
    self.status_bar = StatusBar(self.jobs_dialog, self.system_tray_icon)
    self.setStatusBar(self.status_bar)

Totul arată bine, deci putem să-l punem în surse:

  $ gendiff calibre .no_update > ~/rpmbuild/SOURCES/calibre-no-update.patch
  

Acum trebuie să modificăm spec-ul, adăugând un nou petec, incrementând release-ul, menționând motivul pentru petec și scriind modificarea în Changelog:

   -1,6 +1,6 
  Name:           calibre
  Version:        0.6.21
  -Release:        1%{?dist}
  +Release:        2%{?dist}
  Summary:        E-book converter and library management
  Group:          Applications/Multimedia
  License:        GPLv3
   -18,6 +18,7 
  Source1:        generate-tarball.sh
  Patch0:         %{name}-cssprofiles.patch
  Patch1:         %{name}-manpages.patch
  +Patch2:         %{name}-no-update.patch
  BuildRoot:      /{name/del>{releaseroot({__id_u} -n)
  BuildRequires:  python >= 2.6
   -72,6 +73,9 
  # don’t append calibre1 to the name of the manpages. No need to compress either
  %patch1 -p1 -b .manpages

+# don’t check for new upstream version (that’s what packagers do) +%patch2 -p1 -b .no-update + # dos2unix newline conversion %{__sed} -i 's/\r//’ src/calibre/web/feeds/recipes/* -239,6 +243,9 %{_mandir}/man1/* %changelog +* Sat Nov 29 2009 Ionuț C. Arțăriși – 0.6.21-2 +- patch to stop checking for new upstream version + * Sat Nov 6 2009 Ionuț C. Arțăriși – 0.6.21-1 – new upstream version: http://calibre.kovidgoyal.net/wiki/Changelog#Version0.6.2106Nov2009 – added python-BeautifulSoup requirement

Gata. Asta a fost tot :). Acum putem reconstrui pachetul cu noile patchuri:

  $ cd ~/rpmbuild/SPECS/
  $ rpmbuild -ba calibre.spec

Și putem reinstala noul pachet:

  $ su -c "yum localinstall -y --nogpgcheck ~/rpmbuild/RPMS/x86_64/calibre-0.6.21-2.fc12.x86_64.rpm"
  
View Comments post separator

Emacs la Ceata

Tuesday, August 18, 2009

Să folosesc blogul ăsta și altfel decât până acum.

Dacă mă are cineva în feed reader și vrea să meargă la o mică (o juma’ de duzină de oameni) prezentare emacs în politehnică, cu oamenii din Ceata (probabil e stricat situl în momentul ăsta), știți cum să mă contactați. Întâlnirea va avea loc mâine probabil după ora 18 în sediul Cetei din unul din căminele din Poli.

Ceata e o organizație de studenți din Politehnică interesați de tehnologii libere.

View Comments post separator

FUDCon Berlin

Monday, June 29, 2009

I just got back from this year’s EMEA FUDCON in Berlin with Nicu . I didn’t have time to write anything while I was there because so much was happening all the time.

FUDCon and LinuxTag

LinuxTag wasn’t really the purpose of our visit, but we got free tickets so I checked the place out for a while. There were lots of booths and some speeches (mostly in German). There were also some activities, but I really didn’t get to any of them since most appeared to be German-only. I was a bit disappointed, eLiberatica had way better talks and guests.

FUDCon was nice. The first day was a little slow to start, but the BarCamp session the next day was very interesting and diverse. More of that would’ve been nice. Some of the cool topics I enjoyed were: koji at CERN, git for hackers, Fedora EKG and UI Design. The last day was mostly random hacking by people who already had something to work on. I did a bit of pkgdb hacking on my own and then went Berlinxploring.

Berlin

The city was awesome. I haven’t been to a lot of different countries, but right now Berlin is my favourite. Its public transportation is awesome, the people are polite, friendly and everyone can speak English. There were a lot of trees everywhere, the temperature was really cool and there were wild bunnies in the parks! I separated from the crowd two times to go visit the city and I got to see some stuff I would’ve missed otherwise. It was also cool because what I did was basically ride the train and get off whenever I would see something interesting. I went to the Brandenburg gate and the Governmental district and also got a closer look of the bombed church. I also went to a cool flea market.

German Beer

The best part of the whole conference were the nights out at the restaurant, I think. I and Nicu were lucky to tag along to a few people from Red Hat before the majority of people had arrived. We got to see some nice places that way, especially thanks to Jesse’s iphone. I got to eat indian food, assembly line sushy and we were also at the local Zoo. I soon found out that my English was a bit slow and so I couldn’t keep up with their constant witty joking so I sort of gave up and switched into listening mode.
The nights-at-the-restaurant got better and better as more people arrived. We went to a small restaurant right under the railways for free pizza (thanks Red Hat!) where I met a few of the newly arrived people and had some interesting chats mostly about fedora and Red Hat.
The next day we went looking for a Sudanese restaurant, but ended up at a Cuban restaurant with cool waitresses. I got to taste the first real German beer and socialised with some of the other European guys which was really fun.
The last night was the best night. We had interesting discussions about fonetics(!), German beer, the Dutch language and RMS among other things. They also had the greatest dark German beer, which I forgot the name of. Real traditional German beer really doesn’t compare with any other beer. It’s a whole different beverage and an awesome one.

Conclusion

Overall I think it was a great experience. I got to meet a lot of interesting and smart people from all over the world who all shared a passion for their work and for Fedora.
So these are sort of the words to Nicu’s photos which explain the rest, only better.

View Comments post separator

eLiberatica - the aftermath!

Sunday, May 24, 2009

Wow, what an event! It was way more awesome than I expected. This is probably one of the later posts to get to the planet from eLiberatica because I wanted to form a complete opinion on the event.

eLiberatica is the first big open source and free software conference I’ve been to. The scale of it is quite amazing for something this far East in Europe and especially for my country. Some high-profile guest even said that he was astonished at the presence of very influential, key FLOSS personalities that aren’t present at some bigger events.
the booths

We (ajoian , nicubunu, alexxed and myself) had a whole booth for fedora and we really made the best of that opportunity, I think. We had a lot of SWAG. Nicu had printed some posters for the event which really helped beautify the booth and had also printed some fedora business cards for each of us. We had fedora t-shirts and a lot of CDs sent by Max (thanks Max!). These were the most helpful for starting conversations with passers-by. We even helped out the Ubuntu people when they ran out of cds on the first day!

The booth activity was more fun than I had expected. I didn’t think I would enjoy talking to people about fedora so much. We had people ask us to come to their town and “do something about fedora”. We told them we’d come and hold presentations when they would be ready and we gave them some free LiveCDs to spread around in the meantime. I hope we’ll have some new local fedora communities spring up. I’m especially hopeful of the guys from Iași who are active contributors to different opensource projects, mostly xwiki .

There were two other cool booths that were very engaging with the passers-by: the Mozilla booth and the Romanian Free Software Communities booth which was more of an Ubuntu booth actually, but that was good since a lot of people were interested in that.
the speakers

I only went to a few speeches as the booth activity and the new people I met were too engaging. I think Jeroen‘s speech was awesome and his message was very clear. It was a great complement to the discourse we were holding at the booth – telling people that fedora is all about contributing, not just using a stable, already tested linux distribution. A lot of people were ubuntu users, especially the ones in the Politehnica University (the host of the event) who are taught Ubuntu in class (there are no linux machines at my university :| ). Everyone kept asking how fedora is better than ubuntu. It was an honest question since many of them didn’t have experience anything else and I hope we succeeded in getting our message accross.

There were other awesome people, too. There was Monty – the founder of MySQL who told us about his new project to give MySQL back to the community: MariaDB . There was the president of fsfe and the OpenSource Diva – Danesse Cooper who both gave great philosophical speeches. There was David Axmark who had a great presentation about his awesome new project to create a stripped-down version of MySQL for webshops called Drizzle – I think this will be a great project to watch evolve. I didn’t get to spend too much time on the openagile track, but I went to Corey Haines ‘s talk about software craftsmanship in an agile context which I enjoyed.
the friends

contributors
The most awesome part of the entire conference, I think, were the people I met. There were a lot of people I only knew from online discussions. Some of them I had known for years, but had never met. I had a revelation with a couple of people who I didn’t like online, but prooved to be very nice people in real life.

I met some fellow Romanian Google Summer of Code guys for this year and last year with whom I hope to meet again.
I met a few Eau de Web guys – a small python/zope web company especially Alex who’s blog I had been reading and who turned out to be an even cooler guy than I expected. We discussed a lot of interesting python things. (I almost got him to switch from his OS X + virtual Debian setup to fedora. But I hope I’ll have another swing at it soon).
I met an old friend, Vlad who gave me an awesome idea for an enhancement to the fedora business cards that I’ll hopefully have time to implement this summer.
The guys from the other Romanian communities were cool people and I hope we’ll interact better and do more awesome FLOSS stuff now that we’ve met face to face. These were people from Software Liber, rosedu and the cool lonely guy from openSUSE Romania who had a taste of our fedora CDs, literally (the opensuse community is just starting out in Romania).
Last, but not least, the Romanian Fedora community was awesome. We got along really well and had a lot of fun. We made some really nasty videos with the fedora sign that I was going to post, but I changed my mind when I actually looked at them :), you can look at nicubunu’s pictures, though.
miscellaneous

I added 3 more O’Reilly books to my I hope I’ll read them this summer reading list: Beautiful Code, Masterminds of Programming and SQL and the Relational Theory.

This conference and the people I talked to really influenced me I think, career-wise. I got a lot of motivation and a great yearning to sometime be able to work with people such as the ones I met there. I’ll probably slip into a bit of a depression now that the event is over and I’m going back to real life and ignorant school people. That’ll hopefully be over in less than two weeks and I’ll have time to work work work == fun fun fun for the Fedora Project.

The good news is I’m going to FUDCon Berlin with Nicu. I hope to meet a lot of cool fedorians there aswell.

View Comments post separator

Fedora Business Cards

Friday, April 24, 2009

A few days ago, me and a few friends from Fedora Romania decided we’d like some fedora business cards for the upcoming eLiberatica conference. Ian Weller had already developed an official template and even created a cool python generator script and packaged it.

The problem, however, was that it only supported US-style business cards which are a bit smaller than the Romanian/Central European ones. Live and learn‌ It seems that there are a lot of different sizes actually.

So I got my hacking hat and dived in. The code was quite nice to look at and easy to understand. The XML in the svg templates is quite easy to hack, too. Especially when using tools like python’s minidom . It makes working with python and XML taste like javascript dom manipulation which is quite nice.

Everything went smooth, I renamed a few tags, made some modifiable (for height and width), but then I had to make the blue strip on the right of the front of the business card extendable1 . There is no way in XML to align an element to the right so I spent about an hour coming up with a sweet solution. Instead of having a big white background on which I would apply the blue band, I made a big blue background and made the white background just a little narrower. Because the white background was on top of the blue one, it could get aligned to the left (x=0, y=0 in XML) and cover just the part that needed to be white, and left a blue band at the right. Problem solved. Hoo-grah!

Now I’m waiting for an answer to the patch that I sent to bugzilla. Hopefully it’ll be accepted and will be available in Fedora, soon, so that others may enjoy and cherish the coolness that it be!

View Comments post separator

GSOC - it begins...

Thursday, April 23, 2009

My Fedora proposal got accepted to this year’s Google Summer of Code Program. You can look at a short abstract here . Now I’m going to try to explain what this project is about and what I did to prepare for being accepted, hopefully without going mad about how happy I am about it.

I started work on the Fedora Project almost a year ago. One day I popped on the mailing list and then on the irc channel of the infrastructure team and asked for something to do. Luckily, Toshio Kuratomi was on the watch and after giving me a short tour of the various projects he could help me get familiar with, I picked the package database. Most of the work I’ve done so far is in the pkgdb (the search capability is the most obvious thing I worked on). The overview on the front page describes it quite well; it’s got package information and it’s aimed at package developers. It’s not a very famous part of the fedora project websites, certainly not as famous as something like packages.ubuntu.com is for ubuntu. But that’s not what it was intended for, even if that’s what attracted me to the project at first. I liked the exposure of such a website, but also the fact that, at the time, it was easier for me to understand what it did and how it worked :).

The idea of making the package database more user-friendly as opposed to developer-centric wasn’t a new one. Toshio, the main developer had been thinking about it for a long time, but I guess it never really became a priority. The idea had also been proposed for last year’s GSOC, but it hadn’t been accepted (this scared me a bit when I found out). I picked this idea on a whim when I told Toshio I wanted to participate in this year’s GSOC on pkgdb and he asked me what exactly I wanted to do. I wasn’t expecting the question, so I answered with the first thing that came to mind. Looking back, I think it was a good choice.

All my involvement with the Fedora Project owes a lot to the best possible person who could have become my mentor for GSOC. The Infrastructure Team is a great one to work with, and the Fedora contributor community is made up of a lot of smart, fun and selfless people. I say this after having spent a lot of time lurking the IRC channels, the various mailing lists, the planet etc. and to a somewhat lesser extent interacting with other contributors. However, I wouldn’t have continued contributing if it weren’t for the continuous support and guidance of Toshio. I probably wouldn’t have been able to participate in the GSOC without the many discussions (starting in February) with Toshio about the proposal and the support when explaining the idea to other community members. Having said that, I think that being familiar with the pkgdb also helped a lot with writing the proposal. I didn’t have to waste time on getting to know the code, the community, the devs as I would have if I had written a proposal for a different project. I also had a fair idea of what would constitute a good proposal and a rough idea about how it could be implemented. I think this helped with my credibility in the eyes of the mentors who ranked my proposal.

I was never convinced I would get a spot on Fedora & JBoss’s accepted proposal’s list , but it was is a great thing to dream of. The butterflies in my stomach were killing me at the end of the waiting period, especially since it had lasted for more than 2 months. I now have a summer to work full time on my hobby :).

At the end of the summer, the fedora community will hopefully have a package database with package versions, size, dependencies, rss feeds, tagging, package reviews etc. There’s even a detailed schedule from my proposal you can drool on if you’re so inclined.

And hello, fedora planet! Sorry for being late.

View Comments post separator

the ultimate FreeBSD desktop (without a mouse)

Tuesday, February 3, 2009

I installed FreeBSD a few days ago, because I wanted to work on a distribution that’s famous for its code quality and good practices. I had been using Fedora for almost a year, after switching from ArchLinux which I think I had used for two years and various other Linux distros before that. I had messed around with various BSDs before (OpenBSD, NetBSD, FreeBSD), but none of them really stuck with me. One of the big reasons for switching was getting tired of not having a package for that new thing I just saw on reddit. I used to go search for it on freshports everytime and everytime it was already there.

After installing the base system, the first thing was to get some sort of WM(Window Manager) installed. I was in a bit of a hurry, anxious to get my new system ready, so I didn’t want anything big, like a DE(Desktop Environment) . Tiling WMs are the next big thing. WIMP is dead. I had played with dwm/wmii before, but these didn’t really stick then. I think there’s an effort to be made in order to change your desktop paradigm, just like when you’re changing your editor or anything else. You can’t just use it casually once a week and expect to become proficient with it in a month. It doesn’t work that way. At least not for me. These things cause a bit of a headache. It’s like cutting a limb. You’re brain needs to adapt your other senses and limbs to compensate for the loss. But in this case, when you cut your limb, you get a new cyber-robotic-megatron arm instead. You just need to figure it out how it works and your productivity will increase exponentially.

So i installed awesome , then switched to xmonad and then switched to dwm in a matter of minutes. I then opened up the configuration file for dwm, and changed some keybindings and some colors and two days later it feels like home.

Early on, as I got the tiling wm installed I thought about trying to live without my mouse. That’s hardcore productivity staring me in the face. Especially the hardcore part. I already had my vim/emacs editor so nothing to change there.

Browsing is a big part of our lives, and browsing can’t be done without a pointing device. Or could it? I installed vimperator . You have these nice key-bindings for moving around (j,k,C-d,C-u,search etc.), but how do you click links? Vimperator has this awesome feature called hinting that highlights and gives a number to each link on the screen when you press f. I think it’s actually faster than moving your mouse around. You can open a new link just by pressing o, a tab by pressing t. It knows you mean google if you just give it words instead of a url. It goes back and forth with C-o, C-i. It can do almost everything firefox can do and more without looking around through ugly menus. It’s even got macros! Granted, it takes some getting used to, but that’s the fun, right?

Everyone already knows irssi the irc client and mutt the email client. You can try those. Or you could use one of emacs’s. That’s the next big part of my plan. I’m going to be switching over to emacs after about 3 years with vim. I’m probably going to say other things about this move some other time, so I’ll just summarise my first thoughts until now. I want my editor to be everywhere I edit text. Vim is already in my blog posts and in my source files. But I want my editor in my email, in my shell, in my chat client and under my pillow. Emacs 22 has ugly fonts, but Emacs 23 has antialiased fonts and what do you know? FreeBSD’s got a port of the development version. All the carpal syndrome scare goes away once you remap Caps to be another Ctrl key. Read a lot of tutorials. Read a lot of high-profile users’ blog posts (like steve yegge’s ). Have a lot of commitment and you’ll do it.

Learning one of the two editors is a rewarding experience in itself. Vimtutor and the emacs tutorial are amazing. They’ll have you crackling once every few lines at the new magic powers you’ve just gained. They truly are great weapons in any mastermind-bent-on-world-domination’s arsenal.

The first few hours after the second few hours spent into the new environment are the most important. If you can get to this stage, the battle is almost won. The first session is the most troublesome. Your brain revolts and refuses to adapt to the new way . That’s why it’s most important to not give up. Spend the night with the new environment and go to sleep. The next day you have to be able to wake up in the same environment and everything will seem natural in a little while. Try it.

Next year I’ll go Dvorak .

View Comments post separator
Powered by pyblee