| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <title>Bash Script gen_pack.sh</title>
- <title>CMSIS-Pack: Bash Script gen_pack.sh</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <link href="cmsis.css" rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <script type="text/javascript" src="printComponentTabs.js"></script>
- <link href="navtree.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="resize.js"></script>
- <script type="text/javascript" src="navtree.js"></script>
- <script type="text/javascript">
- $(document).ready(initResizable);
- $(window).load(resizeHeight);
- </script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/search.js"></script>
- <script type="text/javascript">
- $(document).ready(function() { searchBox.OnSelectItem(0); });
- </script>
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 46px;">
- <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
- <td style="padding-left: 0.5em;">
- <div id="projectname">CMSIS-Pack
-  <span id="projectnumber">Version 1.6.3</span>
- </div>
- <div id="projectbrief">Delivery Mechanism for Software Packs</div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <div id="CMSISnav" class="tabs1">
- <ul class="tablist">
- <script type="text/javascript">
- <!--
- writeComponentTabs.call(this);
- //-->
- </script>
- </ul>
- </div>
- <!-- Generated by Doxygen 1.8.6 -->
- <script type="text/javascript">
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- </script>
- <div id="navrow1" class="tabs">
- <ul class="tablist">
- <li><a href="index.html"><span>Main Page</span></a></li>
- <li class="current"><a href="pages.html"><span>Usage and Description</span></a></li>
- <li>
- <div id="MSearchBox" class="MSearchBoxInactive">
- <span class="left">
- <img id="MSearchSelect" src="search/mag_sel.png"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- alt=""/>
- <input type="text" id="MSearchField" value="Search" accesskey="S"
- onfocus="searchBox.OnSearchFieldFocus(true)"
- onblur="searchBox.OnSearchFieldFocus(false)"
- onkeyup="searchBox.OnSearchFieldChange(event)"/>
- </span><span class="right">
- <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
- </span>
- </div>
- </li>
- </ul>
- </div>
- </div><!-- top -->
- <div id="side-nav" class="ui-resizable side-nav-resizable">
- <div id="nav-tree">
- <div id="nav-tree-contents">
- <div id="nav-sync" class="sync"></div>
- </div>
- </div>
- <div id="splitbar" style="-moz-user-select:none;"
- class="ui-resizable-handle">
- </div>
- </div>
- <script type="text/javascript">
- $(document).ready(function(){initNavTree('bash_script.html','');});
- </script>
- <div id="doc-content">
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Pages</a></div>
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
- <div class="header">
- <div class="headertitle">
- <div class="title">Bash Script gen_pack.sh </div> </div>
- </div><!--header-->
- <div class="contents">
- <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>
- <p>For using <a class="el" href="bash_script.html#gen_pack_sh">gen_pack.sh</a></p>
- <ul>
- <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>
- <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>
- </ul>
- <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>
- <p>Below is a sample output (reduced). </p>
- <div class="fragment"><div class="line">$ ./gen_pack.sh</div>
- <div class="line"> </div>
- <div class="line">Starting CMSIS-Pack Generation: 19 Aug 2019 15:34:02</div>
- <div class="line">7z is /C/Program Files/7-Zip/7z</div>
- <div class="line">PackChk is /C/Keil_v5/ARM/PACK/ARM/CMSIS/5.6.0/CMSIS/Utilities/Win32/PackChk</div>
- <div class="line"> </div>
- <div class="line">Generating Pack Version: <span class="keywordflow">for</span> MyVendor.MyPack</div>
- <div class="line"> </div>
- <div class="line">Adding directories to pack:</div>
- <div class="line">Include/ Source/</div>
- <div class="line"> </div>
- <div class="line">Adding files to pack:</div>
- <div class="line">License.txt ReadMe.txt</div>
- <div class="line"> </div>
- <div class="line">PackChk.exe 1.3.87</div>
- <div class="line">Copyright (C) 2012-2019 ARM Ltd and ARM Germany GmbH. All rights reserved.</div>
- <div class="line"> </div>
- <div class="line">M362: Also suppressing Messages M502 and M504</div>
- <div class="line"> </div>
- <div class="line">Phase1: Read PDSC files</div>
- <div class="line">Phase2: Static Data & Dependencies check</div>
- <div class="line"> WARNING M304: C:\W\CMSIS_5\CMSIS\Pack\Bash\build\MyVendor.MyPack.pdsc</div>
- <div class="line"> No <span class="keyword">package </span>URL (<url>-tag and/or value) found in PDSC file!</div>
- <div class="line"> </div>
- <div class="line">Phase3: RTE Model based Data & Dependencies check</div>
- <div class="line">Found 0 Error(s) and 1 Warning(s).</div>
- <div class="line"> </div>
- <div class="line">creating pack file MyVendor.MyPack.1.0.0.pack</div>
- <div class="line"> </div>
- <div class="line">Creating archive: C:/W/CMSIS_5/CMSIS/Pack/Bash/output/MyVendor.MyPack.1.0.0.pack</div>
- <div class="line">Add new data to archive: 2 folders, 5 files, 1165 bytes (2 KiB)</div>
- <div class="line"> </div>
- <div class="line">Everything is Ok</div>
- <div class="line">Completed CMSIS-Pack Generation ...</div>
- </div><!-- fragment --><p><a class="anchor" id="gen_pack_sh"></a><b>gen_pack.sh Bash script template file</b></p>
- <p>The <b>gen_pack.sh</b> script template allows to configure:</p>
- <ul>
- <li>Path environment variables for related utilities</li>
- <li>Directory names for temporary build and output files</li>
- <li>Directory names and files in the root directory that should be included in the pack</li>
- </ul>
- <pre class="fragment">#!/bin/bash
- # Version: 1.0
- # Date: 2019-08-16
- # This bash script generates a CMSIS Software Pack:
- #
- # Pre-requisites:
- # - bash shell (for Windows: install git for Windows)
- # - 7z in path (zip archiving utility)
- # e.g. Ubuntu: sudo apt-get install p7zip-full p7zip-rar)
- # - PackChk in path with execute permission
- # (see CMSIS-Pack: CMSIS/Utilities/<os>/PackChk)
- # - xmllint in path (XML schema validation; available only for Linux)
- ############### EDIT BELOW ###############
- # Extend Path environment variable locally
- #
- if [ `uname -s` = "Linux" ]
- then
- CMSIS_PACK_PATH="/home/$USER/.arm/Packs/ARM/CMSIS/5.6.0/"
- PATH_TO_ADD="$CMSIS_PACK_PATH/CMSIS/Utilities/Linux-gcc-4.8.3/"
- else
- CMSIS_PACK_PATH="/C/Keil_v5/ARM/PACK/ARM/CMSIS/5.6.0"
- PATH_TO_ADD="/C/Program Files/7-Zip/:$CMSIS_PACK_PATH/CMSIS/Utilities/Win32/"
- fi
- [[ ":$PATH:" != *":$PATH_TO_ADD}:"* ]] && PATH="${PATH}:${PATH_TO_ADD}"
- echo $PATH_TO_ADD appended to PATH
- echo " "
- # Pack warehouse directory - destination
- PACK_WAREHOUSE=output/
- # Temporary pack build directory
- PACK_BUILD=build/
- # Specify directories included in pack relative to base directory
- # All directories:
- PACK_DIRS=`ls -d */`
- # Do not include the build directory if it is local
- PACK_DIRS=${PACK_DIRS//$PACK_BUILD/}
- PACK_DIRS=${PACK_DIRS//$PACK_WAREHOUSE/}
- # alternative: specify directory names to be added to pack base directory
- # PACK_DIRS="
- # Source
- # Include
- #"
-
- # Specify file names to be added to pack base directory
- PACK_BASE_FILES="
- License.txt
- ReadMe.txt
- "
- ############ DO NOT EDIT BELOW ###########
- echo Starting CMSIS-Pack Generation: `date`
- # Zip utility check
- ZIP=7z
- type -a $ZIP
- errorlevel=$?
- if [ $errorlevel -gt 0 ]
- then
- echo "Error: No 7zip Utility found"
- echo "Action: Add 7zip to your path"
- echo " "
- exit
- fi
- # Pack checking utility check
- PACKCHK=PackChk
- type -a $PACKCHK
- errorlevel=$?
- if [ $errorlevel != 0 ]
- then
- echo "Error: No PackChk Utility found"
- echo "Action: Add PackChk to your path"
- echo "Hint: Included in CMSIS Pack:"
- echo "<pack_root_dir>/ARM/CMSIS/<version>/CMSIS/Utilities/<os>/"
- echo " "
- exit
- fi
- echo " "
- # Locate Package Description file
- # check whether there is more than one pdsc file
- NUM_PDSCS=`ls -1 *.pdsc | wc -l`
- PACK_DESCRIPTION_FILE=`ls *.pdsc`
- if [ $NUM_PDSCS -lt 1 ]
- then
- echo "Error: No *.pdsc file found in current directory"
- echo " "
- elif [ $NUM_PDSCS -gt 1 ]
- then
- echo "Error: Only one PDSC file allowed in directory structure:"
- echo "Found:"
- echo "$PACK_DESCRIPTION_FILE"
- echo "Action: Delete unused pdsc files"
- echo " "
- exit
- fi
- SAVEIFS=$IFS
- IFS=.
- set $PACK_DESCRIPTION_FILE
- # Pack Vendor
- PACK_VENDOR=$1
- # Pack Name
- PACK_NAME=$2
- echo Generating Pack Version: for $PACK_VENDOR.$PACK_NAME
- echo " "
- IFS=$SAVEIFS
- #if $PACK_BUILD directory does not exist, create it.
- if [ ! -d $PACK_BUILD ]; then
- mkdir -p $PACK_BUILD
- fi
- # Copy files into build base directory: $PACK_BUILD
- # pdsc file is mandatory in base directory:
- cp -f ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_BUILD}
- # directories
- echo Adding directories to pack:
- echo $PACK_DIRS
- echo " "
- for d in ${PACK_DIRS}
- do
- cp -r "$d" ${PACK_BUILD}
- done
- # files for base directory
- echo Adding files to pack:
- echo $PACK_BASE_FILES
- echo " "
- for f in $PACK_BASE_FILES
- do
- cp -f "$f" $PACK_BUILD/
- done
- # Run Schema Check (for Linux only):
- # sudo apt-get install libxml2-utils
- if [ `uname -s` = "Linux" ]
- then
- echo Running schema check for $PACK_VENDOR.$PACK_NAME.pdsc
- xmllint --noout --schema ${CMSIS_PACK_PATH}/CMSIS/Utilities/PACK.xsd $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc
- errorlevel=$?
- if [ $errorlevel -ne 0 ]; then
- echo "build aborted: Schema check of $PACK_VENDOR.$PACK_NAME.pdsc against PACK.xsd failed"
- echo " "
- exit
- fi
- else
- echo "Use MDK PackInstaller to run schema validation for $PACK_VENDOR.$PACK_NAME.pdsc"
- fi
- # Run Pack Check and generate PackName file with version
- $PACKCHK $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc -n PackName.txt -x M362
- errorlevel=$?
- if [ $errorlevel -ne 0 ]; then
- echo "build aborted: pack check failed"
- echo " "
- exit
- fi
- PACKNAME=`cat PackName.txt`
- rm -rf PackName.txt
- # Archiving
- # $ZIP a $PACKNAME
- echo creating pack file $PACKNAME
- #if $PACK_WAREHOUSE directory does not exist create it
- if [ ! -d $PACK_WAREHOUSE ]; then
- mkdir -p $PACK_WAREHOUSE
- fi
- pushd $PACK_WAREHOUSE
- PACK_WAREHOUSE=`pwd`
- popd
- pushd $PACK_BUILD
- "$ZIP" a $PACK_WAREHOUSE/$PACKNAME -tzip
- popd
- errorlevel=$?
- if [ $errorlevel -ne 0 ]; then
- echo "build aborted: archiving failed"
- exit
- fi
- echo "build of pack succeeded"
- # Clean up
- echo "cleaning up ..."
- rm -rf $PACK_BUILD
- echo " "
- echo Completed CMSIS-Pack Generation: `date`
- </pre> </div></div><!-- contents -->
- </div><!-- doc-content -->
- <!-- start footer part -->
- <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
- <ul>
- <li class="navelem"><a class="el" href="createPackUtil.html">Utilities for Creating Packs</a></li>
- <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.
- <!--
- <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
- -->
- </li>
- </ul>
- </div>
- </body>
- </html>
|