En esta página, se describe cómo agregar, ver y borrar paquetes de Debian en los repositorios de Apt.
Antes de comenzar
- Si el repositorio de Apt de destino no existe, crea uno nuevo.
- Configura las VMs para acceder al repositorio.
- (Opcional) Configura valores predeterminados para los comandos de gcloud.
- Asegúrate de que los nombres de los 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 que el repositorio agregue paquetes.
Puedes subir un paquete a un repositorio con Google Cloud CLI o importar un paquete que se almacena 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 se pueda completar en menos tiempo. Consulta la documentación sobre la solución de problemas de paquetes del SO para obtener más información.
Carga directa
Usa el comando gcloud artifacts apt upload
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 o multirregional 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 us-west1
, ejecuta lo siguiente:
gcloud artifacts apt upload my-repo \ --location=us-west1 \ --source=my-package.deb
Cloud Storage
- Para subir los paquetes a Cloud Storage, sigue estos pasos:
- Sube paquetes directamente a un bucket de Cloud Storage.
- Compila paquetes con Cloud Build y almacénalos en un bucket
- 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 o multirregional 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 un comodín de directorio recursivo (**
) para subir todos los paquetes de todos los subdirectorios.
Por ejemplo, para subir el paquete
package.deb
y todos los paquetes del directoriodirectory
del bucketmy-bucket
al repositorio de Aptmy-repo
en la ubicaciónus-west1
, ejecuta lo siguiente:gcloud artifacts apt import my-repo \ --location=us-west1 \ --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 Google Cloud console o gcloud CLI para ver los paquetes en el repositorio y confirmar que se subieron correctamente.
Si tienes un repositorio grande con muchos paquetes, es posible que se demoren varios minutos en volver a generar el índice de paquetes para que el cliente de Apt pueda ver los paquetes nuevos.
Cómo ver los paquetes
Modos de repositorio: estándar, remoto (versión preliminar)Para ver los paquetes, debes tener los permisos del rol de lector de Artifact Registry. Artifact Registry no muestra archivos dentro de los paquetes.
To view packages and package versions using the Google Cloud console
or gcloud
:
Console
Open the Repositories page in the Google Cloud console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
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 or multi-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 or multi-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, remoto (versión preliminar)Antes de instalar paquetes, verifica que hayas configurado correctamente el administrador de paquetes y el repositorio.
Para instalar un paquete en el repositorio, sigue estos pasos:
Actualiza la lista de paquetes disponibles:
sudo apt update
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. Para los repositorios remotos, usa el nombre del repositorio upstream estándar.
Por ejemplo, para instalar el paquete
my-package
del repositoriomy-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
Open the Repositories page in the Google Cloud console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Select the package that you want to delete.
Click DELETE.
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 or multi-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
Open the Repositories page in the Google Cloud console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Click a package to view versions of that package.
Select versions that you want to delete.
Click DELETE.
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 or multi-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, la regeneración del índice del paquete de Apt puede tardar unos minutos en reflejar las eliminaciones.
¿Qué sigue?
- Obtén más información para administrar paquetes RPM
- Descarga archivos individuales dentro de un paquete