pbuildPackage.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. set -e
  3. # build the supplied package using pbuilder
  4. # satisfies build dependencies if necessary
  5. # This file is part of PrawnOS (https://www.prawnos.com)
  6. # Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
  7. # PrawnOS is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License version 2
  9. # as published by the Free Software Foundation.
  10. # PrawnOS is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  16. if [ -z "$1" ]
  17. then
  18. echo "No package name supplied"
  19. exit 1
  20. fi
  21. if [ -z "$2" ]
  22. then
  23. echo "No pbuilder chroot supplied"
  24. exit 1
  25. fi
  26. if [ -z "$3" ]
  27. then
  28. echo "No pbuilder RC supplied"
  29. exit 1
  30. fi
  31. if [ -z "$4" ]
  32. then
  33. echo "No pbuilder hooks directory supplied"
  34. exit 1
  35. fi
  36. if [ -z "$5" ]
  37. then
  38. echo "No prawnos apt repo directory supplied"
  39. exit 1
  40. fi
  41. if [ -z "$6" ]
  42. then
  43. echo "No prawnos apt repo sources.list line supplied"
  44. exit 1
  45. fi
  46. PACKAGE_NAME=$1
  47. PBUILDER_CHROOT=$2
  48. PBUILDER_RC=$3
  49. PBUILDER_HOOKS=$4
  50. PRAWNOS_LOCAL_APT_REPO=$5
  51. PRAWNOS_LOCAL_APT_SOURCE=$6
  52. PACKAGE_DIR=$PWD
  53. # only defined if there are build deps we need to satisfy
  54. PACKAGE_LOCAL_BUILD_DEPS=$7
  55. if [[ $PACKAGE_LOCAL_BUILD_DEPS == "" ]]; then
  56. echo Building $PACKAGE_NAME
  57. cd src
  58. pdebuild --configfile $PBUILDER_RC \
  59. --buildresult $PACKAGE_DIR \
  60. -- \
  61. --hookdir $PBUILDER_HOOKS \
  62. --basetgz $PBUILDER_CHROOT
  63. else
  64. echo Satisfying local build deps for $PACKAGE_NAME
  65. for dep in $PACKAGE_LOCAL_BUILD_DEPS ; do \
  66. make build_package BUILD_PACKAGE=$dep -C .. ; \
  67. done
  68. rm $PRAWNOS_LOCAL_APT_REPO/Packages
  69. cd $PRAWNOS_LOCAL_APT_REPO && dpkg-scanpackages . /dev/null > Packages
  70. echo $PACKAGE_NAME build deps satisfied
  71. cd $PACKAGE_DIR
  72. echo Building $PACKAGE_NAME
  73. cd src
  74. pdebuild --configfile $PBUILDER_RC \
  75. --buildresult $PACKAGE_DIR \
  76. -- \
  77. --override-config \
  78. --basetgz $PBUILDER_CHROOT \
  79. --hookdir $PBUILDER_HOOKS \
  80. --bindmounts $PRAWNOS_LOCAL_APT_REPO \
  81. --othermirror "$PRAWNOS_LOCAL_APT_SOURCE"
  82. fi
  83. mkdir -p $PRAWNOS_LOCAL_APT_REPO
  84. cp $PACKAGE_DIR/$PACKAGE_NAME $PRAWNOS_LOCAL_APT_REPO