add script for managing 'build environments' (.config+files/), including documentation
[openwrt/staging/chunkeey.git] / docs / build.tex
index ef58b0ba7e911ab771bbe8b6e88aa5dc5376b145..cc7f5fd2c89b37110efa872816f515f8a5cb6551 100644 (file)
@@ -80,10 +80,10 @@ add a new version of one of the components above.
 \texttt{package} is for exactly that -- packages. In an OpenWrt firmware, almost everything
 is an \texttt{.ipk}, a software package which can be added to the firmware to provide new
 features or removed to save space. Note that packages are also maintained outside of the main
 \texttt{package} is for exactly that -- packages. In an OpenWrt firmware, almost everything
 is an \texttt{.ipk}, a software package which can be added to the firmware to provide new
 features or removed to save space. Note that packages are also maintained outside of the main
-trunk and can be obtained from subversion at the following location:
+trunk and can be obtained from subversion using the package feeds system:
 
 \begin{Verbatim}
 
 \begin{Verbatim}
-$ svn checkout https://svn.openwrt.org/openwrt/packages packages
+$ ./scripts/feeds update
 \end{Verbatim}
 
 Those packages can be used to extend the functionality of the build system and need to be
 \end{Verbatim}
 
 Those packages can be used to extend the functionality of the build system and need to be
@@ -91,15 +91,17 @@ symlinked into the main trunk. Once you do that, the packages will show up in th
 configuration. From kamikaze you would do something like this:
 
 \begin{Verbatim}
 configuration. From kamikaze you would do something like this:
 
 \begin{Verbatim}
-$ ls
-kamikaze  packages
-$ ln -s packages/net/nmap kamikaze/package/nmap
+$ ./scripts/feeds search nmap
+Search results in feed 'packages':
+nmap       Network exploration and/or security auditing utility
+
+$ ./scripts/feeds install nmap
 \end{Verbatim}
 
 To include all packages, issue the following command:
 
 \begin{Verbatim}
 \end{Verbatim}
 
 To include all packages, issue the following command:
 
 \begin{Verbatim}
-$ ln -s packages/*/* kamikaze/package/
+$ make package/symlinks
 \end{Verbatim}
 
 \texttt{target} refers to the embedded platform, this contains items which are specific to
 \end{Verbatim}
 
 \texttt{target} refers to the embedded platform, this contains items which are specific to
@@ -481,3 +483,60 @@ Other useful targets include:
     \item \texttt{make package/\textit{<name>}/configure V=99}
 \end{itemize}
 
     \item \texttt{make package/\textit{<name>}/configure V=99}
 \end{itemize}
 
+
+\subsection{Using build environments}
+OpenWrt provides a means of building images for multiple configurations
+which can use multiple targets in one single checkout. These \emph{environments}
+store a copy of the .config file generated by \texttt{make menuconfig} and the contents
+of the \texttt{./files} folder.
+The script \texttt{./scripts/env} is used to manage these environments, it uses
+\texttt{git} (which needs to be installed on your system) as backend for version control.
+
+The command 
+\begin{Verbatim}
+  \texttt{./scripts/env help}
+\end{Verbatim}
+produces a short help text with a list of commands.
+
+To create a new environment named \texttt{current}, run the following command
+\begin{Verbatim}
+  ./scripts/env new current
+\end{Verbatim}
+This will move your \texttt{.config} file and \texttt{./files} (if it exists) to
+the \texttt{env/} subdirectory and create symlinks in the base folder.
+
+After running make menuconfig or changing things in files/, your current state will
+differ from what has been saved before. To show these changes, use:
+\begin{Verbatim}
+  ./scripts/env diff
+\end{Verbatim}
+
+If you want to save these changes, run:
+\begin{Verbatim}
+  ./scripts/env save
+\end{Verbatim}
+If you want to revert your changes to the previously saved copy, run:
+\begin{Verbatim}
+  ./scripts/env revert
+\end{Verbatim}
+
+If you want, you can now create a second environment using the \texttt{new} command.
+It will ask you whether you want to make it a clone of the current environment (e.g.
+for minor changes) or if you want to start with a clean version (e.g. for selecting
+a new target).
+
+To switch to a different environment (e.g. \texttt{test1}), use:
+\begin{Verbatim}
+  ./scripts/env switch test1
+\end{Verbatim}
+
+To rename the current branch to a new name (e.g. \texttt{test2}), use:
+\begin{Verbatim}
+  ./scripts/env rename test2
+\end{Verbatim}
+
+If you want to get rid of environment switching and keep everything in the base directory
+again, use:
+\begin{Verbatim}
+  ./scripts/env clear
+\end{Verbatim}