Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.84 KB | None | 0 0
  1. #!/bin/bash
  2. # Script to clone / update GITs according to a text-file
  3. # and build Debian-Packages from them as well as sort them into the repository
  4. # 2014-10-08 V1 by Michael Mrozek (EvilDragon)
  5. #
  6.  
  7. # Setup some Env-Vars
  8.  
  9. builddir="/srv/www/vhosts/domains/packages.pyra-handheld.com/build"
  10. gitlist="/srv/www/vhosts/domains/packages.pyra-handheld.com/build/packages.txt"
  11. repodir="/srv/www/vhosts/domains/packages.pyra-handheld.com/httpdocs/debian"
  12. logdir="/srv/www/vhosts/domains/packages.pyra-handheld.com/httpdocs/buildlogs"
  13.  
  14. # Update rootfs if needed
  15. ARCH=armhf DIST=testing git-pbuilder update
  16.  
  17. # Package-Build-Loop
  18. while read file          
  19. do          
  20.  
  21.   url="$(echo $file)"
  22.  
  23.   # Clean old stuff
  24.   rm -R "$builddir/tmp/"
  25.   build=false
  26.  
  27.   # Read the GIT URL
  28.   gitdir="$(echo ${url%.*} | awk -F'/' '{print $NF}')"
  29.  
  30.   # Does GIT exist?
  31.   if [ ! -d "$builddir/$gitdir" ]; then
  32.     # Clone it!
  33.     echo New Package! - Cloning $url
  34.     gbp-clone $url
  35.     build=true
  36.   else
  37.     # Otherwise: Update the GIT.
  38.     echo Update GIT
  39.     cd "$builddir/$gitdir"
  40.     git fetch
  41.    
  42.     # Check if the package needs to be rebuilt
  43.     update="$(gbp-pull | grep "up to date")"
  44.     if [ -n "$update" ]; then
  45.       build=false
  46.     else
  47.       build=true
  48.     fi
  49.   fi  
  50.  
  51.   # Build if Package is updated
  52.  
  53.   if [ "$build" == true ]; then
  54.  
  55.     # Get package name
  56.     package="$(head -1 "${builddir}/${gitdir}/debian/control" | awk '{print $NF}')"
  57.  
  58.      # Build the source and binary packages!
  59.      cd "$builddir/$gitdir"
  60.      git-buildpackage
  61.  
  62.      # Put it into the repository
  63.  
  64.      cd "$builddir/tmp"
  65.      name="$(ls *.changes)"
  66.      reprepro -V -b "$repodir" include jessie-pyra $name
  67.    
  68.      # Move the build log files into the build-log-dir
  69.      mv "$builddir/tmp/*.build" "$logdir/"
  70.    
  71.   fi
  72.  
  73. done <$gitlist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement