This guide explains in several easy steps how to get started with [[Devshell | Devshell]]. It goes through the steps of getting the source, and building a sample Haskell package in not so many not so easy steps.

These directions are clearly not going to be the final workflow. If nothing else, i can't even get <code>brainfuck</code> to compile fully. But it demonstrates fundamentally how the workflow will follow. Most of the steps in this process are pretty generic to alot of kinds of packages. Implementing code to handle the bits for other packages is as simple as coding the steps into Python.

These directions are clearly not going to be the final workflow. If nothing else, i can't even get <code>brainfuck</code> to compile fully. But it demonstrates fundamentally how the workflow will follow. Most of the steps in this process are pretty generic to alot of kinds of packages. Implementing code to handle the bits for other packages is as simple as coding the steps into Python.

−

== Getting the Source ==

+

= Getting the Source =

−

In order to begin, you will need the latest source. Currently, this is only available through git. Open a handy terminal window and follow along.

+

In order to begin, you will need the latest source. Currently, this is only available through git.

−

<pre>

+

Follow the directions in the [[Devshell development | Development Guide]] in order to get the latest upstream.

Since this is the raw upstream, there's a chance the code may not work.

Since this is the raw upstream, there's a chance the code may not work.

−

== Launching Ports ==

+

= Launching Ports =

Since there are no built in tools yet for building a package, the only way to interact with the code is via the source directory itself. Therefore it's necessary to modify the command line path to make this work.

Since there are no built in tools yet for building a package, the only way to interact with the code is via the source directory itself. Therefore it's necessary to modify the command line path to make this work.

Line 19:

Line 19:

$ export PATH=/path/to/fedora-devshell/:$PATH

$ export PATH=/path/to/fedora-devshell/:$PATH

−

$ ports.py

+

$ ports

* PackageSource

* PackageSource

* SourceBall

* SourceBall

Line 61:

Line 61:

* Package

* Package

Traceback (most recent call last):

Traceback (most recent call last):

−

File "/path/to/fedora-devshell/ports.py", line 36, in <module>

+

File "/path/to/fedora-devshell/ports", line 36, in <module>

main()

main()

−

File "/path/to/fedora-devshell/ports.py", line 31, in main

+

File "/path/to/fedora-devshell/ports", line 31, in main

output, module, params = do_command(args)

output, module, params = do_command(args)

File "/path/to/fedora-devshell/base/base.py", line 176, in do_command

File "/path/to/fedora-devshell/base/base.py", line 176, in do_command

Line 73:

Line 73:

This confirms that the code is running at least partially. The list of names there is a list of the available modules, albeit repeated.

This confirms that the code is running at least partially. The list of names there is a list of the available modules, albeit repeated.

−

== Setting up a project ==

+

= Setting up a project =

Currently, Fedora Devshell can only work with Haskell programs, especially ones hosted on Hackage, the Haskell package repository. It also only works with packages managed by Darcs, the Haskell distributed version control system. Let's get a package and start playing with it.

Currently, Fedora Devshell can only work with Haskell programs, especially ones hosted on Hackage, the Haskell package repository. It also only works with packages managed by Darcs, the Haskell distributed version control system. Let's get a package and start playing with it.

<pre>

<pre>

−

$ ports.py package brainfuck

+

$ ports package brainfuck

$ cd brainfuck/

$ cd brainfuck/

Line 92:

Line 92:

We've started a new package called brainfuck.

We've started a new package called brainfuck.

<pre>

<pre>

−

brainfuck $ ports.py haskellport add_latest brainfuck

+

brainfuck $ ports haskellport add_latest brainfuck

brainfuck $ ls -Al

brainfuck $ ls -Al

Line 132:

Line 132:

</pre>

</pre>

−

== Editing the package ==

+

= Editing the package =

This gets the latest upstream tarball from hackage. Let's do a bit of hacking. Let's assume that brainfuck's not FHS compliant, and we need to put a quick patch in to get it into Fedora. Eventually we will send that patch upstream, but the tools for that are still in the works. For now, i'm going to assume that adding lines to the LICENSE file will make it FHS compliant. (In my imaginary world, we also have cookies.)

This gets the latest upstream tarball from hackage. Let's do a bit of hacking. Let's assume that brainfuck's not FHS compliant, and we need to put a quick patch in to get it into Fedora. Eventually we will send that patch upstream, but the tools for that are still in the works. For now, i'm going to assume that adding lines to the LICENSE file will make it FHS compliant. (In my imaginary world, we also have cookies.)

The 0 in the last command is what would ordinarily be passed to the argument <code>-p</code> to <code>patch</code>. We can also tell that the patches apply to the source code cleanly. Next we want to make a spec file.

The 0 in the last command is what would ordinarily be passed to the argument <code>-p</code> to <code>patch</code>. We can also tell that the patches apply to the source code cleanly. Next we want to make a spec file.

−

== Creating an RPM ==

+

= Creating an RPM =

<pre>

<pre>

−

brainfuck/brainfuck-0.1 $ ports.py cabal . gen_spec brainfuck

+

brainfuck/brainfuck-0.1 $ ports cabal . gen_spec brainfuck

brainfuck/brainfuck-0.1 $ ls -A

brainfuck/brainfuck-0.1 $ ls -A

Line 227:

Line 227:

brainfuck $ cd ..

brainfuck $ cd ..

−

$ ports.py profile profiles/devel configure_from_system devel

+

$ ports profile profiles/devel configure_from_system devel

$ cd brainfuck/

$ cd brainfuck/

−

brainfuck $ ports.py package fetch_sourceballs

+

brainfuck $ ports package fetch_sourceballs

brainfuck $ ls -Al

brainfuck $ ls -Al

Line 255:

Line 255:

~/rpmbuild/SRPMS:

