How does one build a package

Contribute code to SolydXK and make it even better.
User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

How does one build a package

Postby ScottQuier » 01 Aug 2014 22:39

In almost finished with my project and would love for it to actually work on a real system. So how does one:
  • build the first structure
  • do the whole localization thing ... or at least build the infrastructure for it
  • craft an actual .deb from a python project
Links, hints, comments all gladly accepted.
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"


User avatar
Arjen Balfoort
Site Admin
Posts: 9219
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: How does one build a package

Postby Arjen Balfoort » 02 Aug 2014 10:01

If you want I can create the package for you. That way you can see its structure, needed files, etc.

When I started this project, I found I was building Python applications a lot. So, I wrote a bash called "builddeb" which builds a Python project located in a sub-directory. I placed that bash in /usr/bin, and now I only have to run "builddeb myproject-subdir":

Code: Select all

#!/bin/bash
# Build debs from subdirs

CURDIR=$PWD

if [ -z $1 ]; then
  echo "Provide a sub-directory name to build (or 'all')"
  exit
fi

# Be root to run this script
if [ $UID -ne 0 ]; then
  echo "Please, type root password..."
  su -c "$0 $@"
  exit
fi

buildpck() {
  echo "====================================================="
  echo "Package directory: $DIR"
  echo "====================================================="
  
  chown -R root:root $DIR
  cd $DIR
  DEB="debian"
  if [ -d ./DEBIAN ]; then
    DEB="DEBIAN"
  fi
  PCK=$(cat $DEB/control | grep Package: | cut -d' ' -f2)
  ARCH=$(cat $DEB/control | grep Architecture: | cut -d' ' -f2)
  VER=$(cat $DEB/control | grep Version: | cut -d' ' -f2)
  CHR="${PCK:0:1}"
  
  #md5sum `find . -type f | grep -v '^[.]/debian/'` > debian/md5sums
  i=0
  rm -f $DEB/md5sums
  while IFS= read -r -d $'\0' file; do
    md5sum "$file" >> $DEB/md5sums
    i=$((i+1))
  done < <(find . -path "*/$DEB/*" -prune -o -type f -print0)
  echo "$i files processed for md5sum"
  
  echo "----------------- Start build -----------------------"
  if [ -e $DEB/rules ]; then
    if [ "$ARCH" != "all" ]; then
      dpkg-buildpackage -rfakeroot -a$ARCH -us -uc -kBCA63C3C
    else
      dpkg-buildpackage -rfakeroot -us -uc -kBCA63C3C
    fi
    cd ../
  else
    cd ../
    if [[ -e $DIR/usr/share/doc/$PCK/changelog* ]]; then
      gzip --best $DIR/usr/share/doc/$PCK/changelog*
    fi
    US='_'
    dpkg -b $DIR "$PCK$US$VER$US$ARCH.deb"
  fi
  
  #if [ "$DIR" != "$CURDIR" ]; then
    #mv *.dsc *.gz *.deb *.changes $CURDIR/
  #fi
}



if [ "$1" == "all" ]; then
echo "all"
  for DIR in $(ls -d */) 
  do
    DIR="${DIR:0:${#DIR}-1}"
    FC="${DIR:0:1}"
    if [ $FC != "_" ]; then
      buildpck
    fi
  done
else
echo $1
  if [ -d $1 ]; then
    DIR=$1
    buildpck
  fi
fi
You can see that I sign my packages with the solydxk-keyring with "-kBCA63C3C".


SolydXK needs you!
Development | Testing | Translations

User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

Re: How does one build a package

Postby ScottQuier » 02 Aug 2014 12:34

Schoelje wrote:If you want I can create the package for you. That way you can see its structure, needed files, etc.
I'll take you up on that offer! When it's ready, I'll tar up the necessary files and make them available. Once I have the "correct" structure, I'll work on getting the git folders set up correctly. Sooooo much to learn!
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"

User avatar
Arjen Balfoort
Site Admin
Posts: 9219
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: How does one build a package

Postby Arjen Balfoort » 02 Aug 2014 12:59

Just as long as it's fun to do ;)


SolydXK needs you!
Development | Testing | Translations

Deleted User 2764

Re: How does one build a package

Postby Deleted User 2764 » 02 Aug 2014 21:35

@Scott: Sounds like you made great progress! Congratulations! :) I remember Schoelje recommending things like Poedit for localization and python-stdeb for building debian packages from python files (both are these are in the repos). I'm thinking they also come with docs to help you along?

@Schoelje: Can I keep your script too to use in the future in case I actually make programs?

To anyone who knows about this stuff: Maybe in the Tutorials section it would be nice to make a tutorial on how to do these things (localization and making a debian package)?

User avatar
jsalpha2
Posts: 296
Joined: 28 May 2013 12:28

Re: How does one build a package

Postby jsalpha2 » 03 Aug 2014 01:33

I've kept Zerozero's post on making a .deb bookmarked. http://forums.solydxk.com/viewtopic.php ... make+a+deb If I was just smarter! :(

Deleted User 2764

Re: How does one build a package

Postby Deleted User 2764 » 03 Aug 2014 02:25

Thanks for the link! I just bookmarked it. :)

User avatar
Arjen Balfoort
Site Admin
Posts: 9219
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: How does one build a package

Postby Arjen Balfoort » 03 Aug 2014 07:09

RavenLX wrote:@Schoelje: Can I keep your script too to use in the future in case I actually make programs?
:lol: Any code I post is open source, and free to use!


SolydXK needs you!
Development | Testing | Translations

Deleted User 2764

Re: How does one build a package

Postby Deleted User 2764 » 03 Aug 2014 13:57

Thank you. :) I guess it's a habit that I ask permission for some things... Still trying to shake off the Windows culture. :mrgreen:


Return to “Code”

Who is online

Users browsing this forum: No registered users and 2 guests