Auf dieser Seite wird beschrieben, wie Sie RPM-Pakete in Yum-Repositories hinzufügen, aufrufen und löschen. Yum-Repositories in Artifact Registry unterstützen Yum und DNF.
Hinweise
- Wenn das Ziel-Yum-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.
- Achten Sie darauf, dass die Paketnamen in den Metadaten den Richtlinien für die Benennung von Fedora-Paketen und den Richtlinien für die Versionierung von Fedora-Paketen 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 Rahmen des Builds 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 yum upload, um ein Paket in ein Yum-Repository hochzuladen:
gcloud artifacts yum upload REPOSITORY \
--location=LOCATION \
--source=PACKAGES
Ersetzen Sie die folgenden Werte:
REPOSITORYist der Name des Artifact Registry-Repositorys.-
LOCATIONist der regionale oder multiregionale Speicherort des Repositorys. PACKAGESist der Pfad zum Paket.
Wenn Sie beispielsweise das Paket my-package.rpm in das Yum-Repository my-repo am Speicherort us-west1 hochladen möchten, führen Sie Folgendes aus:
gcloud artifacts yum upload my-repo \
--location=us-west1 \
--source=my-package.rpm
Cloud Storage
- Sie haben folgende Möglichkeiten, die Pakete in Cloud Storage hochzuladen:
- 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 yum import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
Ersetzen Sie die folgenden Werte:
REPOSITORYist der Name des Artifact Registry-Repositorys.-
LOCATIONist der regionale oder multiregionale Speicherort des Repositorys. PACKAGESist 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.
Mit dem folgenden Befehl werden beispielsweise das Paket
package.rpmund alle Pakete im Verzeichnisdirectoryaus dem Bucketmy-bucketin das Yum-Repositorymy-repoam Speicherortus-west1hochgeladen:gcloud artifacts yum import my-repo \ --location=us-west1 \ --gcs-source=gs://my-bucket/path/to/package.rpm,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 Yum-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:
REPOSITORYis the name of the repository. If you configured a default repository, you can omit this flag to use the default.-
LOCATIONis 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:
PACKAGEis the ID of the package or fully qualified identifier for the package.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis 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 die VM konfiguriert haben, um Pakete aus Ihrem Artifact Registry-Repository zu installieren.
Führen Sie den folgenden Befehl aus, um ein Paket zu installieren:
sudo yum --enablerepo=REPOSITORY install PACKAGE
Ersetzen Sie die folgenden Werte:
PACKAGEist der Paketname.REPOSITORYist der Name des in der Datei.repokonfigurierten Repositorys.
Wenn Sie beispielsweise das Paket my-package aus dem Repository my-repo installieren möchten, führen Sie den Befehl aus:
sudo yum --enablerepo=my-repo install my-package
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:
PACKAGEis the name of the package in the repository.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis 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:
VERSIONis the name of the version to delete.PACKAGEis the name of the package in the repository.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis 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 Yum-Paketindex neu generiert wird, um die Löschungen widerzuspiegeln.
Nächste Schritte
- Weitere Informationen zum Verwalten von Debian-Paketen
- Einzelne Dateien in einem Paket herunterladen