File: tutor-distribute.sgml

package info (click to toggle)
aap 1.072-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 4,976 kB
  • ctags: 2,160
  • sloc: python: 15,113; makefile: 62; sh: 13
file content (141 lines) | stat: -rw-r--r-- 4,455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!--  vim: set sw=2 sts=2 et ft=docbk:

  Part of the A-A-P recipe executive: Tutorial - distributing a program

  Copyright (C) 2002-2003 Stichting NLnet Labs
  Permission to copy and use this file is specified in the file COPYING.
  If this file is missing you can find it here: http://www.a-a-p.org/COPYING

-->

<para>
Open source software needs to be distributed.  This chapter gives a simple
example of how you can upload your files and make it easy for others to
download and install your program.
</para>



<bridgehead>Downloading</bridgehead>

<para>
To make it easy for others to obtain the latest version of your program, you
give them a recipe.  That is all they need.  In the recipe you describe how to
download the files and compile the program.  Here is an example:
</para>

<programlisting>
1     Origin = ftp://ftp.mysite.org/pub/theprog
2
3     :recipe {fetch = $Origin/main.aap}
4
5     Source = main.c
6              version.c
7     Header = common.h
8
9     :attr {fetch = $Origin/%file%} $Source $Header
10
11    :program theprog : $Source
</programlisting>

<para>
The first line specifies the location where all the files can be found.  It
is good idea to specify this only once.  If you would use the text all over
the recipe it is more difficult to read and it would be more work when the URL
changes.
</para>

<para>
Line 3 specifies where this recipe can be obtained.  After obtaining this
recipe once, it can be updated with a simple command:
</para>

<literallayout>    % <userinput>aap refresh</userinput>
    Aap: Updating recipe "main.aap"
    Aap: Attempting download of "ftp://ftp.mysite.org/pub/theprog/main.aap"
    Aap: Downloaded "ftp://ftp.mysite.org/pub/theprog/main.aap" to "/home/mool/.aap/cache/98092140.aap"
    Aap: Copied file from cache: "main.aap"
    %
</literallayout>

<para>
The messages from &Aap; are a bit verbose.  This is just in case the
downloading is very slow, you will have some idea of what is going on.
</para>

<para>
Lines 5 to 7 define the source files.  This is not different from the examples
that were used to compile a program, except that we explicitly mention the
header file used.
</para>

<para>
Line 9 specifies where the files can be fetched from.  This is done by
giving the source and header files the <literal>fetch</literal> attribute.
The <computeroutput>:attr</computeroutput> command does not cause the files to be fetched
yet.  When a file is used somewhere and it has a <literal>fetch</literal>
attribute, then it is fetched.  Thus files that are not used will not be
fetched.
</para>

<para>
A user of your program stores this recipe as <filename>main.aap</filename> and runs
<userinput>aap</userinput> without arguments.  What will happen is:
<orderedlist>
  <listitem>
    <para>
    Dependencies will be created by the <literal>:program</literal> command
    to build "theprog" from
    <filename>main.c</filename> and <filename>version.c</filename>.
    </para>
  </listitem>
  <listitem>
    <para>
    The target "theprog" depends on
    <filename>main.c</filename> and <filename>version.c</filename>.
    Since these
    files do not exist and they do have a <literal>fetch</literal> attribute, they
    are fetched.
    </para>
  </listitem>
  <listitem>
    <para>
    The <filename>main.c</filename> file is inspected for dependencies.  It includes the
    <filename>common.h</filename> file, which is automatically
    added to the list of dependencies.
    Since <filename>common.h</filename> does not exist and has a <literal>fetch</literal> attribute, it
    is fetched as well.
    </para>
  </listitem>
  <listitem>
    <para>
    Now that all the files are present they are compiled and linked into
    "theprog".
    </para>
  </listitem>
</orderedlist>
</para>


<bridgehead>Uploading</bridgehead>

<para>
You need to upload the files mentioned in the recipe above.  This needs to be
repeated each time one of the files changes.  This is essentially the same as
publishing a web site.
You will need to upload both the source files and the recipe itself.
The {publish} attribute can be used for this.
You can add the following
two lines to the recipe above in order to upload all the files:
</para>

<programlisting>
    URL = scp://user@ftp.mysite.org//pub/theprog/%file%
    :attr {publish = $URL} $Source $Header main.aap
</programlisting>

<para>
Now you can use <userinput>aap publish</userinput>
to upload your source files as well.
</para>