Help Center/ CodeArts Artifact/ Best Practices/ Uploading/Obtaining an RPM Component Using Linux Commands
Updated on 2024-11-11 GMT+08:00

Uploading/Obtaining an RPM Component Using Linux Commands

Background

A self-hosted repo manages private component packages (such as Maven) corresponding to various development languages. Different development language components vary in the archive format. A self-hosted repo manages private development language components and shares them with other developers in the same enterprise or team.

This practice describes how to use Linux commands to upload a component to an RPM repository and obtain a dependency from the repository.

Preparations

  • You have an RPM component available.
  • You have a Linux host that can connect to the public network available.
  • You have created an RPM repository.
  • You have permissions for the current repository. For details, see Managing Repository Permissions.

Releasing a Component to an RPM Repository

  1. Log in to the CodeArts homepage, choose Services > Artifact on the top navigation bar, and click the Self-hosted Repos tab. Select an RPM repository. Click Tutorial on the right of the page.

  2. In the displayed dialog box, click Download Configuration File.
  3. On the Linux host, run the following commands to upload an RPM component:

    curl -u {{user}}:{{password}} -X PUT https://{{repoUrl}}/{{component}}/{{version}}/ -T {{localFile}}

    In this command, user, password, and repoUrl can be obtained from the RPM upload command in the configuration file downloaded in the previous step.

    • user: character string before the colon (:) between curl -u and -X
    • password: character string after the colon (:) between curl -u and -X
    • repoUrl: character string between https:// and /{{component}}

    component, version, and localFile can be obtained from the RPM component to be uploaded. The hello-0.17.2-54.x86_64.rpm component is used as an example.

    • component: software name, for example, hello.
    • version: software version, for example, 0.17.2.
    • localFile: RPM component, for example, hello-0.17.2-54.x86_64.rpm.

    The following figure shows the complete command.

  4. After the command is successfully executed, go to the self-hosted repo page and find the uploaded RPM component.

Obtaining a Dependency from an RPM Repository

The following procedure uses the RPM component released in Releasing a Component to an RPM Repository as an example to describe how to obtain a dependency from an RPM repository.

  1. Download the configuration file of the RPM repository by referring to Releasing a Component to an RPM Repository.
  2. Open the configuration file, replace all {{component}} in the file with the value of {{component}} (hello in this file) used for uploading the RPM file, delete the RPM upload command, and save the file.

  3. Save the modified configuration file to the /etc/yum.repos.d/ directory on the Linux host.

  4. Run the following command to download the RPM component: Replace hello with the actual value of component.

    yum install hello