Managing Debian packages

This page describes adding, viewing, and deleting Debian packages in Apt repositories.

Before you begin

  1. If the target Apt repository doesn't exist, create a new repository.
  2. Configure VMs to access the repository.
  3. (Optional) Configure defaults for gcloud commands.

Adding packages

You must have both read and write permissions for the repository to add packages.

You can upload a package to a repository using the gcloud command-line tool, or you can import a package that is stored in Cloud Storage. If you build packages using Cloud Build, the build can store the packages in Cloud Storage for you to import.

Direct upload

Use the gcloud beta artifacts apt upload command to upload a package to an Apt repository:

gcloud beta artifacts apt upload REPOSITORY \
    --location=LOCATION \
    --source=PACKAGES

Replace the following values:

  • REPOSITORY is the Artifact Registry repository name.
  • LOCATION is the regional or multi-regional location of the repository.
  • PACKAGES is the path to the package.

For example, to upload the package my-package.deb to the Apt repository my-repo in the location us-central1, run:

gcloud beta artifacts apt upload my-repo \
    --location=us-central1 \
    --source=my-package.deb

Cloud Storage

  1. Upload the packages to Cloud Storage in one of the following ways:

    • Upload packages directly to a Cloud Storage bucket
    • Build packages with Cloud Build and store it in a bucket
  2. Run the following command:

    gcloud beta artifacts apt import REPOSITORY \
        --location=LOCATION \
         --gcs-source=PACKAGES
    

    Replace the following values:

    • REPOSITORY is the Artifact Registry repository name.
    • LOCATION is the regional or multi-regional location of the repository.
    • PACKAGES is a comma separated list of packages in Cloud Storage. To upload all packages from a directory, use a directory wildcard (*) or use a recursive directory wildcard (**) to upload all packages in all subdirectories.

    For example, to upload a the package package.rpm and all packages in the directory directory from the bucket my-bucket to the Apt repository my-repo in the location us-central1, run:

    gcloud beta artifacts apt import my-repo \
       --location=us-central1 \
       --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory*
    

Viewing packages

To view packages, you must have the permissions in the Artifact Registry Reader role.

To view packages and package versions using the Google Cloud Console or gcloud:

Console

  1. Open the Repositories page in the Google Cloud Console.

    Open the Repositories page

  2. In the repository list, click the appropriate repository.

    The Packages page lists the packages in the repository.

  3. Click a package to view versions of the package.

gcloud

To list packages in a repository, run the following command:

gcloud artifacts packages list [--repository=REPOSITORY] [--location=LOCATION]

Where

  • REPOSITORY is the name of the repository. If you configured a default repository, you can omit this flag to use the default.
  • LOCATION is a regional or multi-regional location. Use this flag to view repositories in a specific location. If you configured a default location, you can omit this flag to use the default.

To view versions of a package, run the following command:

gcloud artifacts versions list --package=PACKAGE \
    [--repository=REPOSITORY] [--location=LOCATION]

Where

  • PACKAGE is the ID of the package or fully qualified identifier for the package.
  • REPOSITORY is the name of the repository. If you configured a default repository, you can omit this flag to use the default.
  • LOCATION is a regional or multi-regional location. Use this flag to view repositories in a specific location. If you configured a default location, you can omit this flag to use the default.

Installing packages

Before you install packages, verify that you have configured the package manager and repository correctly.

To install a package in the repository:

  1. Update the list of available packages:

    sudo apt update
    
  2. Install the package, specifying the name of the repository configured in Apt.

    sudo apt install PACKAGE/REPOSITORY
    

    Replace the following values:

    • PACKAGE is the package name
    • REPOSITORY is the name of the Artifact Registry repository

    For example, to install the package my-package from the repository my-repo, run the command:

    sudo apt install my-package -t my-repo
    

Deleting packages

To delete a package:

Console

  1. Open the Repositories page in the Google Cloud Console.

    Open the Repositories page

  2. In the repository list, click the appropriate repository.

    The Packages page lists the packages in the repository.

  3. Select the package that you want to delete.

  4. Click DELETE.

  5. In the confirmation dialog box, click DELETE.

gcloud

Run the following command:

gcloud artifacts packages delete PACKAGE \
    [--repository=REPOSITORY] [--location=LOCATION] [--async]

Where

  • PACKAGE is the name of the package in the repository.
  • REPOSITORY is the name of the repository. If you configured a default repository, you can omit this flag to use the default.
  • LOCATION is a regional or multi-regional location. Use this flag to view repositories in a specific location. If you configured a default location, you can omit this flag to use the default.
  • --async Return immediately, without waiting for the operation in progress to complete.

To delete versions of a package:

Console

  1. Open the Repositories page in the Google Cloud Console.

    Open the Repositories page

  2. In the repository list, click the appropriate repository.

    The Packages page lists the packages in the repository.

  3. Click a package to view versions of that package.

  4. Select versions that you want to delete.

  5. Click DELETE.

  6. In the confirmation dialog box, click DELETE.

gcloud

Run the following command:

gcloud artifacts versions delete VERSION \
    --package=PACKAGE \
    [--repository=REPOSITORY] [--location=LOCATION] \
    [--async]

Where

  • PACKAGE is the name of the package in the repository.
  • REPOSITORY is the name of the repository. If you configured a default repository, you can omit this flag to use the default.
  • LOCATION is a regional or multi-regional location. Use this flag to view repositories in a specific location. If you configured a default location, you can omit this flag to use the default.
  • --async returns immediately, without waiting for the operation in progress to complete.

What's next