Advertisement
Guest User

build.ccr.sh

a guest
Jul 18th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.34 KB | None | 0 0
  1. #!/bin/sh
  2. #Script to make CCR packages mentioned in packages.ccr
  3. #V.-0.1
  4. # AUTHOR - iruel <cockmomgler at gmail dot com>
  5. #aurscript.sh AUTHOR - PDG - sHy [pdg@archlinux.us] , Thanks to Mike Tuffin for his ideas.
  6.  
  7. arch=$(uname -m)
  8. reponame="custom"
  9. startdir=$(pwd)
  10. #defpath=$(grep PKGDEST /etc/makepkg.conf | cut -d"=" -f2)
  11. defpath="${startdir}/work-${arch}/ccr-packages"
  12. #URL="http://github.com/archbang/ArchBang/raw/master/packages.list.aur"
  13. pacman_conf="${startdir}/overlay/etc/pacman.conf"
  14. error=false
  15.  
  16. # do UID checking here so someone can at least get usage instructions
  17. if [ "$EUID" != "0" ]; then
  18.   echo "error: This script must be run as root."
  19.   echo "try using 'sudo ./build-ccr.sh'"
  20.   exit 1
  21. fi
  22.  
  23. # Check if packages.ccr exists in the same directory
  24. if [ ! -f ${startdir}/packages.ccr ]; then
  25.   echo "You need to create a 'packages.ccr' file and fill it"
  26.   echo "with CCR package names before proceeding."
  27.   exit 1
  28. fi
  29.  
  30. # Prompt the user for a custom package storage path
  31. echo "Your packages will be by default stored in $defpath"
  32. read -p "Would you like to set a custom storage path? (Y/N): "
  33. if [[ "$REPLY" =~ ^[yY] ]]; then
  34.   echo "Enter the exact path to your custom package storage location: "
  35.   read newpath
  36.   mkdir -p $newpath &>/dev/null
  37.   echo "Path successfully created if it didn't already exist!"
  38.   sed -i "/PKGDEST/d" /etc/makepkg.conf
  39.   echo "PKGDEST=$newpath" >> /etc/makepkg.conf
  40.   echo "Path changed! Your package location is : $newpath"
  41.   echo "Press Enter to continue"
  42.   read
  43.   cd $newpath
  44.   defpath=$newpath
  45.   mkdir -p $defpath/ccrbuild &>/dev/null
  46. else
  47.   echo "Path not changed! Your package location is still : $defpath"
  48.   mkdir -p $defpath &>/dev/null
  49.   mkdir -p $defpath/ccrbuild &>/dev/null
  50.   sed -i "/PKGDEST/d" /etc/makepkg.conf
  51.   echo "PKGDEST=$defpath" >> /etc/makepkg.conf
  52.   echo "Press Enter to continue"
  53.   read
  54. fi
  55.  
  56. # Build the packages in defpath
  57. cd $defpath/ccrbuild/
  58. #wget $URL
  59. cp ${startdir}/packages.ccr packages.ccr
  60. for i in $(sed -e 's/\#.*//' -e 's/[ ^I]*$$//' -e '/^$$/ d' packages.ccr); do wget http://chakra-project.org/ccr/packages/$i/$i.tar.gz; done
  61. for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done
  62. rm *.tar.gz
  63. rm packages.ccr
  64. for dir in $defpath/ccrbuild/*
  65. do
  66.   (cd $dir && makepkg -rsf --asroot && mv *.pkg.tar.xz ../)
  67. done
  68.  
  69. repo-add $defpath/${reponame}.db.tar.gz $defpath/*.pkg.tar.xz
  70.  
  71. echo ""
  72. echo "Cleaning up..."
  73. echo ""
  74. rm -r $defpath/ccrbuild/
  75. chmod -R ugo+rX $defpath
  76.  
  77. if [ $? = 0 ]; then
  78.   echo "A package repository has been successfully created."
  79.   echo "However, review the output; some packages may have failed to build."
  80.   echo ""
  81.   echo "Would you like to automatically add this repository to"
  82.   read -p "the profile's pacman.conf? [Y/N]:"
  83.   if [[ "$REPLY" =~ ^[yY] ]]; then
  84.     echo "
  85. [${reponame}]
  86. Server = file://${defpath}/" >> ${pacman_conf}
  87.   else
  88.     echo ""
  89.     echo "Don't forget to add the below to 'overlay/etc/pacman.conf' manually:"
  90.     echo "
  91. [${reponame}]
  92. Server = file://${defpath}/"
  93.   fi
  94.   echo ""
  95.   echo "Would you also like to append 'packages.ccr' to packages.${arch}?"
  96.   read -p "(if you've already done this, DO NOT do it again.) [Y/N]:"
  97.   if [[ "$REPLY" =~ ^[yY] ]]; then
  98.     cat packages.ccr >> packages.${arch}
  99. else
  100.   echo "Something went wrong during repository creation. Review the"
  101.   echo "above output and try again."
  102. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement