summaryrefslogtreecommitdiffstats
path: root/documentation/plain_sources/handling_ptxdist_revisions.tex
blob: e9cf135bd2ef604636451be60f00050dc5acb723 (plain)
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
%
% Charset: utf8
% Content type: Plain LATEX
% Content: This chapter give some PTXdist specific hints how to use handle all
%          the different BSP releases with different PTXdist releases.
%
% Copyright Dave Festing <dave_festing@hotmail.com>, 2012 and
%           Jürgen Beisert <jbe@pengutronix.de>, 2012
%           Jürgen Borleis <jbe@pengutronix.de>, 2014
%
% This work is licensed under the Creative Commons Attribution 3.0 Unported License.
% To view a copy of this license, visit:
%           http://creativecommons.org/licenses/by/3.0/
% or send a letter to:
% Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
%
% Refer the file CREDITS for all people working on this document.
%
% This file content will be part of the "OSELAS.BSP-Pengutronix-Mini2440-Quickstart.pdf"
%
% Note: This document uses some externaly defined LATEX commands. If you try to
% run LATEX only on this file it will fail due to the absense of these commands.
% All these commands are starting with 'ptxdist'.
%

\section{Using automagically the correct PTXdist Revision}	\label{sec:ptxdistreleases}

After following the releases of this Mini2440 BSP our harddisk may contain
various Mini2440 BSP releases, various corresonding OSELAS.Toolchains revisions
and PTXdist revisions. How to avoid to get confused in this situation?

One solution can be to do it in the same way as \ptxdist{} itself remembers the
platform, the current configuration and the toolchain to be used to build the
project: by symbolic filesystem links.

Lets take a look into the project, after it is set up:

\begin{ptxshell}[escapechar=|]{^}
|\$| ls -lF
total 44
-rw-r--r-- 1 jb user   408 Oct  4 18:11 CONTRIBUTORS
-rw-r--r-- 1 jb user 18002 Oct  4 18:11 COPYING
-rw-r--r-- 1 jb user  6688 Oct  4 18:11 Changelog
-rw-r--r-- 1 jb user  4350 Oct  4 18:11 FAQ
-rw-r--r-- 1 jb user   177 Oct  4 18:11 README
drwxr-xr-x 3 jb user   160 Oct  4 18:11 configs/
drwxr-xr-x 3 jb user    80 Jun 12 11:34 documentation/
drwxr-xr-x 4 jb user   128 Oct  4 18:11 local_src/
drwxr-xr-x 2 jb user    72 Oct  4 18:12 platform-mini2440/
drwxr-xr-x 3 jb user    72 Oct  4 18:11 projectroot/
drwxr-xr-x 2 jb user   120 Oct  4 18:11 protocol/
drwxr-xr-x 2 jb user   144 Oct  4 18:11 rules/
lrwxrwxrwx 1 jb user    62 Oct  4 18:12 selected_platformconfig -> configs/platform-friendlyarm-mini2440/platformconfig-NAND-128M
lrwxrwxrwx 1 jb user    17 Oct  4 18:12 selected_ptxconfig -> configs/ptxconfig
lrwxrwxrwx 1 jb user   115 Oct  4 18:12 selected_toolchain -> /opt/OSELAS.Toolchain-2012.12.0/arm-v4t-linux-gnueabi/gcc-4.7.2-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/
\end{ptxshell}

Note the three symbolic links \texttt{selected\_platformconfig},
\texttt{selected\_ptxconfig} and \texttt{selected\_toolchain}. They point to the
correct files and locations to build this project.

Why not do the same with the \ptxdist{} tool itself?

\begin{ptxshell}[escapechar=|]{^}
|\$| ln -s /usr/local/lib/ptxdist-|\releasenumber |/bin/ptxdist .
\end{ptxshell}

This command will add a new link with the name \texttt{ptxdist}, pointing to the
\ptxdist{} revision to be used in this project. All we now need to do is to call
the local link instead of the global \ptxdist{}. This can be achived by using
the trailing \texttt{./}

\begin{ptxshell}[escapechar=|]{^}
|\$| ./ptxdist do
|\$| ./ptxdist menuconfig
|\$| ./ptxdist images
\end{ptxshell}

You can imagine this will free us from thinking about the correct \ptxdist{}
revision on each build or configure step in each \ptxdist{} project. Now, all
projects and \ptxdist{} revisions can co-exist and we can use them all at the
same time.

And as we do not want to type longer commands than absolute required, we should
shorten the symbolic link to \texttt{p}

\begin{ptxshell}[escapechar=|]{^}
|\$| ln -s /usr/local/lib/ptxdist-|\releasenumber |/bin/ptxdist p
\end{ptxshell}

Now, typing is less time-consuming:

\begin{ptxshell}[escapechar=|]{^}
|\$| ./p do
|\$| ./p menuconfig
|\$| ./p images
\end{ptxshell}

And if we also do not want to enter the trailing \texttt{./} again and again (we
are so lazy, aren't we?) we could add the following function to our own
environment in \texttt{\~/.bashrc}:

\begin{ptxshell}[escapechar=|]{^}
function p ()
{
    if [ -h ./p ]; then
        ./p |\$|{@};
    else
        echo "No local PTXdist symlink found. Create the correct one first"
    fi
}
\end{ptxshell}

Now it looks like a regular command again:

\begin{ptxshell}[escapechar=|]{^}
|\$| p do
|\$| p menuconfig
|\$| p images
\end{ptxshell}

\begin{important}
To avoid the trailing \texttt{./} we could also add the current directory to
the search PATH. But to do so is a really bad idea. At least compiling the
OSELAS.Toolchain fails with the current directory in the PATH. Use the function
shown above. It also gives us a helpful error message instead silently
searching for 'p' in our filesystem with different funny and confusing error
messages at the end.
\end{important}