Mengelola paket Debian

Halaman ini menjelaskan cara menambahkan, melihat, dan menghapus paket Debian di repositori Apt.

Sebelum memulai

  1. Jika repositori Apt 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 standar nama paket Debian.

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 mengimpor paket yang disimpan di Cloud Storage. Jika Anda membuat paket menggunakan Cloud Build, build dapat menyimpan paket di Cloud Storage agar Anda dapat mengimpornya.

Operasi impor atau upload yang sangat panjang mungkin melebihi masa berlaku token yang digunakan gcloud CLI untuk memanggil API. Jika Anda memiliki banyak paket yang akan ditambahkan, pertimbangkan untuk menambahkannya 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 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 repositori.
  • PACKAGES adalah jalur ke paket.

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

gcloud artifacts apt upload my-repo \
    --location=u-france-east1 \
    --source=my-package.deb

Cloud Storage

  1. Upload paket ke Cloud Storage dengan melakukan hal berikut:
    • Mengupload paket langsung ke bucket Cloud Storage
  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 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 u-france-east1, jalankan:

    gcloud artifacts apt import my-repo \
      --location=u-france-east1 \
      --gcs-source=gs://my-bucket/path/to/package.deb,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 Apt.

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

    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 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 Apt agar penghapusan dapat ditampilkan.

Langkah berikutnya