Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:guide-developer:helloworld:chapter7 [2018/02/17 17:51] – ↷ Links adapted because of a move operation docs:guide-developer:helloworld:chapter7 [2024/03/29 14:42] (current) – [Including the first patch into the package] jiashuo_lin
Line 3: Line 3:
 ====== Patching your application: Adding new files ====== ====== Patching your application: Adding new files ======
  
-This is the seventh chapter in the “Hello, world!” for LEDE article series. At this point, you should've already accomplished the following tasks:+This is the seventh chapter in the “Hello, world!” for OpenWrt article series. At this point, you should've already accomplished the following tasks:
  
   * Commissioned your development environment   * Commissioned your development environment
Line 11: Line 11:
   * Created a local package feed for your application   * Created a local package feed for your application
   * Created a package manifest file for your application   * Created a package manifest file for your application
-  * Included your new package feed into the LEDE build system+  * Included your new package feed into the OpenWrt build system
   * Updated the package index, and installed your package from the feed   * Updated the package index, and installed your package from the feed
   * Built, deployed and tested the application on your target device   * Built, deployed and tested the application on your target device
Line 22: Line 22:
 ===== About patches ===== ===== About patches =====
  
-During the life cycle of an application, from the initial design until the application is decommissioned, it often requires changes or fixes to the original source code or associated files in order to operate correctly. Changing the application source code is especially common when using when porting software to run on a different computer architecture. In the LEDE build system, this change management is accomplished with a tool called Quilt.+During the life cycle of an application, from the initial design until the application is decommissioned, it often requires changes or fixes to the original source code or associated files in order to operate correctly. Changing the application source code is especially common when using when porting software to run on a different computer architecture. In the OpenWrt build system, this change management is accomplished with a tool called Quilt.
  
-There is an [[docs:guide-developer:build-system:use-patches-with-buildsystem|existing page]] in the LEDE wiki describing the tool in more detail. **Please review at least the first section in this page**, as there is crucial information on how the create a ''.quiltrc'' file, which ensures that the patches you create follow the established standards of the LEDE build system.+There is an [[docs:guide-developer:toolchain:use-patches-with-buildsystem|existing page]] in the OpenWrt wiki describing the tool in more detail. **Please review at least the first section in this page**, as there is crucial information on how the create a ''.quiltrc'' file, which ensures that the patches you create follow the established standards of the OpenWrt build system.
  
-At this point it is a good idea to ensure that Quilt can be found from the PATH environment variable. The LEDE build system installs the 'quilt' tool into the 'bin' directory under the target-independent tools' folder. We added this directory to our path in the [[docs:guide-developer:helloworld:chapter1#adjusting_the_path_variable|first chapter]]. To ensure that you can invoke the tool, you can simply issue:+At this point it is a good idea to ensure that Quilt can be found from the PATH environment variable. The OpenWrt build system installs the 'quilt' tool into the 'bin' directory under the target-independent tools' folder. We added this directory to our path in the [[docs:guide-developer:helloworld:chapter1#adjusting_the_path_variable|first chapter]]. To ensure that you can invoke the tool, you can simply issue:
 <code> <code>
 quilt --version quilt --version
Line 33: Line 33:
 ===== Preparing the source code ====== ===== Preparing the source code ======
  
-Creating a patch in the LEDE build system is very straightforward, but before we can start applying patches, we need to prepare our source code using a special option. We do so with the following commands:+Creating a patch in the OpenWrt build system is very straightforward, but before we can start applying patches, we need to prepare our source code using a special option. We do so with the following commands:
 <code> <code>
 cd /home/buildbot/source/ cd /home/buildbot/source/
Line 54: Line 54:
 quilt new 100-add_module_files.patch quilt new 100-add_module_files.patch
 </code> </code>
-The name of the patch comes from the conventions of the LEDE build system. The names usually begin with a free ordinal number, followed by a short description of what they do. The ordinal numbers have a specific meaning in some contexts, but oftentimes you can simply use a numbering starting from '000'.+The name of the patch comes from the conventions of the OpenWrt build system. The names usually begin with a free ordinal number, followed by a short description of what they do. The ordinal numbers have a specific meaning in some contexts, but oftentimes you can simply use a numbering starting from '000'.
  
 The author of this article chose the number '100' to signify that this patch adds new functionality to the existing source code base, and that this functionality has not yet been integrated into the original source code (upstream). The author of this article chose the number '100' to signify that this patch adds new functionality to the existing source code base, and that this functionality has not yet been integrated into the original source code (upstream).
Line 97: Line 97:
 ===== Including the first patch into the package ====== ===== Including the first patch into the package ======
  
-In the LEDE build system, patches are created and modified in the source code directory, and then migrated over to the package that they belong to. In order for us to migrate the patch data that we just created into the package proper, we issue the following commands:+In the OpenWrt build system, patches are created and modified in the source code directory, and then migrated over to the package that they belong to. In order for us to migrate the patch data that we just created into the package proper, we issue the following commands:
 <code> <code>
 cd /home/buildbot/source cd /home/buildbot/source
Line 109: Line 109:
 </code> </code>
  
-As we can see, the LEDE build system migrated our newly-created patch file into the folder where the package manifest is. The original source code folder remains completely unaware of our changes.+As we can see, the OpenWrt build system migrated our newly-created patch file into the folder where the package manifest is. The original source code folder remains completely unaware of our changes. 
 + 
 +Now, we need to modify ''mypackages/examples/helloworld/Makefile'' to copy the patch to the build directory. The earlier version used the ''cp'' command without the ''-r'' option. We need to add the ''-r'' option to copy directories. 
 +<code> 
 +define Build/Prepare 
 + mkdir -p $(PKG_BUILD_DIR) 
 + cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR) -r 
 + $(Build/Patch) 
 +endef 
 +</code>
  
 We can ensure that our new patch is applied correctly during the build process: We can ensure that our new patch is applied correctly during the build process:
Line 122: Line 131:
 ===== Conclusion ====== ===== Conclusion ======
  
-In this chapter, we scratched the surface of the LEDE build system's patching framework. We created a new patch, added two new files into the patch context, added content for the files and updated the patch context to reflect these changes. We then updated the package to migrate the newly-created patch over to the folder where the package manifest file resides.+In this chapter, we scratched the surface of the OpenWrt build system's patching framework. We created a new patch, added two new files into the patch context, added content for the files and updated the patch context to reflect these changes. We then updated the package to migrate the newly-created patch over to the folder where the package manifest file resides.
  • Last modified: 2018/02/17 17:51
  • by