bash_script.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>Bash Script gen_pack.sh</title>
  7. <title>CMSIS-Pack: Bash Script gen_pack.sh</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <link href="cmsis.css" rel="stylesheet" type="text/css" />
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <script type="text/javascript" src="printComponentTabs.js"></script>
  13. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  14. <script type="text/javascript" src="resize.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <script type="text/javascript">
  17. $(document).ready(initResizable);
  18. $(window).load(resizeHeight);
  19. </script>
  20. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  21. <script type="text/javascript" src="search/search.js"></script>
  22. <script type="text/javascript">
  23. $(document).ready(function() { searchBox.OnSelectItem(0); });
  24. </script>
  25. </head>
  26. <body>
  27. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  28. <div id="titlearea">
  29. <table cellspacing="0" cellpadding="0">
  30. <tbody>
  31. <tr style="height: 46px;">
  32. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  33. <td style="padding-left: 0.5em;">
  34. <div id="projectname">CMSIS-Pack
  35. &#160;<span id="projectnumber">Version 1.6.3</span>
  36. </div>
  37. <div id="projectbrief">Delivery Mechanism for Software Packs</div>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. <!-- end header part -->
  44. <div id="CMSISnav" class="tabs1">
  45. <ul class="tablist">
  46. <script type="text/javascript">
  47. <!--
  48. writeComponentTabs.call(this);
  49. //-->
  50. </script>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.6 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li class="current"><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li>
  62. <div id="MSearchBox" class="MSearchBoxInactive">
  63. <span class="left">
  64. <img id="MSearchSelect" src="search/mag_sel.png"
  65. onmouseover="return searchBox.OnSearchSelectShow()"
  66. onmouseout="return searchBox.OnSearchSelectHide()"
  67. alt=""/>
  68. <input type="text" id="MSearchField" value="Search" accesskey="S"
  69. onfocus="searchBox.OnSearchFieldFocus(true)"
  70. onblur="searchBox.OnSearchFieldFocus(false)"
  71. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  72. </span><span class="right">
  73. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  74. </span>
  75. </div>
  76. </li>
  77. </ul>
  78. </div>
  79. </div><!-- top -->
  80. <div id="side-nav" class="ui-resizable side-nav-resizable">
  81. <div id="nav-tree">
  82. <div id="nav-tree-contents">
  83. <div id="nav-sync" class="sync"></div>
  84. </div>
  85. </div>
  86. <div id="splitbar" style="-moz-user-select:none;"
  87. class="ui-resizable-handle">
  88. </div>
  89. </div>
  90. <script type="text/javascript">
  91. $(document).ready(function(){initNavTree('bash_script.html','');});
  92. </script>
  93. <div id="doc-content">
  94. <!-- window showing the filter options -->
  95. <div id="MSearchSelectWindow"
  96. onmouseover="return searchBox.OnSearchSelectShow()"
  97. onmouseout="return searchBox.OnSearchSelectHide()"
  98. onkeydown="return searchBox.OnSearchSelectKey(event)">
  99. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  100. <!-- iframe showing the search results (closed by default) -->
  101. <div id="MSearchResultsWindow">
  102. <iframe src="javascript:void(0)" frameborder="0"
  103. name="MSearchResults" id="MSearchResults">
  104. </iframe>
  105. </div>
  106. <div class="header">
  107. <div class="headertitle">
  108. <div class="title">Bash Script gen_pack.sh </div> </div>
  109. </div><!--header-->
  110. <div class="contents">
  111. <div class="textblock"><p>The following <a href="https://en.wikipedia.org/wiki/Bash_(Unix_shell)" target="_blank">Bash</a> shell script template <a class="el" href="bash_script.html#gen_pack_sh">gen_pack.sh</a> allows you to generate a Pack file on the Linux or the Windows operating system. Bash is available for Windows, for example, via <a href="https://gitforwindows.org/" target="_blank">git for Windows</a>.</p>
  112. <p>For using <a class="el" href="bash_script.html#gen_pack_sh">gen_pack.sh</a></p>
  113. <ul>
  114. <li>Install <a class="el" href="cp_ZIPTool.html">7-Zip</a> (and for Linux <a class="el" href="cp_Editors.html#xmllint">xmllint</a> for schema validation).</li>
  115. <li>Adapt the file <a class="el" href="bash_script.html#gen_pack_sh">gen_pack.sh</a> that is available in the directory <b>/CMSIS/Pack/Bash</b> to the requirements of your software pack.</li>
  116. </ul>
  117. <p>The script is generic enough to cope with a wide range of requirements. It uses the information from the <a class="el" href="packFormat.html">*.PDSC file</a> to generate the output filename according the CMSIS-Pack conventions and validates the pack consistency with <a class="el" href="packChk.html">packChk</a>.</p>
  118. <p>Below is a sample output (reduced). </p>
  119. <div class="fragment"><div class="line">$ ./gen_pack.sh</div>
  120. <div class="line"> </div>
  121. <div class="line">Starting CMSIS-Pack Generation: 19 Aug 2019 15:34:02</div>
  122. <div class="line">7z is /C/Program Files/7-Zip/7z</div>
  123. <div class="line">PackChk is /C/Keil_v5/ARM/PACK/ARM/CMSIS/5.6.0/CMSIS/Utilities/Win32/PackChk</div>
  124. <div class="line"> </div>
  125. <div class="line">Generating Pack Version: <span class="keywordflow">for</span> MyVendor.MyPack</div>
  126. <div class="line"> </div>
  127. <div class="line">Adding directories to pack:</div>
  128. <div class="line">Include/ Source/</div>
  129. <div class="line"> </div>
  130. <div class="line">Adding files to pack:</div>
  131. <div class="line">License.txt ReadMe.txt</div>
  132. <div class="line"> </div>
  133. <div class="line">PackChk.exe 1.3.87</div>
  134. <div class="line">Copyright (C) 2012-2019 ARM Ltd and ARM Germany GmbH. All rights reserved.</div>
  135. <div class="line"> </div>
  136. <div class="line">M362: Also suppressing Messages M502 and M504</div>
  137. <div class="line"> </div>
  138. <div class="line">Phase1: Read PDSC files</div>
  139. <div class="line">Phase2: Static Data &amp; Dependencies check</div>
  140. <div class="line"> WARNING M304: C:\W\CMSIS_5\CMSIS\Pack\Bash\build\MyVendor.MyPack.pdsc</div>
  141. <div class="line"> No <span class="keyword">package </span>URL (&lt;url&gt;-tag and/or value) found in PDSC file!</div>
  142. <div class="line"> </div>
  143. <div class="line">Phase3: RTE Model based Data &amp; Dependencies check</div>
  144. <div class="line">Found 0 Error(s) and 1 Warning(s).</div>
  145. <div class="line"> </div>
  146. <div class="line">creating pack file MyVendor.MyPack.1.0.0.pack</div>
  147. <div class="line"> </div>
  148. <div class="line">Creating archive: C:/W/CMSIS_5/CMSIS/Pack/Bash/output/MyVendor.MyPack.1.0.0.pack</div>
  149. <div class="line">Add new data to archive: 2 folders, 5 files, 1165 bytes (2 KiB)</div>
  150. <div class="line"> </div>
  151. <div class="line">Everything is Ok</div>
  152. <div class="line">Completed CMSIS-Pack Generation ...</div>
  153. </div><!-- fragment --><p><a class="anchor" id="gen_pack_sh"></a><b>gen_pack.sh Bash script template file</b></p>
  154. <p>The <b>gen_pack.sh</b> script template allows to configure:</p>
  155. <ul>
  156. <li>Path environment variables for related utilities</li>
  157. <li>Directory names for temporary build and output files</li>
  158. <li>Directory names and files in the root directory that should be included in the pack</li>
  159. </ul>
  160. <pre class="fragment">#!/bin/bash
  161. # Version: 1.0
  162. # Date: 2019-08-16
  163. # This bash script generates a CMSIS Software Pack:
  164. #
  165. # Pre-requisites:
  166. # - bash shell (for Windows: install git for Windows)
  167. # - 7z in path (zip archiving utility)
  168. # e.g. Ubuntu: sudo apt-get install p7zip-full p7zip-rar)
  169. # - PackChk in path with execute permission
  170. # (see CMSIS-Pack: CMSIS/Utilities/&lt;os&gt;/PackChk)
  171. # - xmllint in path (XML schema validation; available only for Linux)
  172. ############### EDIT BELOW ###############
  173. # Extend Path environment variable locally
  174. #
  175. if [ `uname -s` = "Linux" ]
  176. then
  177. CMSIS_PACK_PATH="/home/$USER/.arm/Packs/ARM/CMSIS/5.6.0/"
  178. PATH_TO_ADD="$CMSIS_PACK_PATH/CMSIS/Utilities/Linux-gcc-4.8.3/"
  179. else
  180. CMSIS_PACK_PATH="/C/Keil_v5/ARM/PACK/ARM/CMSIS/5.6.0"
  181. PATH_TO_ADD="/C/Program Files/7-Zip/:$CMSIS_PACK_PATH/CMSIS/Utilities/Win32/"
  182. fi
  183. [[ ":$PATH:" != *":$PATH_TO_ADD}:"* ]] &amp;&amp; PATH="${PATH}:${PATH_TO_ADD}"
  184. echo $PATH_TO_ADD appended to PATH
  185. echo " "
  186. # Pack warehouse directory - destination
  187. PACK_WAREHOUSE=output/
  188. # Temporary pack build directory
  189. PACK_BUILD=build/
  190. # Specify directories included in pack relative to base directory
  191. # All directories:
  192. PACK_DIRS=`ls -d */`
  193. # Do not include the build directory if it is local
  194. PACK_DIRS=${PACK_DIRS//$PACK_BUILD/}
  195. PACK_DIRS=${PACK_DIRS//$PACK_WAREHOUSE/}
  196. # alternative: specify directory names to be added to pack base directory
  197. # PACK_DIRS="
  198. # Source
  199. # Include
  200. #"
  201. # Specify file names to be added to pack base directory
  202. PACK_BASE_FILES="
  203. License.txt
  204. ReadMe.txt
  205. "
  206. ############ DO NOT EDIT BELOW ###########
  207. echo Starting CMSIS-Pack Generation: `date`
  208. # Zip utility check
  209. ZIP=7z
  210. type -a $ZIP
  211. errorlevel=$?
  212. if [ $errorlevel -gt 0 ]
  213. then
  214. echo "Error: No 7zip Utility found"
  215. echo "Action: Add 7zip to your path"
  216. echo " "
  217. exit
  218. fi
  219. # Pack checking utility check
  220. PACKCHK=PackChk
  221. type -a $PACKCHK
  222. errorlevel=$?
  223. if [ $errorlevel != 0 ]
  224. then
  225. echo "Error: No PackChk Utility found"
  226. echo "Action: Add PackChk to your path"
  227. echo "Hint: Included in CMSIS Pack:"
  228. echo "&lt;pack_root_dir&gt;/ARM/CMSIS/&lt;version&gt;/CMSIS/Utilities/&lt;os&gt;/"
  229. echo " "
  230. exit
  231. fi
  232. echo " "
  233. # Locate Package Description file
  234. # check whether there is more than one pdsc file
  235. NUM_PDSCS=`ls -1 *.pdsc | wc -l`
  236. PACK_DESCRIPTION_FILE=`ls *.pdsc`
  237. if [ $NUM_PDSCS -lt 1 ]
  238. then
  239. echo "Error: No *.pdsc file found in current directory"
  240. echo " "
  241. elif [ $NUM_PDSCS -gt 1 ]
  242. then
  243. echo "Error: Only one PDSC file allowed in directory structure:"
  244. echo "Found:"
  245. echo "$PACK_DESCRIPTION_FILE"
  246. echo "Action: Delete unused pdsc files"
  247. echo " "
  248. exit
  249. fi
  250. SAVEIFS=$IFS
  251. IFS=.
  252. set $PACK_DESCRIPTION_FILE
  253. # Pack Vendor
  254. PACK_VENDOR=$1
  255. # Pack Name
  256. PACK_NAME=$2
  257. echo Generating Pack Version: for $PACK_VENDOR.$PACK_NAME
  258. echo " "
  259. IFS=$SAVEIFS
  260. #if $PACK_BUILD directory does not exist, create it.
  261. if [ ! -d $PACK_BUILD ]; then
  262. mkdir -p $PACK_BUILD
  263. fi
  264. # Copy files into build base directory: $PACK_BUILD
  265. # pdsc file is mandatory in base directory:
  266. cp -f ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_BUILD}
  267. # directories
  268. echo Adding directories to pack:
  269. echo $PACK_DIRS
  270. echo " "
  271. for d in ${PACK_DIRS}
  272. do
  273. cp -r "$d" ${PACK_BUILD}
  274. done
  275. # files for base directory
  276. echo Adding files to pack:
  277. echo $PACK_BASE_FILES
  278. echo " "
  279. for f in $PACK_BASE_FILES
  280. do
  281. cp -f "$f" $PACK_BUILD/
  282. done
  283. # Run Schema Check (for Linux only):
  284. # sudo apt-get install libxml2-utils
  285. if [ `uname -s` = "Linux" ]
  286. then
  287. echo Running schema check for $PACK_VENDOR.$PACK_NAME.pdsc
  288. xmllint --noout --schema ${CMSIS_PACK_PATH}/CMSIS/Utilities/PACK.xsd $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc
  289. errorlevel=$?
  290. if [ $errorlevel -ne 0 ]; then
  291. echo "build aborted: Schema check of $PACK_VENDOR.$PACK_NAME.pdsc against PACK.xsd failed"
  292. echo " "
  293. exit
  294. fi
  295. else
  296. echo "Use MDK PackInstaller to run schema validation for $PACK_VENDOR.$PACK_NAME.pdsc"
  297. fi
  298. # Run Pack Check and generate PackName file with version
  299. $PACKCHK $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc -n PackName.txt -x M362
  300. errorlevel=$?
  301. if [ $errorlevel -ne 0 ]; then
  302. echo "build aborted: pack check failed"
  303. echo " "
  304. exit
  305. fi
  306. PACKNAME=`cat PackName.txt`
  307. rm -rf PackName.txt
  308. # Archiving
  309. # $ZIP a $PACKNAME
  310. echo creating pack file $PACKNAME
  311. #if $PACK_WAREHOUSE directory does not exist create it
  312. if [ ! -d $PACK_WAREHOUSE ]; then
  313. mkdir -p $PACK_WAREHOUSE
  314. fi
  315. pushd $PACK_WAREHOUSE
  316. PACK_WAREHOUSE=`pwd`
  317. popd
  318. pushd $PACK_BUILD
  319. "$ZIP" a $PACK_WAREHOUSE/$PACKNAME -tzip
  320. popd
  321. errorlevel=$?
  322. if [ $errorlevel -ne 0 ]; then
  323. echo "build aborted: archiving failed"
  324. exit
  325. fi
  326. echo "build of pack succeeded"
  327. # Clean up
  328. echo "cleaning up ..."
  329. rm -rf $PACK_BUILD
  330. echo " "
  331. echo Completed CMSIS-Pack Generation: `date`
  332. </pre> </div></div><!-- contents -->
  333. </div><!-- doc-content -->
  334. <!-- start footer part -->
  335. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  336. <ul>
  337. <li class="navelem"><a class="el" href="createPackUtil.html">Utilities for Creating Packs</a></li>
  338. <li class="footer">Generated on Thu Apr 9 2020 15:49:54 for CMSIS-Pack Version 1.6.3 by Arm Ltd. All rights reserved.
  339. <!--
  340. <a href="http://www.doxygen.org/index.html">
  341. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
  342. -->
  343. </li>
  344. </ul>
  345. </div>
  346. </body>
  347. </html>