B
B
BotaniQ_Q2017-05-29 22:48:21
linux
BotaniQ_Q, 2017-05-29 22:48:21

How to build an installation package on Linux for Linux?

I wrote a program in python, it uses third-party libraries, I installed them through pip, how to make an installation package, so that the user would download this package from the link and install python with the required version, the program itself, the libraries for it, the icon appeared for programs?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2017-05-29
@leahch

0) It is advisable to pack everything in virtuelenv if you are using pip. Or use standard system packages.
1) Create a directory for your package, for example myservice-0.001
2) Throw all your sources into this directory, set the paths as you will have them on the target system
For example:

etc/systemd/system/myservice.service
opt/myservice/...
opt/.myservice-venv/...
usr/bin/myservice

Etc.
3) Create the DEBIAN directory in the same place, put the control file in it - https://www.debian.org/doc/debian-policy/ch-control... , and the postinst
file (optional) - https://www. debian.org/doc/debian-policy/ch-mainta... In control , describe your dependencies and the name of the package, which packages postinst replaces - executable, starts after installing the package, create users there, start the service, etc.
[email protected]:~/xxx-2.40# cat DEBIAN/control
Package: xxx
Version: 2.40
Section: custom
Priority: optional
Architecture: all
Essential: no
Installed-Size: 171700
Maintainer: xxx.ru
Description: XXX DS system
Depends: samba, isc-dhcp-server, python-twisted, libdate-manip-perl, libio-socket-multicast-perl
Replaces: isc-dhcp-server, samba
Recommends: sudo, vim, nano

and
[email protected]:~/xxx-2.40# cat DEBIAN/postinst
#!/bin/sh
# postinst script for webpy-example
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

# source debconf library
. /usr/share/debconf/confmodule

case "$1" in

  configure)
    adduser --quiet --system --home /inbox  xxx || echo "User xxx existed!"
    usermod -p yyyy xxx
    (echo new123; echo new123) | smbpasswd -as xxx
    smbpasswd -e xxx
    systemctl enable xxx
    systemctl start xxx
  ;;

  abort-upgrade|abort-remove|abort-deconfigure)
    exit 0
  ;;

  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
  ;;

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

db_stop
exit 0

4) go to the directory below and execute
Next get the file myservice-0.001.deb
Done.
PS. Read about icons and other things separately, I won't tell you that.

M
Michael, 2017-06-08
@Singaporian

Look, if you need direct full automation, PIP is not the most convenient option. You will have to switch to packages that are standard for the operating system (.deb, .rpm, ...).
In this case, even the Python packages themselves are best converted into standard packages. It's very easy to do this:

pip install stdeb
(example for django-haystack package)
/usr/local/bin/pypi-install django-haystack --release=2.6.1 --verbose=5 --keep

And then just put the dependencies in debian / control (or whatever file there is in other OSes).
But I would start if I were you by carefully reading this article on dh-virtualenv

A
Alexander, 2017-05-29
@sanya84

pip install PyInstaller
in cmd or whatever on LInux )
pyinstaller script_name.py --onefile
--noconsole The application will be built with all the libraries
in the dist folder, the finished application will run on Linux
on another computer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question