特殊:Badtitle/NS100:PythonRecipes/DebianPackage:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/PythonRecipes/DebianPackage}} | {{From|https://help.ubuntu.com/community/PythonRecipes/DebianPackage}} | ||
{{Languages|UbuntuHelp:PythonRecipes/DebianPackage}} | {{Languages|UbuntuHelp:PythonRecipes/DebianPackage}} | ||
<<Include(Tag/ContentCleanup)>> | |||
#title How to create a Debian Package | #title How to create a Debian Package | ||
Parent: (unknown) | [[UbuntuHelp:/PageDiscussion|Discuss this page]] | |||
'''Warning: These instructions are incorrect (this is bad hack, not a correct way to create deb package)''' - they should be fixed according to [https://help.ubuntu.com/6.10/ubuntu/packagingguide/C/ Ubuntu packaging guide]. If you wanna simple guide how to create Debian/Ubuntu package you could read http://www.debian-administration.org/articles/336 ([http://www.debian-administration.org/articles/337 Second part]) or use [http://easy-deb.sourceforge.net Easy-deb tool] for creating deb packages of python modules. | '''Warning: These instructions are incorrect (this is bad hack, not a correct way to create deb package)''' - they should be fixed according to [https://help.ubuntu.com/6.10/ubuntu/packagingguide/C/ Ubuntu packaging guide]. If you wanna simple guide how to create Debian/Ubuntu package you could read http://www.debian-administration.org/articles/336 ([http://www.debian-administration.org/articles/337 Second part]) or use [http://easy-deb.sourceforge.net Easy-deb tool] for creating deb packages of python modules. | ||
''This Python Recipe is currently being written, you can fix <u>all</u> errors in this example; feel free to do so'' | ''This Python Recipe is currently being written, you can fix <u>all</u> errors in this example; feel free to do so'' | ||
第7行: | 第9行: | ||
=== First step === | === First step === | ||
The first thing you should know is the folder structure of the Debian Package before you create it. This folder contains three files that are very important, '''control''', '''twisted-zombie''' and '''twisted-zombie.desktop'''. | The first thing you should know is the folder structure of the Debian Package before you create it. This folder contains three files that are very important, '''control''', '''twisted-zombie''' and '''twisted-zombie.desktop'''. | ||
<pre><nowiki>DEBIAN/ | <pre><nowiki> | ||
DEBIAN/ | |||
control | control | ||
usr/ | usr/ | ||
第28行: | 第31行: | ||
=== control file === | === control file === | ||
In the ''control'' file, we will put a short description, long description, package name, package version, etc. Just like the output of the `apt-cache show package` command. The control file contains: | In the ''control'' file, we will put a short description, long description, package name, package version, etc. Just like the output of the `apt-cache show package` command. The control file contains: | ||
<pre><nowiki> Package: twisted-zombie | <pre><nowiki> | ||
Package: twisted-zombie | |||
Version: 1.0 | Version: 1.0 | ||
Section: games | Section: games | ||
第43行: | 第47行: | ||
=== twisted-zombie.desktop file === | === twisted-zombie.desktop file === | ||
In this file we put some options about our application, to tell GNOME -or other desktop- to put our application in the menu, specifying which icon to use, what command to execute, etc... | In this file we put some options about our application, to tell GNOME -or other desktop- to put our application in the menu, specifying which icon to use, what command to execute, etc... | ||
<pre><nowiki>[Desktop Entry] | <pre><nowiki> | ||
[Desktop Entry] | |||
Encoding=UTF-8 | Encoding=UTF-8 | ||
Name=Twisted Zombie | Name=Twisted Zombie | ||
第56行: | 第61行: | ||
=== Config your application === | === Config your application === | ||
If you use external files, you should include the following lines in the .py that uses those files: | If you use external files, you should include the following lines in the .py that uses those files: | ||
<pre><nowiki>import os | <pre><nowiki> | ||
import os | |||
os.chdir('/usr/share/twisted-zombie')</nowiki></pre> | os.chdir('/usr/share/twisted-zombie')</nowiki></pre> | ||
=== Build and install our package === | === Build and install our package === | ||
第65行: | 第71行: | ||
Done, we have installed our game in our machine. Now, open a terminal, and type `twisted-zombie` or go to the Application Menu -> Games -> Twisted Zombie Game and play it. | Done, we have installed our game in our machine. Now, open a terminal, and type `twisted-zombie` or go to the Application Menu -> Games -> Twisted Zombie Game and play it. | ||
---- | ---- | ||
[[category: | Categories: [[category:CategoryProgrammingPython]] | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2008年10月19日 (日) 16:59的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/PythonRecipes/DebianPackage }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/af | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Afrikaans| [[::PythonRecipes/DebianPackage/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ar | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|العربية| [[::PythonRecipes/DebianPackage/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/az | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|azərbaycanca| [[::PythonRecipes/DebianPackage/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/bcc | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|جهلسری بلوچی| [[::PythonRecipes/DebianPackage/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/bg | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|български| [[::PythonRecipes/DebianPackage/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/br | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|brezhoneg| [[::PythonRecipes/DebianPackage/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ca | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|català| [[::PythonRecipes/DebianPackage/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/cs | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|čeština| [[::PythonRecipes/DebianPackage/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/de | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Deutsch| [[::PythonRecipes/DebianPackage/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/el | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Ελληνικά| [[::PythonRecipes/DebianPackage/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/es | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|español| [[::PythonRecipes/DebianPackage/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/fa | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|فارسی| [[::PythonRecipes/DebianPackage/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/fi | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|suomi| [[::PythonRecipes/DebianPackage/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/fr | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|français| [[::PythonRecipes/DebianPackage/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/gu | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|ગુજરાતી| [[::PythonRecipes/DebianPackage/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/he | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|עברית| [[::PythonRecipes/DebianPackage/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/hu | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|magyar| [[::PythonRecipes/DebianPackage/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/id | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Bahasa Indonesia| [[::PythonRecipes/DebianPackage/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/it | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|italiano| [[::PythonRecipes/DebianPackage/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ja | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|日本語| [[::PythonRecipes/DebianPackage/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ko | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|한국어| [[::PythonRecipes/DebianPackage/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ksh | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Ripoarisch| [[::PythonRecipes/DebianPackage/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/mr | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|मराठी| [[::PythonRecipes/DebianPackage/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ms | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Bahasa Melayu| [[::PythonRecipes/DebianPackage/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/nl | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Nederlands| [[::PythonRecipes/DebianPackage/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/no | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|norsk| [[::PythonRecipes/DebianPackage/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/oc | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|occitan| [[::PythonRecipes/DebianPackage/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/pl | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|polski| [[::PythonRecipes/DebianPackage/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/pt | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|português| [[::PythonRecipes/DebianPackage/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ro | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|română| [[::PythonRecipes/DebianPackage/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/ru | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|русский| [[::PythonRecipes/DebianPackage/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/si | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|සිංහල| [[::PythonRecipes/DebianPackage/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/sq | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|shqip| [[::PythonRecipes/DebianPackage/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/sr | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|српски / srpski| [[::PythonRecipes/DebianPackage/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/sv | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|svenska| [[::PythonRecipes/DebianPackage/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/th | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|ไทย| [[::PythonRecipes/DebianPackage/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/tr | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Türkçe| [[::PythonRecipes/DebianPackage/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/vi | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|Tiếng Việt| [[::PythonRecipes/DebianPackage/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/yue | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|粵語| [[::PythonRecipes/DebianPackage/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/zh | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|中文| [[::PythonRecipes/DebianPackage/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/zh-hans | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|中文(简体)| [[::PythonRecipes/DebianPackage/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PythonRecipes/DebianPackage | UbuntuHelp:PythonRecipes/DebianPackage | {{#if: | :}}PythonRecipes/DebianPackage}}/zh-hant | • {{#if: UbuntuHelp:PythonRecipes/DebianPackage|中文(繁體)| [[::PythonRecipes/DebianPackage/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:PythonRecipes/DebianPackage|:PythonRecipes/DebianPackage|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :PythonRecipes/DebianPackage/zh | | {{#ifexist: PythonRecipes/DebianPackage/zh | | {{#ifeq: {{#titleparts:PythonRecipes/DebianPackage|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:PythonRecipes/DebianPackage|1|-1|}} | zh | | }}
<<Include(Tag/ContentCleanup)>>
- title How to create a Debian Package
Parent: (unknown) | Discuss this page Warning: These instructions are incorrect (this is bad hack, not a correct way to create deb package) - they should be fixed according to Ubuntu packaging guide. If you wanna simple guide how to create Debian/Ubuntu package you could read http://www.debian-administration.org/articles/336 (Second part) or use Easy-deb tool for creating deb packages of python modules. This Python Recipe is currently being written, you can fix all errors in this example; feel free to do so Here is a simple example on creating a Debian Package, but it will not be in agreement with the Debian/Ubuntu Policy. You should read that if you want to publish your program in the Debian/Ubuntu repositories. In this example I will use a game developed for PyWeek 5, Twisted Zombie.
First step
The first thing you should know is the folder structure of the Debian Package before you create it. This folder contains three files that are very important, control, twisted-zombie and twisted-zombie.desktop.
DEBIAN/ control usr/ bin/ twisted-zombie share/ applications/ twisted-zombie.desktop pixmaps/ twisted-zombie-icon.png twisted-zombie/ data/ lib/ COPYING README.txt create-upload.py pyweek-upload.py run_game.py
twisted-zombie is the folder of the application itself, pixmaps contains an icon, application contains a desktop file that indicates some options to GNOME, and bin contains a script to execute this game from a console.
control file
In the control file, we will put a short description, long description, package name, package version, etc. Just like the output of the `apt-cache show package` command. The control file contains:
Package: twisted-zombie Version: 1.0 Section: games Maintainer: Manuel Kaufmann <[email protected]> Architecture: all Depends: python, python-pygame Description: Twisted Zombie game Twisted Zombie is a game developed for PyWeek 5 in seven days by programmers of Santa Fé Argentina.
If you wish, you can put more information about the package. In this page you can find all what you need for this: Binary package control files
twisted-zombie file
In this file we will put what command should be executed when we type `twisted-zombie` in a console. It's simple, it only contains the `python` command with the path of the main .py file. Make sure that it is executable (chmod a+x run_game.py):
python /usr/share/twisted-zombie/run_game.py
twisted-zombie.desktop file
In this file we put some options about our application, to tell GNOME -or other desktop- to put our application in the menu, specifying which icon to use, what command to execute, etc...
[Desktop Entry] Encoding=UTF-8 Name=Twisted Zombie Version=1.0 Comment=Game developed for PyWeek 5 GenericName=Twisted Zombie Game Terminal=false Icon=twisted-zombie-icon.png Type=Application Exec=python /usr/share/twisted-zombie/run_game.py Categories=Game;
Config your application
If you use external files, you should include the following lines in the .py that uses those files:
import os os.chdir('/usr/share/twisted-zombie')
Build and install our package
In this step we will build our package. For this, we use the following command in the folder that contain our application:
$ dpkg --build twisted-zombie/ twisted-zombie-1.0_all.deb
And to finish:
$ dpkg -i twisted-zombie-1.0_all.deb
Done, we have installed our game in our machine. Now, open a terminal, and type `twisted-zombie` or go to the Application Menu -> Games -> Twisted Zombie Game and play it.
Categories: