Guest User

Untitled

a guest
Jan 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. diff --git a/makechrootpkg.in b/makechrootpkg.in
  2. index d81be84..d045c0a 100644
  3. --- a/makechrootpkg.in
  4. +++ b/makechrootpkg.in
  5. @@ -51,6 +51,7 @@ usage() {
  6. echo '-n Run namcap on the package'
  7. echo '-T Build in a temporary directory'
  8. echo '-U Run makepkg as a specified user'
  9. + echo '-N Disable network during build'
  10. exit 1
  11. }
  12.  
  13. @@ -311,6 +312,7 @@ main() {
  14. clean_first=false
  15. run_namcap=false
  16. temp_chroot=false
  17. + disable_network=false
  18. chrootdir=
  19. passeddir=
  20. makepkg_user=
  21. @@ -325,7 +327,7 @@ main() {
  22. [[ -z "$copy" || $copy = root ]] && copy=copy
  23. src_owner=${SUDO_USER:-$USER}
  24.  
  25. - while getopts 'hcur:I:l:nTD:d:U:' arg; do
  26. + while getopts 'hcur:I:l:nTD:d:U:N' arg; do
  27. case "$arg" in
  28. c) clean_first=true ;;
  29. D) bindmounts_ro+=("--bind-ro=$OPTARG") ;;
  30. @@ -337,6 +339,7 @@ main() {
  31. n) run_namcap=true; makepkg_args+=(--install) ;;
  32. T) temp_chroot=true; copy+="-$$" ;;
  33. U) makepkg_user="$OPTARG" ;;
  34. + N) disable_network=true ;;
  35. h|*) usage ;;
  36. esac
  37. done
  38. @@ -415,12 +418,30 @@ main() {
  39.  
  40. prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap"
  41.  
  42. - if arch-nspawn "$copydir" \
  43. - --bind="$PWD:/startdir" \
  44. - --bind="$SRCDEST:/srcdest" \
  45. - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
  46. - /chrootbuild "${makepkg_args[@]}"
  47. - then
  48. + # Download dependencies
  49. + if [[ "$disable_network" == true ]]; then
  50. + stat_busy "Installing build dependencies before disabling network"
  51. + arch-nspawn "$copydir" \
  52. + --bind="$PWD:/startdir" \
  53. + --bind="$SRCDEST:/srcdest" \
  54. + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
  55. + sudo -u builduser bash -c 'cd /startdir; makepkg -soe --noconfirm'
  56. + stat_done
  57. +
  58. + arch-nspawn "$copydir" \
  59. + --bind="$PWD:/startdir" \
  60. + --bind="$SRCDEST:/srcdest" \
  61. + --private-network \
  62. + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
  63. + /chrootbuild "${makepkg_args[@]}"
  64. + else
  65. + arch-nspawn "$copydir" \
  66. + --bind="$PWD:/startdir" \
  67. + --bind="$SRCDEST:/srcdest" \
  68. + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
  69. + /chrootbuild "${makepkg_args[@]}"
  70. + fi
  71. + if (( $? == 0 )); then
  72. move_products "$copydir" "$src_owner"
  73. else
  74. (( ret += 1 ))
Add Comment
Please, Sign In to add comment