「Wine パッケージガイドライン」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(同期)
(Pkg/AUR テンプレートの更新)
(他の1人の利用者による、間の1版が非表示)
25行目: 25行目:
 
=== ポータビリティ ===
 
=== ポータビリティ ===
   
  +
ポータブルなプログラムであれば [[Wine]] でファイルシステムをエミュレートする必要はありません。パッケージングするプログラムにポータブル版が存在しないか [http://www.portablefreeware.com Portable Freeware] で確認してみてください。
A portable program does not need its own [[Wine]] emulated file system, so check in [http://www.portablefreeware.com Portable Freeware] if the program you are packaging is portable.
 
   
 
== ガイドライン ==
 
== ガイドライン ==
   
  +
Windows のプログラムをパッケージ化するということは、プログラムのファイルを JVM と Java のバイトコードと同じように、Wine が解釈するただのデータとして使うことです。
The idea behind packaging a Windows program is to use the program's files as mere data that Wine will interpret, just like JVM and Java bytecode.
 
   
  +
したがって、プログラムは {{ic|/usr/share/"$pkgname"}} にインストールし、プログラムは必要なものを全て {{ic|"$HOME"/."$pkgname"}} に書き込むようにします。{{ic|/usr/bin/"$pkgname"}} に保存したスクリプトを使って、フォルダを作成したり必要な準備を行って、それからプログラムを起動します。
So we will install the program in {{ic|/usr/share/"$pkgname"}} and the program will write all what it needs in {{ic|"$HOME"/."$pkgname"}}. Everything will be prepared by a small script saved in {{ic|/usr/bin/"$pkgname"}} that will create the folder, prepare it if needed, and finally start the program.
 
   
  +
次のセクションでは必要なステップについて説明します。
In the next sections we will talk about every step.
 
   
  +
この方法ではあれば個々のユーザーがそれぞれ設定を保持することができ、他のユーザーに干渉することがありません。
This way every user will have their own settings and their decisions will not bother other users.
 
   
 
=== インストール ===
 
=== インストール ===
   
  +
プログラムにインストーラが存在しない場合、インストールはファイルの解凍にすぎません。{{ic|"$pkgdir"/usr/share/$pkgname}} に展開して、パーミッションを適切に設定します。以下のコマンドでパーミッションを確認できます:
If the program has no installer, the installation is a mere decompression of a file; unpack it to {{ic|"$pkgdir"/usr/share/$pkgname}}, making sure that the permissions are correct. These commands will do:
 
 
$ find "$pkgdir"/usr/share -type f -exec chmod 644 "{}" \;
 
$ find "$pkgdir"/usr/share -type f -exec chmod 644 "{}" \;
 
$ find "$pkgdir"/usr/share -type d -exec chmod 755 "{}" \;
 
$ find "$pkgdir"/usr/share -type d -exec chmod 755 "{}" \;
  +
If the program cannot be installed the easy way, you need to create a Wine environment:
 
  +
プログラムを簡単にインストールできない場合、Wine 環境を作成する必要があります:
 
$ install -m755 -d "$srcdir"/tmp "$srcdir"/tmp/env "$srcdir"/tmp/local
 
$ install -m755 -d "$srcdir"/tmp "$srcdir"/tmp/env "$srcdir"/tmp/local
 
$ export WINEPREFIX="$srcdir"/tmp/env
 
$ export WINEPREFIX="$srcdir"/tmp/env
 
$ export XDG_DATA_HOME="$srcdir"/tmp/local
 
$ export XDG_DATA_HOME="$srcdir"/tmp/local
 
$ wine "$srcdir"/installer.exe /silentoptions
 
$ wine "$srcdir"/installer.exe /silentoptions
  +
 
We have not discussed portability yet, but if your program does not need the registry keys it modified, you can just copy the directory from the:
 
We have not discussed portability yet, but if your program does not need the registry keys it modified, you can just copy the directory from the:
 
"$srcdir"/tmp/env/drive_c/Program\ Files/programname
 
"$srcdir"/tmp/env/drive_c/Program\ Files/programname
  +
 
Otherwise you need to copy all the registry files too and eventually the files the program installed around. The {{ic|"$srcdir"/tmp/local}} will contains menu icons and desktop files, you may want to copy them in the package. If there does not exist a way to install the program silently... Maybe you can make a {{ic|.tar.gz}} file and upload it somewhere? If nothing automated is possible, force the user to follow the installer and hope he does not mess up the installation, write some checks before blindly copying a folder that may not exist (e.g., the user pressed 'Cancel'.)
 
Otherwise you need to copy all the registry files too and eventually the files the program installed around. The {{ic|"$srcdir"/tmp/local}} will contains menu icons and desktop files, you may want to copy them in the package. If there does not exist a way to install the program silently... Maybe you can make a {{ic|.tar.gz}} file and upload it somewhere? If nothing automated is possible, force the user to follow the installer and hope he does not mess up the installation, write some checks before blindly copying a folder that may not exist (e.g., the user pressed 'Cancel'.)
   
 
=== /usr/bin スクリプト ===
 
=== /usr/bin スクリプト ===
   
  +
スクリプトでは設定フォルダを用意してプログラムを起動します。プログラムがポータブルな場合、以下のようになります:
This script prepares the settings folder and starts the program. If your program is portable, it will look like this:
 
   
 
#!/bin/bash
 
#!/bin/bash
62行目: 65行目:
 
fi
 
fi
 
WINEDEBUG=-all wine "$HOME"/.programname/programname "$@"
 
WINEDEBUG=-all wine "$HOME"/.programname/programname "$@"
  +
 
If it is clean, it will look like this:
 
If it is clean, it will look like this:
 
#!/bin/bash
 
#!/bin/bash
93行目: 97行目:
 
=== UnionFsFuse ===
 
=== UnionFsFuse ===
   
[[公式リポジトリ]]の {{Pkg|unionfs-fuse}} で [http://podgorny.cz/moin/UnionFsFuse UnionFsFuse] プログラムを使うことができます。UnionFsFuse はベースディレクトリを {{ic|/usr/share}} に保持して、書き込みに必要なアプリケーションのファイルのコピーを {{ic|$HOME/.programname}} に自動的に配置します。
+
{{Pkg|unionfs-fuse}} パッケージで [http://podgorny.cz/moin/UnionFsFuse UnionFsFuse] プログラムを使うことができます。UnionFsFuse はベースディレクトリを {{ic|/usr/share}} に保持して、書き込みに必要なアプリケーションのファイルのコピーを {{ic|$HOME/.programname}} に自動的に配置します。
   
 
Using UnionFsFuse means an additional dependency and it requires the fuse module that not all users might load. Yet, it might be worthwhile if the application would need lots of symlinking or if it is unclear exactly what it needs to be written. Just ensure to mount and unmount the UnionFs correctly.
 
Using UnionFsFuse means an additional dependency and it requires the fuse module that not all users might load. Yet, it might be worthwhile if the application would need lots of symlinking or if it is unclear exactly what it needs to be written. Just ensure to mount and unmount the UnionFs correctly.
Among others, the {{AUR|GeneRally}}{{Broken package link|{{aur-mirror|generally}}}} package uses this approach.
 
   
 
== サンプル ==
 
== サンプル ==
160行目: 163行目:
 
== Gecko と Mono ==
 
== Gecko と Mono ==
   
Unless you know for sure, that software require browser of .NET runtime (packages {{Pkg|wine_gecko}} and {{Pkg|wine-mono}} in official repositories), default wine installation prompts for Gecko/Mono are undesirable.
+
Unless you know for sure, that software require browser of .NET runtime (packages {{Pkg|wine_gecko}}{{Broken package link|置換パッケージ: {{Pkg|wine-gecko}}}} and {{Pkg|wine-mono}} in official repositories), default wine installation prompts for Gecko/Mono are undesirable.
   
 
HTML レンダリング, バイトコードサポート, ダイアログを無効果するにはスクリプトで dlloverride を使う必要があります。
 
HTML レンダリング, バイトコードサポート, ダイアログを無効果するにはスクリプトで dlloverride を使う必要があります。

2020年12月31日 (木) 14:48時点における版

Windows プログラムにも Linux で役に立つものがたくさんあります。Windows プログラムのパッケージも作ることが可能です。オペレーティングシステムの違いがあるためにやや面倒なところがあります。このガイドラインでは Win32 バイナリについて記述します。ソースが利用できるプロジェクトが Linux に移植されているためです。

確認事項

  • ライセンス: ライセンスがプログラムの再配布を許可しているか。
  • インストーラー: ユーザーが特に操作しなくてもプログラムをインストールできるか。インストーラー不要のバージョンは存在するか。
  • ポータビリティ: プログラムはポータブルか。ファイルシステムを汚さないか。

プログラムがポータブルかどうかというのはレジストリやプログラムディレクトリの外に書き込みを行わないことを意味します。ファイルシステムを汚さないプログラムとはユーザーフォルダに設定を書き込むプログラムを意味します。両方の条件を満たすプログラム (例: 設定をどこにも書き込まない) もあれば、どちらにも当てはまらないプログラも存在します (例: あらゆるところに書き込みを行う)。

ライセンス

通常、ライセンスはインストールディレクトリにテキストファイルの形で存在します。見つけられない場合、インストール時の表示を確認してください。大抵のライセンスはファイルの削除や再パッケージを許可していません。前者の場合、makepkg の処理によってファイルが消えないように注意する必要があります。post_install で無駄なファイルを削除してしまう可能性があるためです (例: アンインストーラー)。後者の場合、インストールは全て post_install で行う必要があります。build ではインストールファイルのコピーだけを行います。

インストーラ

Windows インストーラーよりも .zip などの圧縮ファイルのほうがパッケージにするのが簡単です。プログラムがインストーラーによってしか配布されていない場合、インターネットを検索してソフトウェアをユーザーの操作なしでインストールする方法がないか探してください。検索する場所としては MSFN が良いでしょう。方法が見つからない場合、解凍ユーティリティを使ってインストーラーを解凍できないか試してみてください。

ポータビリティ

ポータブルなプログラムであれば Wine でファイルシステムをエミュレートする必要はありません。パッケージングするプログラムにポータブル版が存在しないか Portable Freeware で確認してみてください。

ガイドライン

Windows のプログラムをパッケージ化するということは、プログラムのファイルを JVM と Java のバイトコードと同じように、Wine が解釈するただのデータとして使うことです。

したがって、プログラムは /usr/share/"$pkgname" にインストールし、プログラムは必要なものを全て "$HOME"/."$pkgname" に書き込むようにします。/usr/bin/"$pkgname" に保存したスクリプトを使って、フォルダを作成したり必要な準備を行って、それからプログラムを起動します。

次のセクションでは必要なステップについて説明します。

この方法ではあれば個々のユーザーがそれぞれ設定を保持することができ、他のユーザーに干渉することがありません。

インストール

プログラムにインストーラが存在しない場合、インストールはファイルの解凍にすぎません。"$pkgdir"/usr/share/$pkgname に展開して、パーミッションを適切に設定します。以下のコマンドでパーミッションを確認できます:

$ find "$pkgdir"/usr/share -type f -exec chmod 644 "{}" \;
$ find "$pkgdir"/usr/share -type d -exec chmod 755 "{}" \;

プログラムを簡単にインストールできない場合、Wine 環境を作成する必要があります:

$ install -m755 -d "$srcdir"/tmp "$srcdir"/tmp/env "$srcdir"/tmp/local
$ export WINEPREFIX="$srcdir"/tmp/env
$ export XDG_DATA_HOME="$srcdir"/tmp/local
$ wine "$srcdir"/installer.exe /silentoptions

We have not discussed portability yet, but if your program does not need the registry keys it modified, you can just copy the directory from the:

"$srcdir"/tmp/env/drive_c/Program\ Files/programname

Otherwise you need to copy all the registry files too and eventually the files the program installed around. The "$srcdir"/tmp/local will contains menu icons and desktop files, you may want to copy them in the package. If there does not exist a way to install the program silently... Maybe you can make a .tar.gz file and upload it somewhere? If nothing automated is possible, force the user to follow the installer and hope he does not mess up the installation, write some checks before blindly copying a folder that may not exist (e.g., the user pressed 'Cancel'.)

/usr/bin スクリプト

スクリプトでは設定フォルダを用意してプログラムを起動します。プログラムがポータブルな場合、以下のようになります:

#!/bin/bash
unset WINEPREFIX
if [ ! -d "$HOME"/.programname ] ; then
   mkdir -p "$HOME"/.programname
   #prepare the environment here
fi
WINEDEBUG=-all wine "$HOME"/.programname/programname "$@"

If it is clean, it will look like this:

#!/bin/bash
export WINEPREFIX="$HOME"/.programname/wine
if [ ! -d "$HOME"/.programname ] ; then
   mkdir -p "$HOME"/.programname/wine
   wineboot -u
   #copy the registry file if needed
fi
WINEDEBUG=-all wine /usr/share/programname "$@"

As you can see, in the second case there is no environment preparation. In fact a clean application will be started directly from /usr/share since it will not need to write in its folder, so its settings will be written somewhere in the emulated file system.

If the application is neither clean neither portable the two ideas must be combined.

If the application does not write settings at all, skip the if and start it from /usr/share.

The task of preparing the environment may differ greatly between applications, but follow these rules of thumb: If the program:

  • just needs to read a file, symlink it.
  • needs to write in a file, copy it.
  • does not use a file, ignore it.

Of course the minimum is just starting WINEDEBUG=-all wine /usr/share/programname "$@".

Usually the environment will be made by symlinking between the "$HOME"/.programname directory and the /usr/share/programname files. But since some Windows programs are very fickle about their paths, you may need to symlink directly in the "$HOME"/.programname/wine/drive_c/Program\ Files/programname directory.

Of course those are just ideas to integrate Win32 applications in the Linux environment, do not forget your intelligence and gumption.

As example, μTorrent is by default a clean application, but with a easy step can be used as a portable one. Since it is a single file and it is pretty small creating its wine environment (about 5MB) it is probably an overkill. It is better to symlink the executable, create the empty settings.dat in order to use it portable in the $HOME/.utorrent directory. With the added advantage that just visiting .utorrent folder an user can see a copy of the .torrent files she downloaded.

UnionFsFuse

unionfs-fuse パッケージで UnionFsFuse プログラムを使うことができます。UnionFsFuse はベースディレクトリを /usr/share に保持して、書き込みに必要なアプリケーションのファイルのコピーを $HOME/.programname に自動的に配置します。

Using UnionFsFuse means an additional dependency and it requires the fuse module that not all users might load. Yet, it might be worthwhile if the application would need lots of symlinking or if it is unclear exactly what it needs to be written. Just ensure to mount and unmount the UnionFs correctly.

サンプル

We will make a package for eMule. According to Portable Freeware, eMule is not completely portable since it writes some (useless) keys in the registry.

On the other hand, it is not clean either since it writes its configuration files and puts its downloads in its installation folder.

Luckily there is an installer-less version available.

So we make our PKGBUILD; the only dependency is wine. The md5sums should be added.

# Maintainer: You <youremail>
pkgname=emule
pkgver=0.49b
pkgrel=1
pkgdesc="One of the biggest and most reliable peer-to-peer file sharing
clients around the world."
arch=(i686 x86_64)
url="http://www.emule-project.net"
license=('GPL')
depends=()
depends=(wine)
makedepends=(unzip)
source=(emule http://prdownloads.sourceforge.net/emule/eMule$pkgver.zip)
noextract=()
options=(!strip)

build() {
  rm -f src/eMule"$pkgver"/license* #It is GPL

  install -d -m755 pkg/usr/share/emule
  cp -ra src/eMule"$pkgver"/* pkg/usr/share/emule
  find pkg/usr/share/emule -type d -exec chmod 755 "{}" \;
  find pkg/usr/share/emule -type f -exec chmod 644 "{}" \;

  install -d -m755 pkg/usr/bin
  install -m755 emule pkg/usr/bin 
}

Now we make our emule file, which according to build, will be copied and made executable in /usr/bin.

#!/bin/bash
export WINEARCH=win32 WINEPREFIX="$HOME/.emule/wine"

if [ ! -d "$HOME"/.emule ] ; then
  mkdir -p "$HOME"/.emule/wine || exit 1
  #Each user will have its config, we copy the default file since emule
  #needs to write here.
  cp -r /usr/share/emule/config "$HOME"/.emule || exit 1
  #We symlink the files emule needs to read to work
  ln -s /usr/share/emule/emule.exe "$HOME"/.emule/emule || exit 1
  ln -s -T /usr/share/emule/lang "$HOME"/.emule/lang || exit 1
  ln -s -T /usr/share/emule/webserver "$HOME"/.emule/webserver || exit 1
fi

wine "$HOME"/.emule/emule "$@"

If you want to be more precise, you may add a message in the .install file telling the user that they should disable search history since wine messes up that menu. You may even provide a default config file with the best settings. And that's it... run $ makepkg, check the package folder to be sure, and install.

Gecko と Mono

Unless you know for sure, that software require browser of .NET runtime (packages wine_gecko[リンク切れ: 置換パッケージ: wine-gecko] and wine-mono in official repositories), default wine installation prompts for Gecko/Mono are undesirable.

HTML レンダリング, バイトコードサポート, ダイアログを無効果するにはスクリプトで dlloverride を使う必要があります。

Gecko の場合:

export WINEDLLOVERRIDES="mshtml="

Mono の場合:

export WINEDLLOVERRIDES="mscoree="

両方の場合:

export WINEDLLOVERRIDES="mscoree,mshtml="

winecfg で無効化することもできます。mscoree/mshtml を Disable に設定してください。