Modifying Package Template Files for Rust Applications

To ensure your package has all the required files for successful installations, you must use the debmake command to generate the template files necessary to create your package.

About This Task

Whether you are creating a new package or updating an existing one, you should generate the template files to ensure the package has everything it needs to build and install successfully, regardless of the destination. In this procedure, you will use the debmake command to create the template files, and update them as necessary.

By default, if run with no options, and your package working directory includes all the minimum required files per creating-a-sample-application, the command will provide default values based on your environment. For example, the binary and source package name is derived from the working directory name, as well as the upstream revision. If you want to specify different values, run debmake with the –help option to see all your available customization options.

It is important to understand that each template file will be processed when you run the debuild command to compile your application package. The debuild output will provide specfic details for any missing template information. For additional information, see building-the-application-package.

Note

A set of updated template files for the fibonacci application is available at eLxr User Documentation: Samples repository.

Before You Begin

  • You must have the necessary development tools installed. For details, see development-tools-overview-and-requirements

  • You must have a package directory as described in creating-a-sample-application, or an existing package that you want to update.

Procedure

  1. Navigate to your package working directory.

    $ cd fibonacci-rust-1.0
    
  2. Run the debmake command.

    $ debmake -f rust -p fibonacci-rust -u 1.0
    
    I: substituting => /usr/share/debmake/extra0/rules
    I: creating => debian/rules
    I: substituting => /usr/share/debmake/extra0/changelog
    I: creating => debian/changelog
    I: substituting => /usr/share/debmake/extra1/watch
    I: creating => debian/watch
    I: substituting => /usr/share/debmake/extra1/README.Debian
    I: creating => debian/README.Debian
    I: substituting => /usr/share/debmake/extra1source/local-options
    I: creating => debian/source/local-options
    I: substituting => /usr/share/debmake/extra1source/format
    I: creating => debian/source/format
    I: substituting => /usr/share/debmake/extra1patches/series
    I: creating => debian/patches/series
    I: run "debmake -x2" to get more template files
    I: $ wrap-and-sort
    
  3. Review the new folder structure and template files. Once the debmake command completes, it creates a number of new files, called template files, in a new debian directory in the working directory. Essentially, you must review and update each template file in the debian directory. For details on each template file requirement, see Guide for Debian Maintainers: Modification to the Template Files.

  4. Review and update the debian/rules template. This file defines the options that the debuild build script will run. Each option is specific to a certain function to let you specify additional lintian build options. Note that the only required option is the two lines that comprise %: dh $@.

    Update the file to match the following contents.

    #!/usr/bin/make -f
    %:
          dh $@
    
    override_dh_auto_build:
          cargo build --release
    
    override_dh_auto_install:
          install -d $(CURDIR)/debian/$(shell dh_listpackages)/usr/bin
          install -m 0755 target/release/fibonacci-rust $(CURDIR)/debian/$(shell dh_listpackages)/usr/bin/
    
    export DH_VERBOSE = 1
    export DEB_CFLAGS = -g
    export DEB_BUILD_MAINT_OPTIONS = hardening=+all
    export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
    export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
    
  5. Review and update the debian/control template to match the following example.

    Source: fibonacci-rust
    Section: devel
    Priority: optional
    Maintainer: Your Name <your.name@youremail.com>
    Build-Depends: debhelper (>=13)
    Standards-Version: 4.5.1
    Homepage: http://elxr.org
    Rules-Requires-Root: no
    #Vcs-Git: https://salsa.debian.org/debian/fibonacci.git
    #Vcs-Browser: https://salsa.debian.org/debian/fibonacci
    
    Package: fibonacci-rust
    Architecture: any
    Multi-Arch: foreign
    Depends: ${misc:Depends}, ${shlibs:Depends}
    Description: Simple fibonacci application to demonstrate
      packaging with eLxr.
    
  6. Set the environment compatibility to ensure successful package builds.

    $ echo "13" > debian/compat
    
  7. Review and update the debian/copyright template to match the following example. For your own applications, with specific license or copyright information, you will want to ensure this file is accurate.

    Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
    Upstream-Name: fibonacci-rust
    Upstream-Contact: your.name@elxr.org
    Source: https://elxr.org
    #
    # Please double check copyright with the licensecheck(1) command.
    
    Files:
                 Cargo.toml
                 src/fib_math.rs
                 src/main.rs
    Copyright: __NO_COPYRIGHT_NOR_LICENSE__
    License:   __NO_COPYRIGHT_NOR_LICENSE__
    
    #----------------------------------------------------------------------------
    # huge files   (skipped):
    #         target/release/fibonacci
    #         target/release/deps/fibonacci-8ee5ac80dca6a659
    
    #----------------------------------------------------------------------------
    # Files marked as NO_LICENSE_TEXT_FOUND may be covered by the following
    # license/copyright files.
    
  8. Review the remaining template files and make updates as necessary.

    • changelog file. Add and entry to this file for each package update.

    • README.Debian file. This is the README file for your package. Update this with as much information as necessary to help someone understand what your package does and how to get started with it.

    • source directory
      • control file. Update this file if you want to perform automated testing as part of the installation. This includes specifying testcode.sh script and setting any restrictions required by the application.

      • format file. Update this file to specify the quilt version (default 3.0).

      • local-options file. Update this file to specify any local build options for the gbp-buildpackage command.

      • options file. Update this file to specify merge and commit options for patches.

      • patch-header file. Review and update this file only if you are using dgit-maint-merge. If you are using gbp-buildpackage, no updates are necessary.

    • tests/control file. Same as source/control file, above.

    • upstream/metadata file. Update this file to include the upstream metadata that defines your application.


Results

Now that your template file updates are complete, you will need to build the package with debuild. For details, see Building the Application Package.