Loading ...
Sorry, an error occurred while loading the content.
 

Re: [hackers-il] Yet Another Hacktivity - An RPM Spec file for building Fortune Collections

Expand Messages
  • Tzafrir Cohen
    ... Let s examine it, then. The Name header is composed in three stages. 1. %define packageprefix fortune-mod-fortunes %define packagebase shlomif 2. %define
    Message 1 of 6 , Jun 1, 2002
      On Sat, 1 Jun 2002, OmerM wrote:

      > On Saturday 01 June 2002 15:52, Tzafrir Cohen wrote:
      > > On Sat, 1 Jun 2002, OmerM wrote:
      > > > On Saturday 01 June 2002 03:02, Shlomi Fish wrote:
      > > > > Included below is an RPM Spec for building a collection of fortune
      > > > > files. It is specific to my collection, but hopefully can be customized
      > > > > to other sources with relative ease.
      > > > >
      > > > > I plan to use it as the basis for my fortune2rpm hack, which I have
      > > > > some great plans for.
      > > > >
      > > > > Shlomi Fish
      > > > >
      > > > > #######################################
      > > > > # Base Macros which need to be set
      > > > > %define packageprefix fortune-mod-fortunes
      > > > > %define packagebase shlomif
      > > > > %define archivebase fortunes-shlomif
      > > > > %define version 0.2.2
      > > > > %define fortunefilesprefix shlomif-
      > > > >
      > > > > # Derived Macros
      > > > > %define name %{packageprefix}-%{packagebase}
      > > > > %define archivewithver %{archivebase}-%{version}
      > > > > %define archivefull %{archivewithver}.tar.gz
      > > > > Name: %{name}
      > > > > Version: %{version}
      > > > > Release: 6
      > > > > Copyright: Free to use but restricted
      > > > > Group: Toys
      > > >
      > > > Speaking of suboptimal design decisions that are to happen when
      > > > some other guys do not put their best in finding optimal algorithms:
      > > >
      > > > Do you always define 3 level of indirection to put a literal string
      > > > that will be used once?
      > >
      > > You obviously didn't write many makefiles ;-)
      >
      > Actually, I did not:) I'm using Teamware and mkmf at work and have to worry
      > about design and performance of my programs,not my makefiles.
      >
      > However, I did write enough code to have my too-complicated-without-a-reason
      > bit set while seing three levels of naming when one direct name would suffice.
      >
      > > Considering that this is going to be processed by RPM to produce a number
      > > of shell scripts that spits a lot of output, that redirection is
      > > negligble.
      >
      > I do not buy this statement. In similar manner, considering that email message
      > is going to be broken to bits, transformed from one endiness to the other and
      > after all displayed as an array of pixels, logic errors in a message are
      > neglible.
      >
      > Considering that a program file will be broken to sequence of zeros and ones,
      > design considerations are not relevant.
      >
      > I disagree with abovementioned attitude.
      >
      > >
      > > There are also quite a few levels of redirection in /usr/lib/rpm/macros
      > >
      > > However, it helps to make the code more maintainable. You can never know
      > > when the name is going to be used again.
      >
      > I disagree with that point too. Either you do know what youdo with a name or
      > you do not know. If you do not know what you do with a name, then you do not
      > know well the code that you had written.

      Let's examine it, then.

      The Name header is composed in three stages.

      1. %define packageprefix fortune-mod-fortunes
      %define packagebase shlomif

      2. %define name %{packageprefix}-%{packagebase}

      3. Name: %{name}


      Actually, I believe that with a better look at the specifications of RPM
      it would turn out that (2) is unnecessary, because the Name header can be
      used directly. However, assuming it is not, you may need to reuse the name
      of that header somewhere later.

      Therefore if you want to use the name of the package later (for instance:
      as part of the README, part of the description, or be used in one of the
      scripts: all of those are very useful in a template spec, which Shlomi
      seems to have in mind, and can be useful in some other places) you need to
      give a seperate definition for it.

      Therefore it has become a standard part of spec files (at least of those
      authored by mandrake, which is probably the example Shlomi used).

      So it has an obvious atvantage of code maintainability, and negligble
      performance price, since rpm already does much more, and wastes much more
      time, anyway.

      Does this answer your question?

      --
      Tzafrir Cohen
      mailto:tzafrir@...
      http://www.technion.ac.il/~tzafrir
    Your message has been successfully submitted and would be delivered to recipients shortly.