This page describes adding, viewing, and deleting Debian packages in Apt repositories.
Before you begin
- If the target Apt repository doesn't exist, create a new repository .
- Configure VMs to access the repository.
- (Optional) Configure defaults for gcloud commands .
- Ensure your package names in metadata meet the Debian package name standards .
Adding packages
Repository modes :standard
You must have both read and write permissions for the repository to add packages.
You can upload a package to a repository using the Google Cloud CLI, or you can import a package that is stored in Cloud Storage. If you build packages using Cloud Build, the build can store the packages in Cloud Storage for you to import.
Very long import or upload operations might exceed the expiry period for the token that gcloud CLI uses to call the API. If you have a very large number of packages to add, consider adding them in smaller batches so that each upload or import operation can complete in a shorter amount of time. See OS packages troubleshooting documentation for more information.
Direct upload
Use the  gcloud artifacts apt upload 
command 
to upload a package to an Apt repository:
 gcloud  
artifacts  
apt  
upload  
 REPOSITORY 
  
 \ 
  
--location = 
 LOCATION 
  
 \ 
  
--source = 
 PACKAGES 
 
 
Replace the following values:
-   REPOSITORYis the Artifact Registry repository name.
-   LOCATIONis the regional or multi-regional location of the repository.
-   PACKAGESis the path to the package.
For example, to upload the package my-package.deb 
to the Apt repository my-repo 
in the location us-west1 
, run:
gcloud artifacts apt upload my-repo \
    --location=us-west1 \
    --source=my-package.deb 
Cloud Storage
- Upload the packages to Cloud Storage by doing the following: - Upload packages directly to a Cloud Storage bucket
- Build packages with Cloud Build and store the packages in a bucket
 
- Run the following command: gcloud artifacts apt import REPOSITORY \ --location= LOCATION \ --gcs-source= PACKAGES Replace the following values: -   REPOSITORYis the Artifact Registry repository name.
-   LOCATIONis the regional or multi-regional location of the repository.
-   PACKAGESis a comma separated list of packages in Cloud Storage. To upload all packages from a directory, use a directory wildcard (*) or use a recursive directory wildcard (**) to upload all packages in all subdirectories.
 For example, to upload a the package package.deband all packages in thedirectorydirectory from the bucketmy-bucketto the Apt repositorymy-repoin the locationus-west1, run:gcloud artifacts apt import my-repo \ --location=us-west1 \ --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory* 
-   
When the upload or import operation is complete, you can use the Google Cloud console or gcloud CLI to view packages in the repository and confirm that they were uploaded successfully.
If you have a large repository with a lot of packages, it might take several minutes to regenerate the package index so that the new packages are visible to the Apt client.
Viewing packages
Repository modes :standard, remote (preview)To view packages, you must have the permissions in the Artifact Registry Reader role . Artifact Registry does not list files inside packages.
To view packages and package versions using the Google Cloud console
or gcloud 
:
Console
-  Open the Repositoriespage in the Google Cloud console. 
-  In the repository list, click the appropriate repository. The Packagespage 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 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:
-   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 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.
Installing packages
Repository modes :standard, remote (preview)Before you install packages, verify that you have configured the package manager and repository correctly.
To install a package in the repository:
-  Update the list of available packages: sudo apt update
-  Install the package, specifying the name of the repository configured in Apt. sudo apt install PACKAGE / REPOSITORYReplace the following values: -   PACKAGEis the package name.
-   REPOSITORYis the name of the Artifact Registry repository. For remote repositories, use the name of the standard upstream repository.
 For example, to install the package my-packagefrom the repositorymy-repo, run the command:sudo apt install my-package -t my-repo 
-   
Deleting packages
Repository modes :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
-  Open the Repositoriespage in the Google Cloud console. 
-  In the repository list, click the appropriate repository. The Packagespage 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 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
-  Open the Repositoriespage in the Google Cloud console. 
-  In the repository list, click the appropriate repository. The Packagespage 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 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.
For large repositories, it can take a few minutes to regenerate the Apt package index to reflect deletions.