~/rpmbuild/SRPMS:

−

$ ports.py build ~/rpmbuild setup_source brainfuck

+

$ ports build ~/rpmbuild setup_source brainfuck

$ ls -l ~/rpmbuild/*

$ ls -l ~/rpmbuild/*

Line 285:

Line 285:

<code>mock</code> will actually run setup_sources for us later on. This just demonstrates what it does. The code is also a bit half-baked.

<code>mock</code> will actually run setup_sources for us later on. This just demonstrates what it does. The code is also a bit half-baked.

−

== Building the RPM in Mock ==

+

= Building the RPM in Mock =

<pre>

<pre>

−

$ ports.py mock profiles/devel ~/rpmbuild build_rpm brainfuck

+

$ ports mock profiles/devel ~/rpmbuild build_rpm brainfuck

[INFO] mock compiling brainfuck-0.1-1.fc10.src.rpm... please wait

[INFO] mock compiling brainfuck-0.1-1.fc10.src.rpm... please wait

Line 343:

Line 343:

In reality, setting up the source is not necessary. In the latest upstream, mock.build_rpm can actually set up the source for you.

In reality, setting up the source is not necessary. In the latest upstream, mock.build_rpm can actually set up the source for you.

−

== Conclusion ==

+

= Conclusion =

Clearly <code>mock</code> failed. I guess that spec file wasn't perfect. Because of the use of symlinks, however, i can simply edit the spec file, make the necessary changes, and rerun the command to initialize <code>mock</code>. Fedora Devshell will automatically build the source RPM, and send the appropriate command to <code>mock</code> to use a premade profile. There will be more you can do with this here.

Clearly <code>mock</code> failed. I guess that spec file wasn't perfect. Because of the use of symlinks, however, i can simply edit the spec file, make the necessary changes, and rerun the command to initialize <code>mock</code>. Fedora Devshell will automatically build the source RPM, and send the appropriate command to <code>mock</code> to use a premade profile. There will be more you can do with this here.

Line 349:

Line 349:

This concludes the tutorial section. For more information about what you can do with Fedora Devshell, have a look at the Developers Guide.

This concludes the tutorial section. For more information about what you can do with Fedora Devshell, have a look at the Developers Guide.

−

[[Category:FedoraDevshell]]

+

[[Category:Devshell]]

Latest revision as of 06:10, 30 April 2009

This guide explains in several easy steps how to get started with Devshell. It goes through the steps of getting the source, and building a sample Haskell package in not so many not so easy steps.

These directions are clearly not going to be the final workflow. If nothing else, i can't even get brainfuck to compile fully. But it demonstrates fundamentally how the workflow will follow. Most of the steps in this process are pretty generic to alot of kinds of packages. Implementing code to handle the bits for other packages is as simple as coding the steps into Python.

Since this is the raw upstream, there's a chance the code may not work.

Launching Ports

Since there are no built in tools yet for building a package, the only way to interact with the code is via the source directory itself. Therefore it's necessary to modify the command line path to make this work.

This confirms that the code is running at least partially. The list of names there is a list of the available modules, albeit repeated.

Setting up a project

Currently, Fedora Devshell can only work with Haskell programs, especially ones hosted on Hackage, the Haskell package repository. It also only works with packages managed by Darcs, the Haskell distributed version control system. Let's get a package and start playing with it.

Editing the package

This gets the latest upstream tarball from hackage. Let's do a bit of hacking. Let's assume that brainfuck's not FHS compliant, and we need to put a quick patch in to get it into Fedora. Eventually we will send that patch upstream, but the tools for that are still in the works. For now, i'm going to assume that adding lines to the LICENSE file will make it FHS compliant. (In my imaginary world, we also have cookies.)

brainfuck/brainfuck-0.1 $ vi LICENSE
brainfuck/brainfuck-0.1 $ diff -ru -X /path/to/fedora-devshell/diff.excludes .pkg_src/branches/brainfuck-0.1_orig/ .
diff -ru -X /path/to/fedora-devshell/diff.excludes .pkg_src/branches/brainfuck-0.1_orig/LICENSE ./LICENSE
--- .pkg_src/branches/brainfuck-0.1_orig/LICENSE 2008-06-08 18:37:11.000000000 -0400
+++ ./LICENSE 2009-01-20 22:29:40.911210433 -0500
@@ -26,6 +26,8 @@
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
+
+
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
@@ -33,6 +35,8 @@
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
+
+
source code. And you must show them these terms so they know their
rights.
@@ -43,6 +47,7 @@
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
+RMS has a big beard.
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

As you can see, keeping the original code tree around is convenient, because we can run diff's easily.

This creates our first patch. It's ordered for reasons that will be obvious shortly. Later in the workflow, someone hands you a second patch, which you want to import into the package. Apparently you couldn't make the package FHS compliant enough.

I've skipped the steps about integrating patches into the spec file, and updating it with all the vital bits. haskellports uses cabal2spec which means you have to fill in all the little bits later. Rather, we're going to jump right away to compiling RPMs. Currently, Haskell packages can only be built for rawhide, so we're going to use the 'devel' branch. profile will copy over mock configuration files, so we can tinker with them later. This segment is only half baked, so theres's not much you can do with profile except copy bits and use it with mock

In reality, setting up the source is not necessary. In the latest upstream, mock.build_rpm can actually set up the source for you.

Conclusion

Clearly mock failed. I guess that spec file wasn't perfect. Because of the use of symlinks, however, i can simply edit the spec file, make the necessary changes, and rerun the command to initialize mock. Fedora Devshell will automatically build the source RPM, and send the appropriate command to mock to use a premade profile. There will be more you can do with this here.

This concludes the tutorial section. For more information about what you can do with Fedora Devshell, have a look at the Developers Guide.