Auf dieser Seite wird beschrieben, wie Sie Debian-Pakete in Apt-Repositories hinzufügen, aufrufen und löschen.
Hinweise
- Wenn das Ziel-Apt-Repository nicht vorhanden ist, erstellen Sie ein neues Repository.
- Konfigurieren Sie VMs für den Zugriff auf das Repository.
- (Optional) Konfigurieren Sie die Standardeinstellungen für gcloud-Befehle.
- Die Paketnamen in den Metadaten müssen den Debian-Standards für Paketnamen entsprechen.
Pakete hinzufügen
Repository-Modi:standard
Sie können ein Paket mit der Google Cloud CLI in ein Repository hochladen oder ein in Cloud Storage gespeichertes Paket importieren. Wenn Sie Pakete mit Cloud Build erstellen, können die Pakete im Build in Cloud Storage gespeichert werden, damit Sie sie importieren können.
Bei sehr langen Import- oder Uploadvorgängen kann die Gültigkeitsdauer des Tokens, das die gcloud CLI zum Aufrufen der API verwendet, überschritten werden. Wenn Sie eine sehr große Anzahl von Paketen hinzufügen möchten, sollten Sie sie in kleineren Gruppen hinzufügen, damit jeder Upload- oder Importvorgang in kürzerer Zeit abgeschlossen werden kann. Weitere Informationen finden Sie in der Dokumentation zur Fehlerbehebung bei Betriebssystempaketen.
Direkter Upload
Verwenden Sie den Befehl gcloud artifacts apt upload
, um ein Paket in ein Apt-Repository hochzuladen:
gcloud artifacts apt upload REPOSITORY \
--location=LOCATION \
--source=PACKAGES
Ersetzen Sie die folgenden Werte:
REPOSITORY
ist der Name des Artifact Registry-Repositorys.-
LOCATION
ist der regionale oder multiregionale Speicherort des Repositorys. PACKAGES
ist der Pfad zum Paket.
Wenn Sie beispielsweise das Paket my-package.deb
in das Apt-Repository my-repo
am Speicherort us-west1
hochladen möchten, führen Sie Folgendes aus:
gcloud artifacts apt upload my-repo \ --location=us-west1 \ --source=my-package.deb
Cloud Storage
- So laden Sie die Pakete in Cloud Storage hoch:
- Pakete direkt in einen Cloud Storage-Bucket hochladen
- Pakete mit Cloud Build erstellen und in einem Bucket speichern
- Führen Sie dazu diesen Befehl aus:
gcloud artifacts apt import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
Ersetzen Sie die folgenden Werte:
REPOSITORY
ist der Name des Artifact Registry-Repositorys.-
LOCATION
ist der regionale oder multiregionale Speicherort des Repositorys. PACKAGES
ist eine durch Kommas getrennte Liste von Paketen in Cloud Storage. Wenn Sie alle Pakete aus einem Verzeichnis hochladen möchten, verwenden Sie einen Verzeichnis-Platzhalter (*
) oder einen rekursiven Verzeichnis-Platzhalter (**
), um alle Pakete in allen Unterverzeichnissen hochzuladen.
Wenn Sie beispielsweise das Paket
package.deb
und alle Pakete im Verzeichnisdirectory
aus dem Bucketmy-bucket
in das Apt-Repositorymy-repo
am Speicherortus-west1
hochladen möchten, führen Sie Folgendes aus:gcloud artifacts apt import my-repo \ --location=us-west1 \ --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory*
Wenn der Upload oder Import abgeschlossen ist, können Sie über dieGoogle Cloud Console oder die gcloud CLI Pakete im Repository ansehen und prüfen, ob sie erfolgreich hochgeladen wurden.
Wenn Sie ein großes Repository mit vielen Paketen haben, kann es einige Minuten dauern, bis der Paketindex neu generiert wurde und die neuen Pakete für den Apt-Client sichtbar sind.
Pakete ansehen
Repository-Modi: standard, remote (Vorabversion)Um Pakete aufzurufen, benötigen Sie die Berechtigungen der Rolle „Artifact Registry Reader“. In Artifact Registry werden keine Dateien in Paketen aufgeführt.
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.
Pakete installieren
Repository-Modi: standard, remote (Vorabversion)Bevor Sie Pakete installieren, prüfen Sie, ob Sie den Paketmanager und das Repository richtig konfiguriert haben.
So installieren Sie ein Paket im Repository:
Aktualisieren Sie die Liste der verfügbaren Pakete:
sudo apt update
Installieren Sie das Paket und geben Sie dabei den Namen des in Apt konfigurierten Repositorys an.
sudo apt install PACKAGE/REPOSITORY
Ersetzen Sie die folgenden Werte:
PACKAGE
ist der Paketname.REPOSITORY
ist der Name des Artifact Registry-Repositorys. Verwenden Sie für Remote-Repositories den Namen des Standard-Upstream-Repositories.
Wenn Sie beispielsweise das Paket
my-package
aus dem Repositorymy-repo
installieren möchten, führen Sie den Befehl aus:sudo apt install my-package -t my-repo
Pakete löschen
Repository-Modi: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.
Bei großen Repositories kann es einige Minuten dauern, bis der Apt-Paketindex neu generiert wird, um die Löschungen widerzuspiegeln.