Skip to content

Instantly share code, notes, and snippets.

@chihchun
Last active August 29, 2015 13:57
Show Gist options
  • Save chihchun/9779944 to your computer and use it in GitHub Desktop.
Save chihchun/9779944 to your computer and use it in GitHub Desktop.
Script for checkout all source code of current Ubuntu packages.
#!/bin/bash
# Script for checkout all source code of current Ubuntu packages.
# Usage: dpkg-query -f '${Package} ${Source}\n' -W | $0
# Author: Rex Tsai <rex.cc.tsai@gmail.com>
# codename can be trusty, precise, etc.
codename=
# bzr or "git-bzr"
vcs="git-bzr"
sources=$(while read pkgs; do
IFS=' ' read -a pkg <<< ${pkgs}
source=${pkg[1]}
binary=${pkg[0]}
echo "${source:=$binary}"
done | sort | uniq)
for branch in ${sources} ; do
echo "Downloading $branch"
if [ -z $codename ] ; then
${vcs} branch lp:/ubuntu/$branch
else
${vcs} branch lp:/ubuntu/$codename/$branch
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment