Questa pagina descrive l'aggiunta, la visualizzazione e l'eliminazione dei pacchetti Debian nei repository Apt.
Prima di iniziare
- Se il repository Apt di destinazione non esiste, crea un nuovo repository.
- Configura le VM per accedere al repository.
- (Facoltativo) Configura le impostazioni predefinite per i comandi gcloud.
- Assicurati che i nomi dei pacchetti nei metadati siano conformi agli standard dei nomi dei pacchetti Debian.
Aggiunta di pacchetti
Modalità repository: standard
Per aggiungere i pacchetti, devi disporre delle autorizzazioni di lettura e scrittura.
Puoi caricare un pacchetto in un repository utilizzando Google Cloud CLI oppure importare un pacchetto archiviato in Cloud Storage. Se crei pacchetti utilizzando Cloud Build, la build può archiviarli in Cloud Storage per importarli.
Le operazioni di importazione o caricamento molto lunghe potrebbero superare il periodo di scadenza del token che l'gcloud CLI utilizza per chiamare l'API. Se devi aggiungere un numero molto elevato di pacchetti, valuta la possibilità di aggiungerli in batch più piccoli, in modo che ogni operazione di caricamento o importazione possa essere completata in un periodo di tempo più breve. Per ulteriori informazioni, consulta la documentazione sulla risoluzione dei problemi relativi ai pacchetti del sistema operativo.
Caricamento diretto
Utilizza il comando gcloud artifacts apt upload
per caricare un pacchetto in un repository Apt:
gcloud artifacts apt upload REPOSITORY \
--location=LOCATION \
--source=PACKAGES
Sostituisci i seguenti valori:
- REPOSITORY è il nome del repository di Artifact Registry.
- LOCATION è la località a livello di una o più aree geografiche del repository.
- PACKAGES è il percorso del pacchetto.
Ad esempio, per caricare il pacchetto my-package.deb
nel repository Apt
my-repo
nella località us-central1
, esegui:
gcloud artifacts apt upload my-repo \ --location=us-central1 \ --source=my-package.deb
Cloud Storage
Carica i pacchetti in Cloud Storage in uno dei seguenti modi:
- Carica i pacchetti direttamente in un bucket Cloud Storage
- Crea pacchetti con Cloud Build e archiviali in un bucket
Esegui questo comando:
gcloud artifacts apt import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
Sostituisci i seguenti valori:
- REPOSITORY è il nome del repository di Artifact Registry.
- LOCATION è la località a livello di una o più aree geografiche del repository.
- PACKAGES è un elenco di pacchetti separati da virgole in Cloud Storage. Per caricare tutti i pacchetti da una directory, utilizza un carattere jolly directory (
*
) o un carattere jolly di directory ricorsivo (**) per caricare tutti i pacchetti in tutte le sottodirectory.
Ad esempio, per caricare un pacchetto
package.rpm
e tutti i pacchetti nella directorydirectory
dal bucketmy-bucket
al repository Aptmy-repo
nella localitàus-central1
, esegui:gcloud artifacts apt import my-repo \ --location=us-central1 \ --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory*
Al termine dell'operazione di caricamento o importazione, puoi utilizzare la console Google Cloud o l'gcloud CLI per visualizzare i pacchetti nel repository e confermare che sono stati caricati correttamente.
Se hai un repository di grandi dimensioni con molti pacchetti, potrebbero essere necessari diversi minuti per rigenerare l'indice dei pacchetti e renderli nuovi visibili al client Apt.
Visualizzare i pacchetti
Modalità repository: standard, remoto (anteprima)
Per visualizzare i pacchetti, devi disporre delle autorizzazioni nel ruolo Lettore Artifact Registry. Artifact Registry non elenca i file nei pacchetti.
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]
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.
Installazione dei pacchetti
Modalità repository: standard, remoto (anteprima)
Prima di installare i pacchetti, verifica di aver configurato il gestore di pacchetti e il repository correttamente.
Per installare un pacchetto nel repository:
Aggiorna l'elenco dei pacchetti disponibili:
sudo apt update
Installare il pacchetto, specificando il nome del repository configurato in Apt.
sudo apt install PACKAGE/REPOSITORY
Sostituisci i seguenti valori:
- PACKAGE è il nome del pacchetto.
- REPOSITORY è il nome del repository Artifact Registry. Per i repository remoti, utilizza il nome del repository upstream standard.
Ad esempio, per installare il pacchetto
my-package
dal repositorymy-repo
, esegui il comando:sudo apt install my-package -t my-repo
Eliminazione di pacchetti
Modalità repository: standard
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]
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
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]
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.
Per i repository di grandi dimensioni, possono essere necessari alcuni minuti per rigenerare l'indice dei pacchetti Apt in modo da riflettere le eliminazioni.