Esta página descreve como adicionar, ver e eliminar pacotes Debian em repositórios Apt.
Antes de começar
- Se o repositório Apt de destino não existir, crie um novo repositório.
- Configure as VMs para aceder ao repositório.
- (Opcional) Configure as predefinições para os comandos gcloud.
- Certifique-se de que os nomes dos pacotes nos metadados cumprem as normas de nomenclatura de pacotes Debian.
Adicionar pacotes
Modos de repositório: padrão
Tem de ter autorizações de leitura e escrita para o repositório para adicionar pacotes.
Pode carregar um pacote para um repositório através da Google Cloud CLI ou importar um pacote armazenado no Cloud Storage. Se criar pacotes com o Cloud Build, a compilação pode armazenar os pacotes no Cloud Storage para que os possa importar.
As operações de importação ou carregamento muito longas podem exceder o período de validade do token que a CLI gcloud usa para chamar a API. Se tiver um número muito grande de pacotes para adicionar, considere adicioná-los em lotes mais pequenos para que cada operação de carregamento ou importação possa ser concluída num período mais curto. Consulte a documentação sobre a resolução de problemas de pacotes do SO para mais informações.
Carregamento direto
Use o comando
gcloud artifacts apt upload
para carregar um pacote para um repositório Apt:
gcloud artifacts apt upload REPOSITORY \
--location=LOCATION \
--source=PACKAGES
Substitua os seguintes valores:
REPOSITORYé o nome do repositório do Artifact Registry.-
LOCATIONé a localização regional do repositório. PACKAGESé o caminho para o pacote.
Por exemplo, para carregar o pacote my-package.deb para o repositório Apt
my-repo na localização u-france-east1, execute:
gcloud artifacts apt upload my-repo \
--location=u-france-east1 \
--source=my-package.deb
Cloud Storage
- Carregue os pacotes para o Cloud Storage da seguinte forma:
- Carregue pacotes diretamente para um contentor do Cloud Storage
- Execute o seguinte comando:
gcloud artifacts apt import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
Substitua os seguintes valores:
REPOSITORYé o nome do repositório do Artifact Registry.-
LOCATIONé a localização regional do repositório. PACKAGESé uma lista de pacotes separados por vírgulas no Cloud Storage. Para carregar todos os pacotes de um diretório, use um caráter universal de diretório (*) ou um caráter universal de diretório recursivo (**) para carregar todos os pacotes em todos os subdiretórios.
Por exemplo, para carregar o pacote
package.debe todos os pacotes no diretóriodirectorydo contentormy-bucketpara o repositório Aptmy-repona localizaçãou-france-east1, execute:gcloud artifacts apt import my-repo \ --location=u-france-east1 \ --gcs-source=gs://my-bucket/path/to/package.deb,gs://my-bucket/directory*
Quando a operação de carregamento ou importação estiver concluída, pode usar a Cloud de Confiance consola ou a CLI gcloud para ver pacotes no repositório e confirmar que foram carregados com êxito.
Se tiver um repositório grande com muitos pacotes, pode demorar vários minutos a regenerar o índice de pacotes para que os novos pacotes fiquem visíveis para o cliente Apt.
Visualizar pacotes
Modos de repositório: padrãoPara ver pacotes, tem de ter as autorizações na função de leitor do Artifact Registry. O Artifact Registry não lista ficheiros dentro de pacotes.
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.
Instalar pacotes
Modos de repositório: padrãoAntes de instalar pacotes, verifique se configurou o gestor de pacotes e o repositório corretamente.
Para instalar um pacote no repositório:
Atualize a lista de pacotes disponíveis:
sudo apt updateInstale o pacote, especificando o nome do repositório configurado no Apt.
sudo apt install PACKAGE/REPOSITORYSubstitua os seguintes valores:
PACKAGEé o nome do pacote.REPOSITORYé o nome do repositório do Artifact Registry.
Por exemplo, para instalar o pacote
my-packagea partir do repositóriomy-repo, execute o comando:sudo apt install my-package -t my-repo
Eliminar pacotes
Modos de repositório: padrão
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.
Para repositórios grandes, a regeneração do índice do pacote Apt pode demorar alguns minutos para refletir as eliminações.