Mengelola paket Debian

Repositori Apt di Artifact Registry memungkinkan Anda mengelola paket Debian secara terpusat dan mempertahankan dependensi software yang konsisten di seluruh workload Linux Anda. Anda dapat menambahkan, melihat, dan menghapus paket, atau menginstalnya di VM yang dikonfigurasi.

Sebelum memulai

  1. Jika repositori Apt target tidak ada, buat repositori baru.
  2. Konfigurasikan VM untuk mengakses repositori.
  3. (Opsional) Konfigurasikan default untuk perintah gcloud.
  4. Pastikan nama paket Anda dalam metadata memenuhi standar nama paket Debian.

Menambahkan paket

Mode repositori: standar

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

Anda dapat mengupload paket ke repositori menggunakan Google Cloud CLI, atau Anda dapat mengimpor paket yang disimpan di Cloud Storage. Jika Anda membangun paket menggunakan Cloud Build, build dapat menyimpan paket di Cloud Storage untuk Anda impor.

Operasi impor atau upload yang sangat lama mungkin melebihi masa berlaku token yang digunakan gcloud CLI untuk memanggil API. Jika Anda memiliki paket dalam jumlah yang sangat besar untuk ditambahkan, pertimbangkan untuk menambahkannya dalam batch yang lebih kecil agar 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 perintah gcloud artifacts apt upload untuk mengupload paket ke repositori Apt:

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

Ganti nilai berikut:

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

Misalnya, untuk mengupload paket my-package.deb ke repositori Apt my-repo di lokasi us-west1, jalankan:

gcloud artifacts apt upload my-repo \
    --location=us-west1 \
    --source=my-package.deb

Cloud Storage

  1. Upload paket ke Cloud Storage dengan melakukan hal berikut:
    • Upload paket langsung ke bucket Cloud Storage
    • Membangun paket dengan Cloud Build dan menyimpan paket dalam bucket
  2. Jalankan perintah berikut:
    gcloud artifacts apt import REPOSITORY \
      --location=LOCATION \
      --gcs-source=PACKAGES
    

    Ganti nilai berikut:

    • REPOSITORY adalah nama repositori Artifact Registry.
    • LOCATION adalah lokasi regional atau multi-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, untuk mengupload paket package.deb dan semua paket di direktori directory dari bucket my-bucket ke repositori Apt my-repo di lokasi us-west1, jalankan:

    gcloud artifacts apt import my-repo \
      --location=us-west1 \
      --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory*
    

Setelah operasi upload atau impor selesai, Anda dapat menggunakan konsolGoogle Cloud atau gcloud CLI untuk melihat paket di repositori dan mengonfirmasi bahwa paket tersebut 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 Apt.

Melihat paket

Repository modes: standard, remote (preview)

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

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

Console

  1. Open the Repositories page in the Google Cloud 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 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.

Menginstal paket

Repository modes: standard, remote (preview)

Sebelum menginstal paket, pastikan Anda telah mengonfigurasi pengelola paket dan repositori dengan benar.

Untuk menginstal paket di repositori:

  1. Perbarui daftar paket yang tersedia:

    sudo apt update
    
  2. Instal paket, dengan menentukan nama repositori yang dikonfigurasi di Apt.

    sudo apt install PACKAGE/REPOSITORY
    

    Ganti nilai berikut:

    • PACKAGE adalah nama paket.
    • REPOSITORY adalah nama repositori Artifact Registry. Untuk repositori jarak jauh, gunakan nama repositori upstream standar.

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

    sudo apt install my-package -t my-repo
    

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

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

Untuk repositori besar, mungkin perlu waktu beberapa menit untuk membuat ulang indeks paket Apt agar mencerminkan penghapusan.

Langkah berikutnya