Help Center/ CodeArts Artifact/ Best Practices/ Uploading/Obtaining a Debian Package Using Linux Commands
Updated on 2026-03-13 GMT+08:00

Uploading/Obtaining a Debian Package Using Linux Commands

Software developers often need to upload custom private packages to a Debian repository so that other team members can easily access and use them. However, without clear guidance, developers may encounter issues when uploading packages using Linux commands, leading to upload or dependency retrieval failures. Ensuring successful upload and access to private packages is therefore a common challenge. This document describes how to upload a private package to a Debian repository and fetch dependencies from the repository using Linux commands.

Prerequisites

  • You have a Debian package available.
  • You have a Linux host that can connect to the Internet.
  • You have created a Debian repository.
  • You have been granted permissions to upload, download, and view packages in the current repository. For details, see Configuring Repository Permissions.

Publishing a Package to a Debian Repository

  1. Use your Huawei Cloud account to access self-hosted repos.
  2. Select the target Debian repository from the repository list. Click Tutorial on the right of the page.
  3. In the displayed dialog box, click Download Guide File.

  4. On the Linux host, run the following command to upload a Debian package.

    curl -u <USERNAME>:<PASSWORD> -X PUT "https:// <repoUrl>/<DEBIAN_PACKAGE_NAME>;deb.distribution=<DISTRIBUTION>;deb.component=<COMPONENT>;deb.architecture=<ARCHITECTURE>" -T <PATH_TO_FILE>

    In this command, USERNAME, PASSWORD, and repoUrl can be obtained from the Debian upload command in the configuration file downloaded in 3.

    • USERNAME: username used for uploading files, which can be obtained from the Debian configuration file. For details, see the example figure.
    • PASSWORD: password used for uploading files, which can be obtained from the Debian configuration file. For details, see the example figure.
    • repoUrl: URL used for uploading files, which can be obtained from the Debian configuration file. For details, see the example figure.

      DEBIAN_PACKAGE_NAME, DISTRIBUTION, COMPONENT, and ARCHITECTURE can be obtained from the Debian package to be uploaded.

      The a2jmidid_8_dfsg0-1_amd64.deb package is used as an example.

    • DEBIAN_PACKAGE_NAME: software package name, for example, a2jmidid_8_dfsg0-1_amd64.deb.
    • DISTRIBUTION: published version, for example, trusty.
    • COMPONENT: component name, for example, main.
    • ARCHITECTURE: system architecture, for example, amd64.
    • PATH_TO_FILE: local storage path of the Debian package, for example, /root/a2jmidid_8_dfsg0-1_amd64.deb.

      The following figure shows the complete commands.

  5. After the commands are successfully executed, go to the self-hosted repo page and find the uploaded Debian package.

Obtaining a Dependency from a Debian Repository

The following procedure uses the Debian package published in Publishing a Package to a Debian Repository as an example to describe how to obtain a dependency from a Debian repository.

  1. Go to the Debian repository by referring to Publishing a Package to a Debian Repository. Click Tutorial on the right of the page.
  2. In the displayed dialog box, set Select purpose to Download and click Downloading the Public Key to download the Debian repository public key.

  3. Import the gpg public key.

    gpg --import <PUBLIC_KEY_PATH>

    PUBLIC_KEY_PATH: local path for storing the Debian public key, for example, artifactory.gpg.public.

  4. Add the public key to the list of keys used by apt to authenticate packages.

    gpg --export --armor <SIG_ID> | apt-key add -

  5. Add the apt repository source.

    Open the configuration file (for details about how to obtain the file, see Publishing a Package to a Debian Repository), replace all DISTRIBUTION fields with the value of COMPONENT (for example, main) used for uploading the Debian file, and add the repository source based on the downloaded configuration file sources.list.

  6. After the repository source is added, run the following command to update the repository source.

    apt-get update

  7. Run the following command to download the Debian package. Replace a2jmidid with the actual value of PACKAGE.

    apt download a2jmidid

    To obtain <PACKAGE>, perform the following steps.

    Download the Packages source data of the Debian package. The following uses the a2jmidid package as an example.