QDK - QPKG Development Kit
Total Page:16
File Type:pdf, Size:1020Kb
QDK - QPKG Development Kit Makes Simple Things Easy and Hard Things Possible Copyright 2010 Michael Nordström Table of Contents QDK - QPKG Development Kit.......................................................................................................................1 Preface..............................................................................................................................................................3 Intended Audience...........................................................................................................................3 Conventions.....................................................................................................................................3 Installation of QDK..........................................................................................................................................4 QPKG Configuration File.................................................................................................................................5 Installation Script..............................................................................................................................................8 Generic Installation Script...............................................................................................................8 Package Specific Installation Functions........................................................................................10 Order of Execution.........................................................................................................................13 Installation/Upgrade..................................................................................................................13 QDK Variables...............................................................................................................................................15 Build Scripts...................................................................................................................................................19 User Configuration File..................................................................................................................................21 Invoking qbuild..............................................................................................................................................22 Initialize a Build Environment.......................................................................................................22 Control the Build...........................................................................................................................22 Trust but Verify.............................................................................................................................23 Exclude Files..................................................................................................................................23 Scripts............................................................................................................................................23 Status Information..........................................................................................................................23 Sections..........................................................................................................................................24 Extract QPKG Packages................................................................................................................24 Query Packages..............................................................................................................................24 Help and Usage..............................................................................................................................24 Creating a QPKG Package Using QDK..........................................................................................................25 Creating a Simple QPKG Package................................................................................................25 Creating Platform Specific QPKG Packages.................................................................................27 Converting an Existing QPKG Package........................................................................................31 Appendix A – QPKG Format.........................................................................................................................35 Header Script.................................................................................................................................35 Control Files..................................................................................................................................36 Data File.........................................................................................................................................36 Extra Data Files.............................................................................................................................36 QDK Area......................................................................................................................................37 Tail Section....................................................................................................................................37 2 Preface QDK is used to build QPKG packages. A QPKG package is a self-extracting archive with application files and meta-data. A QPKG package makes it easy for anyone to install and remove packages. It also gives a package maintainer almost total control on how the package is installed on the NAS. The major design goal of QDK is to make it easy for the package maintainer to create a QPKG package. QDK started out as a simple modification of the first official release of the QPKG SDK, but now supersedes it. It includes many new features like architecture check at installation, support for digital signatures, different compression algorithms, a comprehensive option to check that other required QPKG packages or Optware packages are installed (or that conflicting packages are not installed), automatic installation of required Optware packages, and a powerful build script. QDK is distributed under the GPL making it completely open and available for anyone to use. Intended Audience This document is about creating QPKG packages. As such, it assumes that the reader already has some previous knowledge about QPKG packages and at least know how to install and enable a QPKG package using the web interface. This document assumes that you have a basic knowledge of common shell commands. It also helps if you have some familiarity with shell scripts. Conventions The following conventions are used in this document. Italic is used to indicate files, directories, commands, and program names when they appear in the body of a paragraph. Constant Width is used in examples to show the contents of files or the output from commands, and to indicate environment variables, keywords, function names, and other code snippets in the body of a paragraph. Constant Bold is used in examples to show input that is typed literally by the user. # is the shell prompt. [ ] surrounds optional elements in a description of program syntax. The brackets themselves should never be typed. ➥ is the code-continuation character that is inserted into code when a line shouldn't be broken, but we ran out of room on the page. 3 Installation of QDK Before we can start using QDK we have to install it. It is distributed as a platform-independent QPKG package and can be installed using the normal web interface. When installed and enabled QDK is ready to be used. At installation a directory structure is created at the default QPKG location, which depends on whether it is installed on a RAID volume or a single drive. The exact location is available in the QDK_PATH variable in the system-wide configuration file, /etc/config/qdk.conf, but it is usually /share/MD0_DATA/.qpkg/QDK on a RAID system and /share/HDA_DATA/.qpkg/QDK on a single drive system. bin/ qbuild scripts/ qinstall.sh template/ arm-x09/ arm-x19/ config/ icons/ shared/init.sh x86/ x86_64/ package_routines qpkg.cfg qdk qdk is the init script used to enable and disable QDK. This script is run automatically when QDK is enabled or disabled in the web interface. It creates and removes a symbolic link to the qbuild application in /usr/bin. qbuild is the build script. qinstall.sh is the part of the installation script that includes the generic installation functions common to all QPKG packages. This file is never edited by the user. All user defined actions are added to a separate file, package_routines. The template directory include files for a new build environment that can be created using qbuild. By default it includes common subdirectories where the content should be placed and templates for the package specific installation functions, package_routines, the QPKG configuration file, qpkg.cfg, and an init-script. The init- script, init.sh, is renamed to the same name as the package when the new build environment is created. There are also four hidden files, .qpkg_icon.gif, .qpkg_icon_80.gif, .qpkg_icon_gray.gif, and .uninstall.sh. The three first files are the default icons used for QDK in the web interface and the last file is the script run to perform the required actions to clean up after QDK when it is removed using the web interface. This file is created automatically for all QDK based packages at installation time. 4 QPKG Configuration File We begin