このページでは、Yum リポジトリでの RPM パッケージの追加、表示、削除について説明します。Artifact Registry Yum リポジトリは、Yum と DNF をサポートしています。
始める前に
- ターゲット Yum リポジトリが存在しない場合は、新しいリポジトリを作成します。
- リポジトリにアクセスできるように VM を構成します。
- (省略可)gcloud コマンドのデフォルトを構成します。
- メタデータ内のパッケージ名が Fedora パッケージの命名ガイドラインと Fedora パッケージのバージョニング ガイドラインを満たしているようにしてください。
パッケージの追加
リポジトリ モード: 標準
パッケージを追加するリポジトリに対する読み取りと書き込み権限が必要です。
Google Cloud CLI を使用してパッケージをリポジトリにアップロードすることも、Cloud Storage に保存されているパッケージをインポートすることもできます。
Cloud Build を使用してパッケージをビルドする場合、このビルドは Cloud Storage にパッケージを保存してインポートできます。非常に長いインポートまたはアップロードのオペレーションの場合は、gcloud CLI が API の呼び出しに使用するトークンの有効期限が切れる場合があります。追加するパッケージが非常に多い場合は、小さいバッチ単位で追加し、各アップロードまたはインポート オペレーションをより短時間で完了することを検討してください。 詳細については、OS パッケージのトラブルシューティングのドキュメントをご覧ください。
直接アップロード
gcloud artifacts yum upload
コマンドを使用して、パッケージを Yum リポジトリにアップロードするには:
gcloud artifacts yum upload REPOSITORY \
--location=LOCATION \
--source=PACKAGES
次の値を置き換えます。
REPOSITORY
は Artifact Registry のリポジトリ名です。-
LOCATION
は、リポジトリのリージョンまたはマルチリージョンのロケーションです。 PACKAGES
はパッケージのパスです。
たとえば、パッケージ my-package.rpm
をロケーション us-west1
の Yum リポジトリ my-repo
にアップロードするには、次を実行します。
gcloud artifacts yum upload my-repo \ --location=us-west1 \ --source=my-package.rpm
Cloud Storage
- 次のいずれかの方法でパッケージを Cloud Storage にアップロードします。
- パッケージを Cloud Storage バケットに直接アップロードする
- Cloud Build でパッケージをビルドし、バケットに保存する
- 次のコマンドを実行します。
gcloud artifacts yum import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
次の値を置き換えます。
REPOSITORY
は Artifact Registry のリポジトリ名です。-
LOCATION
は、リポジトリのリージョンまたはマルチリージョンのロケーションです。 PACKAGES
は、Cloud Storage 内のパッケージのカンマ区切りのリストです。ディレクトリからすべてのパッケージをアップロードするには、ディレクトリ ワイルドカード(*
)を使用するか、再帰ディレクトリ ワイルドカード(**
)を使用してすべてのサブディレクトリですべてのパッケージをアップロードします。
たとえば、次のコマンドは、パッケージ
package.rpm
とdirectory
ディレクトリ内のすべてのパッケージを、バケットmy-bucket
からロケーションus-west1
の Yum リポジトリmy-repo
にアップロードします。gcloud artifacts yum import my-repo \ --location=us-west1 \ --gcs-source=gs://my-bucket/path/to/package.rpm,gs://my-bucket/directory*
アップロードまたはインポートのオペレーションが完了したら、Google Cloud コンソールまたは gcloud CLI を使用して、リポジトリ内のパッケージを表示して、それらが正常にアップロードされたことを確認できます。
多数のパッケージを含む大規模なリポジトリの場合、パッケージ インデックスが再生成され、新しいパッケージが Yum クライアントに表示されるまでに数分かかることがあります。
パッケージの表示
リポジトリ モード: 標準、リモート(プレビュー)
パッケージを表示するには、Artifact Registry 読み取りロールの権限が必要です。Artifact Registry はパッケージ内のファイルを一覧表示しません。
Google Cloud コンソールまたは gcloud
を使用してパッケージとパッケージのバージョンを表示するには:
コンソール
Google Cloud Console で [リポジトリ] ページを開きます。
リポジトリ リストで、適切なリポジトリをクリックします。
[パッケージ] ページに、リポジトリ内のパッケージが一覧表示されます。
パッケージをクリックして、そのパッケージのバージョンを表示します。
gcloud
リポジトリ内のパッケージを一覧表示するには、次のコマンドを実行します。
gcloud artifacts packages list [--repository=REPOSITORY] [--location=LOCATION]
以下を置き換えます。
REPOSITORY
はリポジトリの名前です。デフォルト リポジトリを構成した場合は、このフラグを省略してデフォルトを使用できます。-
LOCATION
は、リポジトリのリージョンまたはマルチリージョンのロケーションです。 デフォルト ロケーションを構成している場合は、このフラグを省略してデフォルトを使用できます。
パッケージのバージョンを表示するには、次のコマンドを実行します。
gcloud artifacts versions list --package=PACKAGE \
[--repository=REPOSITORY] [--location=LOCATION]
以下を置き換えます。
パッケージのインストール
リポジトリ モード: 標準、リモート(プレビュー)
パッケージをインストールする前に、Artifact Registry リポジトリからパッケージをインストールするように VM が構成されていることを確認します。
パッケージをインストールするには、次のコマンドを実行します。
sudo yum --enablerepo=REPOSITORY install PACKAGE
次の値を置き換えます。
PACKAGE
はパッケージ名ですREPOSITORY
は、.repo
ファイルで構成されているリポジトリの名前です。
たとえば、リポジトリ my-repo
からパッケージ my-package
をインストールするには、次のコマンドを実行します。
sudo yum --enablerepo=my-repo install my-package
パッケージの削除
リポジトリ モード: 標準
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 Google Cloud 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:
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
Open the Repositories page in the Google Cloud 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:
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.
大規模なリポジトリの場合、削除が反映されるように Yum パッケージ インデックスを再生成するには数分かかることがあります。