3

I have two Python scripts, and I need to package them into a Debian package. I have tried quite a few things with some success. For example, I made a setup.py and then used python-stdeb to create a package (which - if I recall properly - did not work very well), and I also made my own package from scratch with a structure like so:

project
  DEBIAN/
    changelog
    copyright
    compat
    rules
    control
    install
  usr/
    bin/
      script1
      script2

It was something like that, anyway. I got a package that then acted like a Debian package and I could use dpkg -b project to first build it and then dpkg -i package.deb to install the Debian packaging, however it didn't install anything (well it did install some things, but it didn't install the scripts that I wrote, which is what I would really like to install). So, how can I just make a package that will install my Python scripts. I don't care if they go to X11 or I have to say "Install to ~/package". All I want is for my scripts to go into a package so that someone else can install that package and have my scripts.

My guess is that I have to put metadata or something in the install file, but I don't know what to put in there.

2

One fast and easy way could be to use alien, it convert .tar to .deb:

tar czf pkg-name.tgz usr/
fakeroot alien -d pkg-name.tgz

Else use the old way, I use a Makefile like that:

all: deb

deb:
    mkdir -p tmp/usr/bin tmp/DEBIAN tmp/etc tmp/usr/share/man/man5
    find tmp -type d | xargs chmod 755
    cp some.conf tmp/etc/
    cp man/some.5 tmp/usr/share/man/man5/
    cp somecmd tmp/usr/bin/
    tar c --owner root --group root -v -z -f tmp/data.tar.gz -C tmp ./etc ./usr
    cd tmp && find usr/ etc/ -type f | xargs md5sum >DEBIAN/md5sums
    awk '/^#Package:/{i++}i {print substr($$0,2); }' Makefile >tmp/DEBIAN/control
    tar c --owner root --group root -v -z -f tmp/control.tar.gz -C tmp/DEBIAN ./control ./md5sums
    echo 2.0 >tmp/debian-binary
    ar rcv pkg-name_1.0-1.deb tmp/debian-binary tmp/control.tar.gz tmp/data.tar.gz

.phony: clean
clean:
    -rm -fr tmp

#Package: pkg-name
#Version: 1.0
#Section: net
#Priority: optional
#Architecture: all
#Essential: no
#Installed-size: 100
#Maintainer: Name <mail@here>
#Depends: optional dependencies
#Description: short descr
# long descr
  • huh, I saw that the other day. Since I didn't have a .tar file (just two scripts -- now three scripts and a PNG -- I didn't want to use it. I guess I could just tar -cvzf it. Not a bad idea. Again, I know basically nothing about Debian packages. My coworker just said "hey, make a package so I can download it on this headless wandboard." How would you "make" or build the make file (I'm assuming you wouldn't just do make make install or something like that. I like the make file idea, I just don't know what to do with it once I have it. Also, let me get back to you with the tar. Thanks!!! – Dylan Oct 6 '14 at 0:30
  • Nice alien worked like a dream. That was a little too easy. The only thing it it installed to /. Any way to change that. (I honestly haven't looked around much for this on the internet yet, though.) – Dylan Oct 6 '14 at 0:41
  • tar+alien are really easy, you must create and archive the relative path, ie: ./usr/bin/thescript, .debs are installed relative to / – Alex Oct 6 '14 at 0:43
  • Come again. I don't really understand what you are trying to say. I, of course, know what a relative path is, but I don't know what you mean by "create and archive the relative path." Do you mean that I must specify a relative path when I tar the package or when I use alien or something else entirely? Thanks – Dylan Oct 6 '14 at 1:19
  • If you need to install script in /usr/bin/ you've to tar ./usr/bin/script – Alex Oct 6 '14 at 1:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.