个人工具

“UbuntuHelp:PythonRecipes/DebianPackage”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/PythonRecipes/DebianPackage}} {{Languages|UbuntuHelp:PythonRecipes/DebianPackage}} #title How to create a Debian Package ''This Python Recipe is c...)
 
第3行: 第3行:
 
#title How to create a Debian Package
 
#title How to create a Debian Package
 
''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''
 
 
Here is a simple example on how to create a Debian Package, but it will not be in agreement with the [http://www.debian.org/doc/debian-policy/ Debian Policy]. You should read that if you want to publish your program in the Debian repositories. In this example I will use a game developed for [http://www.pyweek.org PyWeek 5], Twisted Zombie.
 
Here is a simple example on how to create a Debian Package, but it will not be in agreement with the [http://www.debian.org/doc/debian-policy/ Debian Policy]. You should read that if you want to publish your program in the Debian repositories. In this example I will use a game developed for [http://www.pyweek.org PyWeek 5], Twisted Zombie.
 
 
=== First step ===
 
=== First step ===
 
 
The first thing you should get to 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 get to 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
第28行: 第24行:
 
pyweek-upload.py
 
pyweek-upload.py
 
run_game.py</nowiki></pre>
 
run_game.py</nowiki></pre>
 
 
''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.
 
''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 ===
 
=== 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
第44行: 第36行:
 
Twisted Zombie is a game developed for PyWeek 5
 
Twisted Zombie is a game developed for PyWeek 5
 
in seven days by programmers of Santa Fé Argentina. </nowiki></pre>
 
in seven days by programmers of Santa Fé Argentina. </nowiki></pre>
 
 
If you wish, you can put more information about the package. In this page you can find all what you need for this: [http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles Binary package control files]
 
If you wish, you can put more information about the package. In this page you can find all what you need for this: [http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles Binary package control files]
 
 
=== twisted-zombie file ===
 
=== 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:
 
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:
 
<code><nowiki>python /usr/share/twisted-zombie/run_game.py</nowiki></code>
 
<code><nowiki>python /usr/share/twisted-zombie/run_game.py</nowiki></code>
 
 
=== 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
第67行: 第53行:
 
Exec=python /usr/share/twisted-zombie/run_game.py
 
Exec=python /usr/share/twisted-zombie/run_game.py
 
Categories=Game;</nowiki></pre>
 
Categories=Game;</nowiki></pre>
 
 
=== 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 ===
 
 
In this step we will build our package. For this, we use the following command in the folder that contain our application:
 
In this step we will build our package. For this, we use the following command in the folder that contain our application:
 
<code><nowiki>$ dpkg --build twisted-zombie/ twisted-zombie-1.0_all.deb</nowiki></code>
 
<code><nowiki>$ dpkg --build twisted-zombie/ twisted-zombie-1.0_all.deb</nowiki></code>
 
 
And to finish:
 
And to finish:
 
 
<code><nowiki>$ dpkg -i twisted-zombie-1.0_all.deb</nowiki></code>
 
<code><nowiki>$ dpkg -i twisted-zombie-1.0_all.deb</nowiki></code>
 
 
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.
 
----
 
----

2007年11月30日 (五) 21:10的版本

  1. title How to create a Debian Package

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 how to create a Debian Package, but it will not be in agreement with the Debian Policy. You should read that if you want to publish your program in the Debian repositories. In this example I will use a game developed for PyWeek 5, Twisted Zombie.

First step

The first thing you should get to 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: 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.