Debian-Pakete verwalten

Auf dieser Seite wird beschrieben, wie Sie Debian-Pakete in Apt-Repositories hinzufügen, aufrufen und löschen.

Hinweise

  1. Wenn das Ziel-Apt-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. Die Paketnamen in den Metadaten müssen den Debian-Standards für Paketnamen 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 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

  1. So laden Sie die Pakete in Cloud Storage hoch:
  2. 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 Verzeichnis directory aus dem Bucket my-bucket in das Apt-Repository my-repo am Speicherort us-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

  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 den Paketmanager und das Repository richtig konfiguriert haben.

So installieren Sie ein Paket im Repository:

  1. Aktualisieren Sie die Liste der verfügbaren Pakete:

    sudo apt update
    
  2. 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 Repository my-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

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

Nächste Schritte