[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Script for automatically backporting



Hi,

I wrote a script for my personal backports (no signing). With this
script backporting is as easy as give the command "backport package" as
a normal user. And the script itself is really easy to understand, so
take a look at it.

In some cases there are missing build-dependencies. When that's the case
the script will give you the first missing build-dependency (it would be
better if the script would give you all missing build-dependencies, but OK).

I use sudo to give the normal user the right to use apt-get as root (see
the script). This has some security aspects. I expect it can be done
easily more secure then I do here, e.g. with a password in sudo, or by
using a special user for backporting.

With regards,
Paul.

-----------
#!/bin/bash
# /usr/local/bin/backport
# backports a package without signing it
# paul@vandervlis.nl

# user needs sudo rights for apt-get, e.g.:
# paul ALL=(ALL) NOPASSWD: /usr/bin/apt-get
# /etc/apt/sources.list needs a line like this:
# deb-src http://ftp.nl.debian.org/debian/ testing main

# ask for package when not on commandline
if test "$1" = ""; then
  read -p "package: " package
else
  package=$1
  echo "package: $package"
fi

# install build-dependencies
sudo /usr/bin/apt-get build-dep $package
if ! test $? = 0; then exit; fi

# create dir
if test -e $package; then echo "Directory excists"; fi
mkdir $package; cd $package
if ! test $? = 0; then exit; fi

# download sources
apt-get source $package
if ! test $? = 0; then exit; fi

# go to right directory
cd `find ./ -maxdepth 1 -type d | tail -n1`
if ! test $? = 0; then exit; fi

# build package without signing
dpkg-buildpackage -uc -us
if ! test $? = 0; then exit; fi

# show debs
cd ../..
echo
echo "Created deb's:"
ls $package/*.deb
echo
-----------------



-- 
Paul van der Vlis Linux systeembeheer, Groningen
http://www.vandervlis.nl


Reply to: