RPM-Pakete verwalten

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

  1. Wenn das Ziel-Yum-Repository nicht vorhanden ist, erstellen Sie ein neues Repository.
  2. Konfigurieren Sie VMs für den Zugriff auf das Repository.
  3. (Optional) Konfigurieren Sie die Standardeinstellungen für gcloud-Befehle.
  4. 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 benötigen sowohl Lese- als auch Schreibberechtigungen für das Repository, um Pakete hinzuzufügen.

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:

  • 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.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

  1. Sie haben folgende Möglichkeiten, die Pakete in Cloud Storage hochzuladen:
  2. Führen Sie dazu diesen Befehl aus:
    gcloud artifacts yum 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.

    Mit dem folgenden Befehl werden beispielsweise das Paket package.rpm und alle Pakete im Verzeichnis directory aus dem Bucket my-bucket in das Yum-Repository my-repo am Speicherort us-west1 hochgeladen:

    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

  1. Open the Repositories page in the Google Cloud console.

    Zur Seite „Repositories“

  2. In the repository list, click the appropriate repository.

    The Packages page lists the packages in the repository.

  3. 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 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:

  • PACKAGE ist der Paketname.
  • REPOSITORY ist der Name des in der Datei .repo konfigurierten 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

  1. Open the Repositories page in the Google Cloud console.

    Zur Seite „Repositories“

  2. In the repository list, click the appropriate repository.

    The Packages page lists the packages in the repository.

  3. Select the package that you want to delete.

  4. Click DELETE.

  5. 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

  1. Open the Repositories page in the Google Cloud console.

    Zur Seite „Repositories“

  2. In the repository list, click the appropriate repository.

    The Packages page lists the packages in the repository.

  3. Click a package to view versions of that package.

  4. Select versions that you want to delete.

  5. Click DELETE.

  6. 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 Yum-Paketindex neu generiert wird, um die Löschungen widerzuspiegeln.

Nächste Schritte