Chapter 28. Applying a patch

28.1. Pre-process patchfile

Patches can be specific to a single version of eCosPro or can be applicable to a number of versions. If a patch is specific to a single version, the patchfile provided should already be directed at that specific version and will not require pre-processing.

If a patchfile is intended to be applied against a number of different versions of eCosPro you will need to pre-process the patchfile to create a new patchfile that is specific to your version. This is because the naming convention of directories used by CDL (see Chapter 22, CDL Concepts) includes the version number of individual packages, and patchfiles include the path to the files which are to be changed. As the naming convention for versions used is simple and the path names of files can be simply changed within the patchfile, a generic patchfile directed at the version "patchfile" is usually provided rather than providing a patchfile for each version of eCosPro affected.

To pre-process the patchfile, open a command prompt with the "Shell Environment" shortcut in the eCosPro group and change to the directory that contains the downloaded patchfile. Then run the command below replacing X, Y and Z below with the major, minor and sub-minor version numbers of your release respectively. For example, for eCosPro version 3.1.15 the major version number is 3, the minor version is 1, and the sub-minor version number is 15.

Figure 28.1. Pre-process patch on Linux

test@ubuntu:~$ cd /tmp/download
test@ubuntu:/tmp/download$ sed 's@/current/@/vX_Y_Z/@' < issue-1001234.pat > issue-1001234-new.pat
test@ubuntu:/tmp/download$

Figure 28.2. Pre-process patch on Windows

C:\> cd C:\TEMP
C:\TEMP> sed 's@/current/@/vX_Y_Z/@' < issue-1001234.pat > issue-1001234-new.pat
C:\TEMP>

For example, use v3_1_15 for version 3.1.15, v3_1_3 for version 3.1.3 and so on.

Figure 28.3. Example of the pre-process of a patch on Linux for version 3.1.15

test@ubuntu:~$ cd /tmp/download
test@ubuntu:/tmp/download$ sed 's@/current/@/v3_1_15/@' < issue-1001234.pat > issue-1001234-new.pat
test@ubuntu:/tmp/download$

28.2. Applying a patch

28.2.1. Applying a patch on Linux

To apply a patchfile or a pre-processed patchfile from within the command prompt (opened with the "Shell Environment" shortcut in the eCosPro group) on Linux using the patch application follow these commands:

Figure 28.4. Application of a patch on Linux

test@ubuntu:~$ cd $ECOS_REPOSITORY
test@ubuntu:/opt/ecospro/ecos-3.1.19/packages$ patch -p0 < /tmp/download/issue-1001234-new.pat
patching file net/common/current/include/bootp.h
patching file net/common/current/src/bootp_support.c
test@ubuntu:/opt/ecospro/ecos-3.1.19/packages$

Replace /tmp/download/issue-1001234-new.pat with the path and filename to the downloaded or pre-processed patchfile.

28.2.2. Applying a patch on Windows

To apply a patchfile or a pre-processed patchfile from within the command prompt (opened with the "Shell Environment" shortcut in the eCosPro group) on Windows using the patch application follow these commands:

Figure 28.5. Application of a patch on Windows

C:\> cd %ECOS_REPOSITORY%
C:\eCosPro\ecos-3.1.19\packages> patch -p0 < C:\TEMP\issue-1001234-new.pat
patching file net/common/current/include/bootp.h
patching file net/common/current/src/bootp_support.c
C:\eCosPro\ecos-3.1.19\packages>

Replace C:\TEMP\issue-1001234-new.pat with the path and filename to the downloaded or pre-processed patchfile.

[Note]Note

On Windows XP in earlier releases of the eCosPro 3.1 host tools the environment variable %ECOS_REPOSITORY% will not be recognised as it used forward instead of backward slashes as directory name seperators. To work around this issue, alter the %ECOS_REPOSITORY% variable by changing forward to backward slashes.

Figure 28.6. Application of a patch on Windows XP

C:\> echo %ECOS_REPOSITORY%
C:/eCosPro/ecos-3.1.19/packages
C:\> set ECOS_REPOSITORY=C:\eCosPro\ecos-3.1.19\packages
C:\> cd %ECOS_REPOSITORY%
C:\eCosPro\ecos-3.1.19\packages> patch -p0 < C:\TEMP\issue-1001234-new.pat
patching file net/common/current/include/bootp.h
patching file net/common/current/src/bootp_support.c
C:\eCosPro\ecos-3.1.19\packages>