Administra paquetes de Debian

En esta página, se describe cómo agregar, ver y borrar paquetes de Debian en repositorios de Apt.

Antes de comenzar

  1. Si el repositorio de Apt de destino no existe, crea uno nuevo.
  2. Configura las VMs para acceder al repositorio.
  3. (Opcional) Configura valores predeterminados para los comandos de gcloud.
  4. Asegúrate de que los nombres de tus paquetes en los metadatos cumplan con los estándares de nombres de paquetes de Debian.

Agrega paquetes

Modos de repositorio: estándar

Debes tener permisos de lectura y escritura para el repositorio para agregar paquetes.

Puedes subir un paquete a un repositorio con Google Cloud CLI o importar un paquete almacenado en Cloud Storage. Si compilas paquetes con Cloud Build, la compilación puede almacenarlos en Cloud Storage para que los importes.

Las operaciones de importación o carga muy largas pueden exceder el período de vencimiento del token que usa gcloud CLI para llamar a la API. Si tienes una gran cantidad de paquetes para agregar, considera agregarlos en lotes más pequeños para que cada operación de carga o importación pueda completarse en un período más corto. Consulta la documentación de solución de problemas de paquetes del SO para obtener más información.

Carga directa

Usa el gcloud artifacts apt upload comando para subir un paquete a un repositorio de Apt:

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

Reemplaza los siguientes valores:

  • REPOSITORY es el nombre del repositorio de Artifact Registry.
  • LOCATION es la ubicación regional del repositorio.
  • PACKAGES es la ruta de acceso al paquete.

Por ejemplo, para subir el paquete my-package.deb al repositorio de Apt my-repo en la ubicación u-france-east1, ejecuta lo siguiente:

gcloud artifacts apt upload my-repo \
    --location=u-france-east1 \
    --source=my-package.deb

Cloud Storage

  1. Para subir los paquetes a Cloud Storage, haz lo siguiente:
    • Sube paquetes directamente a un bucket de Cloud Storage.
  2. Ejecuta el siguiente comando:
    gcloud artifacts apt import REPOSITORY \
      --location=LOCATION \
      --gcs-source=PACKAGES
    

    Reemplaza los siguientes valores:

    • REPOSITORY es el nombre del repositorio de Artifact Registry.
    • LOCATION es la ubicación regional del repositorio.
    • PACKAGES es una lista de paquetes separados por comas en Cloud Storage. Para subir todos los paquetes de un directorio, usa un comodín de directorio (*) o usa un comodín de directorio recursivo (**) para subir todos los paquetes en todos los subdirectorios.

    Por ejemplo, para subir el paquete package.deb y todos los paquetes del directorio directory del bucket my-bucket al repositorio de Apt my-repo en la ubicación u-france-east1, ejecuta lo siguiente:

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

Cuando se complete la operación de carga o importación, puedes usar la Cloud de Confiance consola o gcloud CLI para ver paquetes en el repositorio y confirmar que se subieron correctamente.

Si tienes un repositorio grande con muchos paquetes, es posible que tarde varios minutos en volver a generar el índice de paquetes para que los paquetes nuevos sean visibles para el cliente de Apt.

Visualiza paquetes

Modos de repositorio: estándar

Para ver los paquetes, debes tener los permisos en el rol de lector de Artifact Registry . Artifact Registry no muestra los archivos dentro de los paquetes.

To view packages and package versions using the Cloud de Confiance console or gcloud:

Console

  1. Open the Repositories page in the Cloud de Confiance console.

    Abrir la página repositorios

  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]

Replace the following:

  • REPOSITORY is the name of the repository. If you configured a default repository, you can omit this flag to use the default.
  • LOCATION is the regional location of the repository. If you configured a default location, then 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]

Replace the following:

  • 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, then you can omit this flag to use the default.
  • LOCATION is the regional location of the repository. Use this flag to view repositories in a specific location. If you configured a default location, then you can omit this flag to use the default.

Instala paquetes

Modos de repositorio: estándar

Antes de instalar paquetes, verifica que hayas configurado correctamente el administrador de paquetes y el repositorio.

Para instalar un paquete en el repositorio, haz lo siguiente:

  1. Actualiza la lista de paquetes disponibles:

    sudo apt update
    
  2. Instala el paquete y especifica el nombre del repositorio configurado en Apt.

    sudo apt install PACKAGE/REPOSITORY
    

    Reemplaza los siguientes valores:

    • PACKAGE es el nombre del paquete.
    • REPOSITORY es el nombre del repositorio de Artifact Registry.

    Por ejemplo, para instalar el paquete my-package del repositorio my-repo, ejecuta el siguiente comando:

    sudo apt install my-package -t my-repo
    

Borra paquetes

Modos de repositorio: estándar

Before you delete a package or package version, verify that any you have communicated or addressed any important dependencies on it.

To delete a package:

Console

  1. Open the Repositories page in the Cloud de Confiance console.

    Abrir la página repositorios

  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]

Replace the following:

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

The --async flag causes the command to 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 Cloud de Confiance console.

    Abrir la página repositorios

  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]

Replace the following:

  • VERSION is the name of the version to delete.
  • PACKAGE is the name of the package in the repository.
  • REPOSITORY is the name of the repository. If you configured a default repository, then you can omit this flag to use the default.
  • LOCATION is the regional location of the repository. Use this flag to view repositories in a specific location. If you configured a default location, then you can omit this flag to use the default.

The --async flag causes the command to return immediately, without waiting for the operation in progress to complete.

En el caso de los repositorios grandes, puede tardar unos minutos en volver a generar el índice de paquetes de Apt para reflejar las eliminaciones.

¿Qué sigue?