Questa pagina descrive come aggiungere, visualizzare ed eliminare i 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 i valori predefiniti per i comandi gcloud.
- Assicurati che i nomi dei pacchetti nei metadati soddisfino gli standard per i nomi dei pacchetti Debian.
Aggiunta di pacchetti
Modalità del repository: standard
Per aggiungere pacchetti al repository, devi disporre delle autorizzazioni di lettura e scrittura.
Puoi caricare un pacchetto in un repository utilizzando l'interfaccia a riga di comando Google Cloud o puoi importarne uno archiviato in Cloud Storage. Se crei pacchetti utilizzando Cloud Build, la compilazione può archiviarli in Cloud Storage per consentirti di importarli.
Le operazioni di importazione o caricamento molto lunghe potrebbero superare il periodo di scadenza del token utilizzato dall'interfaccia a riga di comando gcloud per chiamare l'API. Se hai un numero molto elevato di pacchetti da aggiungere, valuta la possibilità di aggiungerli in batch più piccoli in modo che ogni operazione di caricamento o importazione possa essere completata in un 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 Artifact Registry.-
LOCATION
è la posizione regionale o multiregionale del repository. PACKAGES
è il percorso del pacchetto.
Ad esempio, per caricare il pacchetto my-package.deb
nel repository Aptmy-repo
nella posizione us-west1
, esegui:
gcloud artifacts apt upload my-repo \ --location=us-west1 \ --source=my-package.deb
Cloud Storage
- Carica i pacchetti su Cloud Storage nel seguente modo:
- Carica i pacchetti direttamente in un bucket Cloud Storage
- Crea i 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 Artifact Registry.-
LOCATION
è la posizione regionale o multiregionale del repository. PACKAGES
è un elenco separato da virgole di pacchetti in Cloud Storage. Per caricare tutti i pacchetti da una directory, utilizza un carattere jolly per le directory (*
) o un carattere jolly per le directory ricorsive (**
) per caricare tutti i pacchetti in tutte le sottodirectory.
Ad esempio, per caricare il pacchetto
package.deb
e tutti i pacchetti nella directorydirectory
dal bucketmy-bucket
al repository Aptmy-repo
nella posizioneus-west1
, esegui:gcloud artifacts apt import my-repo \ --location=us-west1 \ --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory*
Al termine dell'operazione di caricamento o importazione, puoi utilizzare laGoogle Cloud console o 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 in modo che i nuovi pacchetti siano visibili al client Apt.
Visualizzazione dei pacchetti
Modalità del repository: standard, remoto (anteprima)Per visualizzare i pacchetti, devi disporre delle autorizzazioni nel ruolo di lettore di Artifact Registry. Artifact Registry non elenca i file all'interno dei 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]
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.
Installazione dei pacchetti
Modalità del repository: standard, remoto (anteprima)Prima di installare i pacchetti, verifica di aver configurato correttamente il gestore dei pacchetti e il repository.
Per installare un pacchetto nel repository:
Aggiorna l'elenco dei pacchetti disponibili:
sudo apt update
Installa 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 dei pacchetti
Modalità del 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]
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.
Per i repository di grandi dimensioni, la rigenerazione dell'indice del pacchetto Apt per riflettere le eliminazioni può richiedere alcuni minuti.