Mengelola paket RPM

Halaman ini menjelaskan cara menambahkan, melihat, dan menghapus paket RPM di repositori Yum. Repositori Yum Artifact Registry mendukung Yum dan DNF.

Sebelum memulai

  1. Jika repositori Yum target tidak ada, buat repositori baru.
  2. Konfigurasi VM untuk mengakses repositori.
  3. (Opsional) Konfigurasi default untuk perintah gcloud.
  4. Pastikan nama paket Anda dalam metadata memenuhi panduan penamaan paket Fedora dan panduan pembuatan versi paket Fedora.

Menambahkan paket

Mode repositori: standar

Anda harus memiliki izin baca dan tulis untuk repositori agar dapat menambahkan paket.

Anda dapat mengupload paket ke repositori menggunakan Google Cloud CLI, atau Anda dapat mengimpor paket yang disimpan di Cloud Storage.

Operasi impor atau upload yang sangat panjang mungkin melebihi periode masa berlaku untuk token yang digunakan gcloud CLI untuk memanggil API. Jika Anda memiliki paket yang sangat banyak untuk ditambahkan, sebaiknya tambahkan paket dalam batch yang lebih kecil sehingga setiap operasi upload atau impor dapat diselesaikan dalam waktu yang lebih singkat. Lihat dokumentasi pemecahan masalah paket OS untuk mengetahui informasi selengkapnya.

Upload langsung

Gunakan gcloud artifacts yum upload perintah untuk mengupload paket ke repositori Yum:

gcloud artifacts yum upload REPOSITORY \
    --location=LOCATION \
    --source=PACKAGES

Ganti nilai berikut:

  • REPOSITORY adalah nama repositori Artifact Registry.
  • LOCATION adalah lokasi regional repositori.
  • PACKAGES adalah jalur ke paket.

Misalnya, untuk mengupload paket my-package.rpm ke repositori Yum my-repo di lokasi u-france-east1, jalankan:

gcloud artifacts yum upload my-repo \
    --location=u-france-east1 \
    --source=my-package.rpm

Cloud Storage

  1. Unggah paket langsung ke bucket Cloud Storage.
  2. Jalankan perintah berikut:
    gcloud artifacts yum import REPOSITORY \
      --location=LOCATION \
      --gcs-source=PACKAGES
    

    Ganti nilai berikut:

    • REPOSITORY adalah nama repositori Artifact Registry.
    • LOCATION adalah lokasi regional repositori.
    • PACKAGES adalah daftar paket yang dipisahkan koma di Cloud Storage. Untuk mengupload semua paket dari direktori, gunakan karakter pengganti direktori (*) atau gunakan karakter pengganti direktori rekursif (**) untuk mengupload semua paket di semua subdirektori.

    Misalnya, perintah berikut mengupload paket package.rpm dan semua paket di direktori directory dari bucket my-bucket ke repositori Yum my-repo di lokasi u-france-east1:

    gcloud artifacts yum import my-repo \
      --location=u-france-east1 \
      --gcs-source=gs://my-bucket/path/to/package.rpm,gs://my-bucket/directory*
    

Setelah operasi upload atau impor selesai, Anda dapat menggunakan Cloud de Confiance konsol atau gcloud CLI untuk melihat paket di repositori dan mengonfirmasi bahwa paket berhasil diupload.

Jika Anda memiliki repositori besar dengan banyak paket, mungkin perlu waktu beberapa menit untuk membuat ulang indeks paket sehingga paket baru dapat dilihat oleh klien Yum.

Melihat paket

Mode repositori: standar

Untuk melihat paket, Anda harus memiliki izin dalam peran Pembaca Artifact Registry. Artifact Registry tidak mencantumkan file di dalam paket.

To view packages and package versions using the Cloud de Confiance console or gcloud:

Console

  1. Open the Repositories page in the Cloud de Confiance console.

    Buka halaman Repositori

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

Menginstal paket

Mode repositori: standar

Sebelum menginstal paket, pastikan Anda telah mengonfigurasi VM untuk menginstal paket dari repositori Artifact Registry.

Untuk menginstal paket, jalankan perintah berikut:

sudo yum --enablerepo=REPOSITORY install PACKAGE

Ganti nilai berikut:

  • PACKAGE adalah nama paket
  • REPOSITORY adalah nama repositori yang dikonfigurasi dalam file .repo.

Misalnya, untuk menginstal paket my-package dari repositori my-repo, jalankan perintah:

sudo yum --enablerepo=my-repo install my-package

Menghapus paket

Mode repositori: standar

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 Cloud de Confiance console.

    Buka halaman Repositori

  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 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 Cloud de Confiance console.

    Buka halaman Repositori

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

Untuk repositori besar, mungkin perlu waktu beberapa menit untuk membuat ulang indeks paket Yum agar penghapusan dapat ditampilkan.

Langkah berikutnya