Halaman ini menjelaskan cara menambahkan, melihat, dan menghapus paket Debian di repositori Apt.
Sebelum memulai
- Jika repositori Apt target tidak ada, buat repositori baru.
- Konfigurasi VM untuk mengakses repositori.
- (Opsional) Konfigurasi default untuk perintah gcloud.
- 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:
REPOSITORYadalah nama repositori Artifact Registry.-
LOCATIONadalah lokasi regional repositori. PACKAGESadalah 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
- Upload paket ke Cloud Storage dengan melakukan hal berikut:
- Mengupload paket langsung ke bucket Cloud Storage
- Jalankan perintah berikut:
gcloud artifacts apt import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
Ganti nilai berikut:
REPOSITORYadalah nama repositori Artifact Registry.-
LOCATIONadalah lokasi regional repositori. PACKAGESadalah 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.debdan semua paket di direktoridirectorydari bucketmy-bucketke repositori Aptmy-repodi lokasiu-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: standarUntuk 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
Open the Repositories page in the Cloud de Confiance console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
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:
REPOSITORYis the name of the repository. If you configured a default repository, you can omit this flag to use the default.-
LOCATIONis 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:
PACKAGEis the ID of the package or fully qualified identifier for the package.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis 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: standarSebelum menginstal paket, pastikan Anda telah mengonfigurasi pengelola paket dan repositori dengan benar.
Untuk menginstal paket di repositori:
Perbarui daftar paket yang tersedia:
sudo apt updateInstal paket, dengan menentukan nama repositori yang dikonfigurasi di Apt.
sudo apt install PACKAGE/REPOSITORYGanti nilai berikut:
PACKAGEadalah nama paket.REPOSITORYadalah nama repositori Artifact Registry.
Misalnya, untuk menginstal paket
my-packagedari repositorimy-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
Open the Repositories page in the Cloud de Confiance console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Select the package that you want to delete.
Click DELETE.
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:
PACKAGEis the name of the package in the repository.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis 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
Open the Repositories page in the Cloud de Confiance console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Click a package to view versions of that package.
Select versions that you want to delete.
Click DELETE.
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:
VERSIONis the name of the version to delete.PACKAGEis the name of the package in the repository.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis 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.