「Namcap」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(1版 をインポートしました)
1行目: 1行目:
 
[[Category:パッケージ管理]]
 
[[Category:パッケージ管理]]
[[Category:パッケージ開発]
+
[[Category:パッケージ開発]]
 
[[en:Namcap]]
 
[[en:Namcap]]
 
[[it:Namcap]]
 
[[it:Namcap]]

2015年1月9日 (金) 23:21時点における版

Namcap は、パッケージを作るときによくある間違いがバイナリパッケージやソース PKGBUILD に存在しないかチェックするツールです。自動的に有効にすることもできます。Namcap は Jason Chu によって開発されました。

変更点: git リポジトリの NEWS ファイルに前のバージョンからの変更点が簡単に説明されています。

開発ブランチ: https://projects.archlinux.org/?p=namcap.git;a=summary

namcap についてバグを報告したり機能リクエストをする場合は、Arch Linux のバグトラッカーPackages:Extra セクションにバグを作成して適当に重要度を設定してください。バグを報告するときは、問題が発生するパッケージの具体例とバージョン番号を忘れずに付け加えることをお願いします。

(バグを修正したり、新しい namcap モジュールの) パッチを作った場合、arch-projects メーリングリストに送ることができます。Namcap の開発は git によって行われているため、git フォーマットにそったパッチが好ましいとされます。

インストール

公式リポジトリから namcap パッケージをインストールしてください。

使用方法

PKGBUILD やバイナリの pkg.tar.xz で namcap を実行する:

$ namcap FILENAME

追加情報のメッセージを見たい場合は、-i フラグを付けて namcap を実行します:

$ namcap -i FILENAME

コマンドラインに man namcap と入力することで namcap(1) マニュアルを見ることができます。

出力の解釈

Namcap は出力を分類するためにタグシステムを使っています。現在、タグには エラー (error, E), ワーニング (warning, W), インフォメーション (informational, I) の3種類があります。エラーは問題が重大で、すぐに修正したほうがよいでしょう。ほとんどの場合、セキュリティの欠陥や、ライセンスが設定されてない、またはパーミッション関連の問題がエラーになります。

通常 namcap は人間が読める形で説明を出力します (場合によっては問題を修正するための方法の提案も付きます)。プログラムが簡単にパース出来るように出力させたい場合は、namcap に -m (machine-readable) フラグを渡して下さい (この機能は現在開発ブランチにあります)。

タグ

シンボリックリンク

  • symlink-found (informational) パッケージ内にシンボリックリンクが存在しています。
  • hardlink-found (informational) パッケージ内にハードリンクが存在しています。
  • dangling-symlink (error) パッケージ内に存在しないファイルのシンボリックリンクが存在しています。
  • dangling-hardlink (error) パッケージ内に存在しないファイルのハードリンクが存在しています。

依存関係

  • link-level-dependence (informational) パッケージが動的リンクしているライブラリについての情報。
  • dependency-is-testing-release (warning) 依存パッケージが [testing] リポジトリにあります。パッケージを公式の Arch Linux リポジトリ (core, extra, community) のためにビルドする場合、[testing] のパッケージを利用するビルドをしてはいけません。[core] や [extra] のパッケージの場合、[testing] を使ってビルドするパッケージは [testing] リポジトリに置くべきです。
  • dependency-covered-by-link-dependence (informational) 依存パッケージのリンクしている依存パッケージによって依存関係が満たされています。つまりこれは依存パッケージが余分だということです。
  • dependency-detected-not-included (error) ファイルが参照している先に depends 行に記載されていない依存パッケージが含まれています。optdepends 行に依存パッケージが載っている場合はこのエラーは無視して下さい。
  • dependency-already-satisfied (warning) 依存関係が既に満たされています (例えばあるパッケージの依存パッケージがすでに依存として記載されている)。つまり余分な依存パッケージです。pacman に含まれている pactree ツールを使うことでパッケージの依存関係ツリーを見ることができます。
  • dependency-not-needed (warning) 依存パッケージがプログラム内に存在するどのファイルからも (namcap が推論できる限りでは) 必要とされていません。ただしスクリプトのパッケージ (python や perl パッケージなど) の場合はこの警告は正しくない場合があり、各自で依存関係を調べて下さい。
  • depends-by-namcap-sight (informational) namcap による依存パッケージのリスト。

ライセンス

  • missing-license (error) パッケージにライセンスが明記されていません。PKGBUILD の license=() 行にライセンスを記述してください。詳しくは Arch Packaging Standards を見て下さい。ライセンスが含まれていないと著作権侵害になる場合が多いため、出来る限り早くこのエラーを解決するのが非常に重要です。
  • missing-custom-license-dir (error) ライセンスが custom となっているのにパッケージングガイドラインで指定されている /usr/share/licenses/ にライセンスディレクトリが存在しません。
  • missing-custom-license-file (error) ライセンスが custom となっているのにライセンスファイルが /usr/share/licenses/$pkgname に存在しません。
  • not-a-common-license (error) ライセンスが custom ではないのにかかわらず Arch Linux ディストリビューションにある licenses パッケージに標準的なライセンスとして含まれていません。

ファイル

このセクションでは、ファイルの不適切なパーミッションや、FHS ガイドラインに従ってインストールされてないファイルなどに関するタグを説明しています。

  • script-link-detected (informational) 示されているファイルはスクリプトです。
  • file-in-non-standard-dir (warning) ファイルが FHS ガイドライン によって定義されている標準ディレクトリ以外に存在します。認定されているディレクトリは: bin/, etc/, usr/bin/, usr/sbin/, usr/lib, usr/include/, usr/share/, opt/, lib/, sbin/, srv/, var/lib/, var/opt/, var/spool/, var/lock/, var/state/, var/run/, var/log/
  • elffile-not-in-allowed-dirs (error) ELF ファイルは以下のディレクトリに配置しなくてはなりません: /lib, /bin, /sbin, /usr/bin, /usr/sbin, /lib, /usr/lib, /opt/$pkgname/
  • empty-directory (warning) The following directory in the package is empty.
  • non-fhs-man-page (error) FHS ガイドライン によってマニュアルページのためのディレクトリとされている /usr/share/man 以外の場所にパッケージがマニュアルページをインストールしています。
  • potential-non-fhs-man-page (warning) This file seems to be a manual page which is not installed in /usr/share/man but namcap is not too sure about it.
  • non-fhs-info-page (error) FHS ガイドライン によってアーキテクチャと無関係なデータをインストールする場所とされている /usr/share/info 以外の場所にパッケージが info ページをインストールしています。
  • potential-non-fhs-info-page (warning) This file seems to be a info page which is not installed in /usr/share/info but namcap is not too sure about it.
  • incorrect-permissions (error) ファイルの所有者が不適切です。バイナリパッケージ内のファイルの所有者は root/root にしてください。
  • file-not-world-readable (warning) ファイルが誰にも読まれないようになっています。通常はこうなっていません。
  • file-world-writable (warning) 誰でもファイルに書き込みができるようになっています。同じく、典型から外れます。
  • directory-not-world-executable (warning) The directory does not have the world executable bit set. This disallows access to the directory for programs running under user privileges.
  • incorrect-library-permissions (warning) The library file does not have permission 644 (readable and writable by root, readable by anyone else).
  • libtool-file-present (warning) 通常は存在しないはずの libtool (.la) ファイルが存在します。PKGBUILD の options 行に !libtool オプションを追加することで自動的に削除できます。
  • perllocal-pod-present (error) perl パッケージに perllocal.pod ファイルが存在してはいけません。詳しくは Perl Package Guidelines を見て下さい。
  • scrollkeeper-dir-exists (error) scrollkeeper ディレクトリがパッケージに存在します。scrollkeeper は post_{install,upgrade,remove} まで実行してはいけません。
  • info-dir-file-present (error) info ディレクトリファイル /usr/share/info/dir がパッケージに存在します。このファイルが存在してはいけません。
  • gnome-mime-file (error) 自動生成された GNOME mime ファイルがパッケージ内に存在してはいけません。

その他

  • mime-cache-not-updated (error) パッケージが mime ファイルをインストールするのに更新するための update-mime-database を呼び出していません。
  • hicolor-icon-cache-not-updated (error) /usr/share/icons/hicolor にファイルが存在するのに hicolor アイコンキャッシュが更新されません。gtk-update-icon-cache (gtk に依存するパッケージ向け) か xdg-icon-resource を使ってアイコンキャッシュを更新するようにしてください。xdg-icon-resource を使う場合は依存パッケージに xdg-utils を記して下さい。
  • insecure-rpath (error) An RPATH (for an executable) is outside /usr/lib. An RPATH to an insecure location is a potential security issue. See FS#14049 for discussion.

PKGBUILD

PKGBUILD に関連するタグです。いくつかはバイナリパッケージにも適用されます。

  • variable-not-array (warning) The variable should be a bash array instead of a string. These are the variables which should be written as arrays: arch, license, depends, makedepends, optdepends, provides, conflicts, replaces, backup, source, noextract, md5sums
  • backups-preceding-slashes (error) backup 行に載っているファイルがスラッシュ ('/') で始まっています。
  • package-name-in-uppercase (error) パッケージの名前に大文字を含めてはいけません。
  • specific-host-type-used (warning) Instead of using a specific host type (like i686 or x86_64) use the generic $CARCH variable.
  • extra-var-begins-without-underscore (warning) The variable is not one of the standard variables defined in the PKGBUILD manual, yet it does not begin with an underscore.
  • file-referred-in-startdir (error) $startdir$startdir/pkg$startdir/src の外側にファイルが参照されています。
  • missing-md5sums (error) ソースファイルに対応する MD5sum が存在しません。updpkgsums を使って PKGBUILD にチェックサムを追加することができます。
  • not-enough-md5sums (error) MD5sum よりも多くのソースファイルが PKGBUILD に指定されています。
  • too-many-md5sums (error) ソースファイルよりも多くの MD5sum が PKGBUILD に記述されています。
  • improper-md5sum (error) 不正な MD5sum です。MD5sum は32字の文字列になります。
  • specific-sourceforge-mirror (warning) PKGBUILD が特定の sourceforge ミラーを使っています。代わりに http://downloads.sourceforge.net を使って下さい。
  • using-dl-sourceforge (warning) source 行で今はもう使われなくなった http://dl.sourceforge.net ドメインが使用されいます。代わりに http://downloads.sourceforge.net を使って下さい。
  • missing-contributor (warning) contributor タグが見つかりません。
  • missing-maintainer (warning) maintainer タグが見つかりません。
  • missing-url (error) パッケージに上流のホームページが設定されていません。url 変数を使って下さい。
  • pkgname-in-description (warning) Description should not contain the package name.
  • recommend-use-pkgdir (informational) $startdir/pkg は廃止されました、代わりに $pkgdir を使って下さい。
  • recommend-use-srcdir (informational) $startdir/src は廃止されました、代わりに $srcdir を使って下さい。

未リリース

現在、開発版に新規タグは存在しません。

namcap モジュールの作成

このセクションは namcap 内部の話であり新しい namcap モジュールの作り方を説明しています。

The main namcap program namcap.py takes as parameters the filename of a package or a PKGBUILD and makes a pkginfo object, which it passes to a list of rules defined in __tarball__ and __pkgbuild__.

  • __tarball__ defines the rules which process binary packages.
  • __pkgbuild__ defines the rules which process PKGBUILDs

Once your module is finalized, remember to add it to the appropriate array (__tarball__ or __pkgbuild__) defined in Namcap/__init__.py

namcap のサンプルモジュール:

namcap/url.py
  import pacman

  class package:
  	def short_name(self):
		return "url"
	def long_name(self):
		return "Verifies url is included in a PKGBUILD"
	def prereq(self):
		return ""
	def analyze(self, pkginfo, tar):
		ret = [[],[],[]]
		if not hasattr(pkginfo, 'url'):
			ret[0].append(("missing-url", ()))
		return ret
	def type(self):
		return "pkgbuild"

Mostly, the code is self-explanatory. The following are the list of the methods that each namcap module must have:

  • short_name(self) Returns a string containing a short name of the module. Usually, this is the same as the basename of the module file.
  • long_name(self) Returns a string containing a concise description of the module. This description is used when listing all the rules using namcap -r list.
  • prereq(self) Return a string containing the prerequisites needed for the module to operate properly. Usually "" for modules processing PKGBUILDs and "tar" for modules processing package files. "extract" should be specified if the package contents should be extracted to a temporary directory before further processing.
  • analyze(self, pkginfo, tar) Should return a list comprising in turn of three lists: of error tags, warning tags and information tags respectively. Each member of these tag lists should be a tuple consisting of two components: the short, hyphenated form of the tag with the appropriate format specifiers (%s, etc.) The first word of this string must be the tag name. The human readable form of the tag should be put in the tags file. The format of the tags file is described below; and the parameters which should replace the format specifier tokens in the final output.
  • type(self) "pkgbuild" for a module processing PKGBUILDs, "tarball" for a module processing a binary package file.

The tags file consists of lines specifying the human readable form of the hyphenated tags used in the namcap code. A line beginning with a '#' is treated as a comment. Otherwise the format of the file is:

 machine-parseable-tag %s :: This is machine parseable tag %s

Note that a double colon (::) is used to separate the hyphenated tag from the human readable description.

Namcap レポート

namcap-reports は core, extra, community ツリーに対して namcap を実行して自動的に生成されるレポートです。

仕組み:

  • namcap is run against the entire ABS tree to make namcap.log.
  • The packages in core, extra and community are put in files named core, extra and community respectively (using pacman -Slq).
  • namcap-report.py takes the code and prepares the report and RSS feeds, which is then copied to the webserver.