43 | | }}} |
44 | | |
45 | | = Example of use on LinuxCOE (more complex example) = |
46 | | |
47 | | When the project was mature enough to package correctly mondorescue and itself, I then decided it was time to try it on another unrelated project to see how difficult it could be and document that experience so that others could also begin to use pb for their own project. |
48 | | |
49 | | You first have to edit your .pbrc configuration file in your home directory, which will setup things globally. |
50 | | |
51 | | Here are my .pbrc LinuxCOE relative entries: |
52 | | {{{ |
53 | | $ grep -E '^#|linuxcoe|default' ~/.pbrc |
54 | | # |
55 | | # Root of the temp file used to store info on the project |
56 | | # Is also used to determine the root directory of the project |
57 | | # No default option allowed here as they need to be all different |
58 | | # |
59 | | pbrc linuxcoe = /users/bruno/LinuxCOE/cvs/pbrc |
60 | | # |
61 | | # Which CMS system is used |
62 | | # |
63 | | cms linuxcoe = cvs |
64 | | cms default = svn |
| 49 | $ rm -f /tmp/netperf-2.4.4.tar.bz2 |
| 50 | }}} |
| 51 | |
| 52 | The netperf project is a nice project using a simple environment to build itself. It uses the GNU autoconf/autmake/litool mecanism, which makes it easy to package with pb. |
| 53 | |
| 54 | You will now need to get the latest and greatest project-builder software from our [ftp://ftp.project-builder.org ftp] repository. Of course we provide lots of packages for your distribution ;-) Or a tar.gz file if you prefer. Once available, you can use the newproj option of pb to create the infrastructure that is mandatory for pb. It is mandatory that there is a correspondance between the directory mentioned in $HOME/.pbrc and the -r option: |
| 55 | |
| 56 | {{{ |
| 57 | $ pb -p netperf -r `pwd` newproj |
| 58 | Creating /users/bruno/netperf/src/pbconf directory |
| 59 | |
| 60 | Do not to forget to commit the pbconf directory in your CMS if needed |
| 61 | After having renamed the pkg1 directory to your package's name |
| 62 | |
| 63 | Project: netperf |
| 64 | Action: newproj |
| 65 | }}} |
| 66 | |
| 67 | Explore then the pbconf directory to familiarize yourself with some of the config file. the next one we want to edit, is the main configuration file which will be used as the central piece of information for pb. |
| 68 | |
| 69 | Edit it and adapt it. After edition, here is the resulting file: |
| 70 | {{{ |
| 71 | $ ls -R pbconf |
| 72 | pbconf: |
| 73 | netperf.pb pbfilter pkg1 |
| 74 | |
| 75 | pbconf/pbfilter: |
| 76 | all.pbf deb.pbf md.pbf novell.pbf rpm.pbf |
| 77 | |
| 78 | pbconf/pkg1: |
| 79 | deb pbfilter rpm |
| 80 | |
| 81 | pbconf/pkg1/deb: |
| 82 | changelog compat control copyright pkg1.dirs pkg1.docs rules |
| 83 | |
| 84 | pbconf/pkg1/pbfilter: |
| 85 | |
| 86 | pbconf/pkg1/rpm: |
| 87 | pkg1.spec |
| 88 | $ |
| 89 | $ vi pbconf/netperf.pb |
| 90 | [Modifications here] |
| 91 | $ cat pbconf/netperf.pb |
| 92 | # |
| 93 | # Project Builder configuration file |
| 94 | # For project netperf |
| 95 | # |
| 96 | # $Id$ |
| 97 | # |
| 98 | |
| 99 | # |
| 100 | # Which CMS system is used (Subversion, CVS or tar file content extracted) |
| 101 | # |
| 102 | #cms netperf = svn |
| 103 | #cms netperf = cvs |
| 104 | cms netperf = flat |
| 105 | |
85 | | vmtype default = qemu |
86 | | }}} |
87 | | |
88 | | Should be obvious for the content. Note that the format is in general |
89 | | {{{ |
90 | | pb-keyword project = value |
91 | | }}} |
92 | | which means that here I named my project for pb linuxcoe (I can choose what I want be need to be consistent everywhere). |
| 132 | vmtype netperf = qemu |
| 133 | |
| 134 | # Hash for VM stuff on vmtype |
| 135 | vmntp default = pool.ntp.org |
| 136 | |
| 137 | # We suppose we can commmunicate with the VM through SSH |
| 138 | vmhost netperf = localhost |
| 139 | vmlogin netperf = pb |
| 140 | vmport netperf = 2225 |
| 141 | |
| 142 | # Timeout to wait when VM is launched/stopped |
| 143 | vmtmout default = 120 |
| 144 | |
| 145 | # per VMs needed paramaters |
| 146 | vmopt netperf = -m 384 -daemonize |
| 147 | vmpath netperf = /home/qemu |
| 148 | vmsize netperf = 5G |
| 149 | |
| 150 | # |
| 151 | # Global version/tag for the project |
| 152 | # |
| 153 | projver netperf = 2.4.4 |
| 154 | projtag netperf = 1 |
| 155 | |
| 156 | # Adapt to your needs: |
| 157 | # Optional if you need to overwrite the global values above |
| 158 | # |
| 159 | #pkgver pkg1 = stable |
| 160 | #pkgtag pkg1 = 3 |
| 161 | #pkgver nil |
| 162 | #pkgtag nil |
| 163 | |
| 164 | # Hash of default package/package directory |
| 165 | defpkgdir netperf = netperf-2.4.4 |
| 166 | |
| 167 | # Hash of additional package/package directory |
| 168 | #extpkgdir pkg1-doc = pkg1-docdir |
| 169 | |
| 170 | # Hash of valid version names |
| 171 | version devel |
| 172 | #version stable |
| 173 | |
| 174 | # List of files per pkg on which to apply filters |
| 175 | # Files are mentioned relatively to pbroot/defpkgdir |
| 176 | filteredfiles netperf = configure.ac |
| 177 | #filteredfiles pkg1-doc = configure.in |
| 178 | }}} |
| 179 | I skip the parameters begining with vm and ssh for the moment. I inform pb that I will produce packages with a version-tag of 2.4.4-1, that no local package should have a different version than the project version (pkgver/pkgtag), that my default package will be netperf (pb will work on it by default all the time) and that no additional packages will be produced. In addition to standard version with numbers, pb will accept the version devel. And finally, I give to pb the name of all files (per package) that it will have to filter to produce the packages - more on that later on. |
| 180 | Once this is done, you may already try to see if pb can make something useful for you. Check the result of: |
| 181 | |
| 182 | {{{ |
| 183 | $ pb -p netperf -r `pwd` cms2build |
| 184 | Project: netperf |
| 185 | Action: cms2build |
| 186 | Packages: netperf |
| 187 | |
| 188 | Management of netperf 2.4.4-1 (rev flat) |
| 189 | Exporting /users/bruno/netperf/src/netperf-2.4.4 from DIR to /users/bruno/netperf/delivery/netperf-2.4.4... OK |
| 190 | Build files generated for |
| 191 | No Build files found for mandriva-2006.0,sles-9,mandrake-10.2,mandriva-2007.0,rhel-3,mandriva-2007.1,redhat-9,ubuntu-6.06,suse-10.3,rhel-5,ubuntu-7.10,gentoo-nover,suse-10.2,mandrake-10.1,mandriva-2008.0,sles-10,fedora-6,suse-10.1,fedora-5,fedora-4,ubuntu-7.04,fedora-7,suse-10.0,debian-4.0,rhel-4,debian-3.1,redhat-7.3 |
| 192 | filter: no such variable |
| 193 | Can't use an undefined value as a HASH reference at /usr/lib/perl5/vendor_perl/5.8.8/ProjectBuilder/Base.pm line 1077. |
| 194 | }}} |
| 195 | Ok we tried to make a build file from ou Configuration Management System (CMS) which didn't work completely as our structure is incomplete. However, pb already recognized the project name, action, package to build, type of CMS (flat), used our -r option to create the intermediate delivery directory where all the final files|packages will be created. |
| 196 | |
| 197 | So now, in order to be more useful, we need to create the structure for our package. Luckily, pb did most of the work for us, by creating a template pkg1 directory and files under pbconf. Rename them to netperf (name of our package) and explore and adapt its content: |
| 198 | |
| 199 | {{{ |
| 200 | $ find . -name pkg1'*' |
| 201 | ./pbconf/pkg1 |
| 202 | ./pbconf/pkg1/rpm/pkg1.spec |
| 203 | ./pbconf/pkg1/deb/pkg1.dirs |
| 204 | ./pbconf/pkg1/deb/pkg1.docs |
| 205 | $ mv ./pbconf/pkg1 ./pbconf/netperf |
| 206 | $ mv ./pbconf/netperf/rpm/pkg1.spec ./pbconf/netperf/rpm/netperf.spec |
| 207 | $ mv ./pbconf/netperf/deb/pkg1.dirs ./pbconf/netperf/deb/netperf.dirs |
| 208 | $ mv ./pbconf/netperf/deb/pkg1.docs ./pbconf/netperf/deb/netperf.docs |
| 209 | }}} |
| 210 | |
| 211 | Now this is done, it's time to look at those and adapt them. At the begining, we try to make RPM packages. |
| 212 | {{{ |
| 213 | $ vi pbconf/netperf/rpm/netperf.spec |
| 214 | [Modifications here] |
| 215 | $ cat pbconf/netperf/rpm/netperf.spec |
| 216 | # |
| 217 | # $Id$ |
| 218 | # |
| 219 | |
| 220 | Summary: The netperf tool is a benchmarking network tool |
| 221 | Summary(fr): netperf est un outil de benchmark réseau |
| 222 | |
| 223 | Name: PBPKG |
| 224 | Version: PBVER |
| 225 | Release: PBTAGPBSUF |
| 226 | License: GPL |
| 227 | Group: PBGRP |
| 228 | Url: PBURL |
| 229 | Source: PBSRC |
| 230 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n) |
| 231 | Requires: PBDEP |
| 232 | |
| 233 | %description |
| 234 | PBDESC |
| 235 | |
| 236 | %description -l fr |
| 237 | netperf est un outil de benchmark réseau |
| 238 | |
| 239 | %prep |
| 240 | %setup -q |
| 241 | |
| 242 | %build |
| 243 | %configure |
| 244 | make %{?_smp_mflags} VERSION=%{version} |
| 245 | |
| 246 | %install |
| 247 | %{__rm} -rf $RPM_BUILD_ROOT |
| 248 | make DESTDIR=$RPM_BUILD_ROOT install |
| 249 | |
| 250 | %clean |
| 251 | %{__rm} -rf $RPM_BUILD_ROOT |
| 252 | |
| 253 | %files |
| 254 | %defattr(-,root,root) |
| 255 | %doc ChangeLog |
| 256 | %doc INSTALL COPYING README AUTHORS NEWS |
| 257 | |
| 258 | %changelog |
| 259 | PBLOG |
| 260 | }}} |
| 261 | |
| 262 | That spec file looks normal except that it uses a lot of PBSOMETHING keywords. Those are Project-Builder macros that will be instantiate depending on the distribution during the cms2build step. |
| 263 | |
| 264 | So now that we have the base for our spec file, we need to look at those filters: |
| 265 | |
| 266 | {{{ |
| 267 | $ vi pbconf/pbfilter/all.pbf |
| 268 | [Modifications here] |
| 269 | $ cat pbconf/pbfilter/all.pbf |
| 270 | # |
| 271 | # $Id$ |
| 272 | # |
| 273 | # Filter for all files |
| 274 | # |
| 275 | # PBSRC is replaced by the source package format |
| 276 | filter PBSRC = ftp://ftp.netperf.org/netperf/%{name}-%{version}.tar.gz |
| 277 | |
| 278 | # PBVER is replaced by the version ($pbver in code) |
| 279 | filter PBVER = $pbver |
| 280 | |
| 281 | # PBDATE is replaced by the date ($pbdate in code) |
| 282 | filter PBDATE = $pbdate |
| 283 | |
| 284 | # PBLOG is replaced by the changelog if value is yes |
| 285 | filter PBLOG = yes |
| 286 | |
| 287 | # PBTAG is replaced by the tag ($pbtag in code) |
| 288 | filter PBTAG = $pbtag |
| 289 | |
| 290 | # PBREV is replaced by the revision ($pbrev in code) |
| 291 | filter PBREV = $pbrev |
| 292 | |
| 293 | # PBPKG is replaced by the package name ($pbpkg in code) |
| 294 | filter PBPKG = $pbpkg |
| 295 | |
| 296 | # PBPACKAGER is replaced by the packager name ($pbpackager in code) |
| 297 | filter PBPACKAGER = $pbpackager |
| 298 | |
| 299 | # PBDESC contains the description of the package |
| 300 | filter PBDESC = "netperf is a network benchmarking tool" |
| 301 | |
| 302 | # PBURL contains the URL of the Web site of the project |
| 303 | filter PBURL = http://www.netperf.org |
| 304 | }}} |
| 305 | We can now try again to use pb to create our build file: |
| 306 | {{{ |
| 307 | $ pb -p netperf -r `pwd` cms2build |
| 308 | Project: netperf |
| 309 | Action: cms2build |
| 310 | Packages: netperf |
| 311 | |
| 312 | Management of netperf 2.4.4-1 (rev flat) |
| 313 | Exporting /users/bruno/netperf/src/netperf-2.4.4 from DIR to /users/bruno/netperf/delivery/netperf-2.4.4... OK |
| 314 | Build files generated for mandriva-2006.0,sles-9,mandrake-10.2,mandriva-2007.0,rhel-3,mandriva-2007.1,redhat-9,ubuntu-6.06,suse-10.3,rhel-5,ubuntu-7.10,suse-10.2,mandrake-10.1,mandriva-2008.0,sles-10,fedora-6,suse-10.1,fedora-5,fedora-4,ubuntu-7.04,fedora-7,suse-10.0,debian-4.0,rhel-4,debian-3.1,redhat-7.3 |
| 315 | No Build files found for gentoo-nover |
| 316 | Files configure.ac have been filtered |
| 317 | Creating netperf tar files compressed... OK |
| 318 | Under /users/bruno/netperf/delivery/netperf-2.4.4.tar.gz |
| 319 | }}} |
| 320 | |
| 321 | Much better. You have now your first useful result from pb :-) Congrats ! |
| 322 | |
| 323 | = Example of use on LinuxCOE (more complex example) = |
| 324 | |
| 325 | When the project was mature enough to package correctly mondorescue and itself, I then decided it was time to try it on another unrelated project to see how difficult it could be and document that experience so that others could also begin to use pb for their own project. |
| 326 | |
| 327 | You first have to edit your .pbrc configuration file in your home directory, which will setup things globally. |
| 328 | |
| 329 | Here are my .pbrc LinuxCOE relative entries: |
| 330 | {{{ |
| 331 | $ grep -E '^#|linuxcoe|default' ~/.pbrc |
| 332 | # |
| 333 | # Root of the temp file used to store info on the project |
| 334 | # Is also used to determine the root directory of the project |
| 335 | # No default option allowed here as they need to be all different |
| 336 | # |
| 337 | pbrc linuxcoe = /users/bruno/LinuxCOE/cvs/pbrc |
| 338 | }}} |