| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | # | | 2 | # |
3 | # $NetBSD: pkg_comp.sh,v 1.37 2010/04/15 09:42:45 jmmv Exp $ | | 3 | # $NetBSD: pkg_comp.sh,v 1.38 2010/07/20 16:50:26 jmmv Exp $ |
4 | # | | 4 | # |
5 | # pkg_comp - Build packages inside a clean chroot environment | | 5 | # pkg_comp - Build packages inside a clean chroot environment |
6 | # Copyright (c) 2002, 2003, 2004, 2005 Julio M. Merino Vidal <jmmv@NetBSD.org> | | 6 | # Copyright (c) 2002, 2003, 2004, 2005 Julio M. Merino Vidal <jmmv@NetBSD.org> |
7 | # | | 7 | # |
8 | # Redistribution and use in source and binary forms, with or without | | 8 | # Redistribution and use in source and binary forms, with or without |
9 | # modification, are permitted provided that the following conditions | | 9 | # modification, are permitted provided that the following conditions |
10 | # are met: | | 10 | # are met: |
11 | # 1. Redistributions of source code must retain the above copyright | | 11 | # 1. Redistributions of source code must retain the above copyright |
12 | # notice, this list of conditions and the following disclaimer. | | 12 | # notice, this list of conditions and the following disclaimer. |
13 | # 2. Redistributions in binary form must reproduce the above copyright | | 13 | # 2. Redistributions in binary form must reproduce the above copyright |
14 | # notice, this list of conditions and the following disclaimer in | | 14 | # notice, this list of conditions and the following disclaimer in |
15 | # the documentation and/or other materials provided with the | | 15 | # the documentation and/or other materials provided with the |
16 | # distribution. | | 16 | # distribution. |
| @@ -523,27 +523,26 @@ makeroot() | | | @@ -523,27 +523,26 @@ makeroot() |
523 | echo "setenv PKG_DBDIR \"${PKG_DBDIR}\"" >> ${DESTDIR}/etc/csh.cshrc | | 523 | echo "setenv PKG_DBDIR \"${PKG_DBDIR}\"" >> ${DESTDIR}/etc/csh.cshrc |
524 | | | 524 | |
525 | cp /etc/resolv.conf $DESTDIR/etc/resolv.conf | | 525 | cp /etc/resolv.conf $DESTDIR/etc/resolv.conf |
526 | | | 526 | |
527 | makeroot_mkconf | | 527 | makeroot_mkconf |
528 | | | 528 | |
529 | echo "PKG_DBDIR=${PKG_DBDIR}" >> ${DESTDIR}/etc/pkg_install.conf | | 529 | echo "PKG_DBDIR=${PKG_DBDIR}" >> ${DESTDIR}/etc/pkg_install.conf |
530 | | | 530 | |
531 | # From now on, filesystems may be mounted, so we need to trap | | 531 | # From now on, filesystems may be mounted, so we need to trap |
532 | # signals to umount them. | | 532 | # signals to umount them. |
533 | trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT | | 533 | trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT |
534 | | | 534 | |
535 | makeroot_libkver | | 535 | makeroot_libkver |
536 | [ "$Nflag" = "no" ] && makeroot_digest | | | |
537 | | | 536 | |
538 | if [ "$USE_GCC3" = "yes" -a "$Nflag" = "no" ]; then | | 537 | if [ "$USE_GCC3" = "yes" -a "$Nflag" = "no" ]; then |
539 | if [ -z "`echo $BUILD_PACKAGES $INSTALL_PACKAGES | grep gcc3`" ]; then | | 538 | if [ -z "`echo $BUILD_PACKAGES $INSTALL_PACKAGES | grep gcc3`" ]; then |
540 | AVOID_GCC3=yes build_and_install lang/gcc3 | | 539 | AVOID_GCC3=yes build_and_install lang/gcc3 |
541 | fi | | 540 | fi |
542 | fi | | 541 | fi |
543 | | | 542 | |
544 | makeroot_x11 | | 543 | makeroot_x11 |
545 | | | 544 | |
546 | if [ -n "${MAKEROOT_HOOKS}" ]; then | | 545 | if [ -n "${MAKEROOT_HOOKS}" ]; then |
547 | echo "Executing makeroot hooks." | | 546 | echo "Executing makeroot hooks." |
548 | for h in ${MAKEROOT_HOOKS}; do | | 547 | for h in ${MAKEROOT_HOOKS}; do |
549 | ${h} ${DESTDIR} makeroot | | 548 | ${h} ${DESTDIR} makeroot |
| @@ -599,37 +598,26 @@ CXXFLAGS += $CXXFLAGS | | | @@ -599,37 +598,26 @@ CXXFLAGS += $CXXFLAGS |
599 | .endif | | 598 | .endif |
600 | EOF | | 599 | EOF |
601 | else | | 600 | else |
602 | cat >>$file <<EOF | | 601 | cat >>$file <<EOF |
603 | CFLAGS += $CFLAGS | | 602 | CFLAGS += $CFLAGS |
604 | CPPFLAGS += $CPPFLAGS | | 603 | CPPFLAGS += $CPPFLAGS |
605 | CXXFLAGS += $CXXFLAGS | | 604 | CXXFLAGS += $CXXFLAGS |
606 | | | 605 | |
607 | .endif # BSD_PKG_MK | | 606 | .endif # BSD_PKG_MK |
608 | EOF | | 607 | EOF |
609 | fi | | 608 | fi |
610 | } | | 609 | } |
611 | | | 610 | |
612 | # makeroot_digest | | | |
613 | # | | | |
614 | # Ensure digest is always installed, specially because PKGSRC_COMPILER | | | |
615 | # may contain 'ccache' or 'distcc'. | | | |
616 | # | | | |
617 | makeroot_digest() | | | |
618 | { | | | |
619 | ( PKGSRC_COMPILER=gcc; export PKGSRC_COMPILER; \ | | | |
620 | build_and_install pkgtools/digest ) | | | |
621 | } | | | |
622 | | | | |
623 | # makeroot_libkver | | 611 | # makeroot_libkver |
624 | # | | 612 | # |
625 | # If NETBSD_RELEASE is set to a version string, installs libkver | | 613 | # If NETBSD_RELEASE is set to a version string, installs libkver |
626 | # inside the sandbox and configures it. | | 614 | # inside the sandbox and configures it. |
627 | # | | 615 | # |
628 | makeroot_libkver() | | 616 | makeroot_libkver() |
629 | { | | 617 | { |
630 | local prefix script statfile | | 618 | local prefix script statfile |
631 | | | 619 | |
632 | if [ "$NETBSD_RELEASE" != "no" ]; then | | 620 | if [ "$NETBSD_RELEASE" != "no" ]; then |
633 | _BUILD_TARGET="$BUILD_TARGET" | | 621 | _BUILD_TARGET="$BUILD_TARGET" |
634 | BUILD_TARGET="standalone-install" | | 622 | BUILD_TARGET="standalone-install" |
635 | build_and_install pkgtools/libkver | | 623 | build_and_install pkgtools/libkver |
| @@ -715,27 +703,27 @@ pkg_build() | | | @@ -715,27 +703,27 @@ pkg_build() |
715 | # Check if all packages exist | | 703 | # Check if all packages exist |
716 | invalid="" | | 704 | invalid="" |
717 | for p in $pkgs; do | | 705 | for p in $pkgs; do |
718 | if [ ! -d $REAL_PKGSRC/$p ]; then | | 706 | if [ ! -d $REAL_PKGSRC/$p ]; then |
719 | invalid="$invalid $p" | | 707 | invalid="$invalid $p" |
720 | fi | | 708 | fi |
721 | done | | 709 | done |
722 | if [ -n "$invalid" ]; then | | 710 | if [ -n "$invalid" ]; then |
723 | err "invalid packages:$invalid" | | 711 | err "invalid packages:$invalid" |
724 | fi | | 712 | fi |
725 | | | 713 | |
726 | # Build them | | 714 | # Build them |
727 | fsmount | | 715 | fsmount |
728 | check_pkg_install # executes copy_vulnerabilities too | | 716 | copy_vulnerabilities |
729 | failed="" | | 717 | failed="" |
730 | for p in $pkgs; do | | 718 | for p in $pkgs; do |
731 | echo "PKG_COMP ==> Building and installing $p" | | 719 | echo "PKG_COMP ==> Building and installing $p" |
732 | prefix=$(mktemp $DESTDIR/pkg_comp/tmp/pkg_comp-XXXXXX) | | 720 | prefix=$(mktemp $DESTDIR/pkg_comp/tmp/pkg_comp-XXXXXX) |
733 | rm $prefix | | 721 | rm $prefix |
734 | script="$prefix.sh" | | 722 | script="$prefix.sh" |
735 | statfile="$prefix.stat" | | 723 | statfile="$prefix.stat" |
736 | init_script $script | | 724 | init_script $script |
737 | cat >> $script <<EOF | | 725 | cat >> $script <<EOF |
738 | cd /usr/pkgsrc/$p | | 726 | cd /usr/pkgsrc/$p |
739 | make $BUILD_TARGET | | 727 | make $BUILD_TARGET |
740 | if [ \$? != 0 ]; then | | 728 | if [ \$? != 0 ]; then |
741 | touch /pkg_comp/tmp/`basename $statfile` | | 729 | touch /pkg_comp/tmp/`basename $statfile` |
| @@ -753,56 +741,26 @@ EOF | | | @@ -753,56 +741,26 @@ EOF |
753 | mv ${_BUILD_RESUME}.new ${_BUILD_RESUME} | | 741 | mv ${_BUILD_RESUME}.new ${_BUILD_RESUME} |
754 | fi | | 742 | fi |
755 | done | | 743 | done |
756 | fsumount | | 744 | fsumount |
757 | if [ -n "$failed" ]; then | | 745 | if [ -n "$failed" ]; then |
758 | echo "PKG_COMP ==> Build error summary" | | 746 | echo "PKG_COMP ==> Build error summary" |
759 | echo "Build failed for:" | | 747 | echo "Build failed for:" |
760 | for p in $failed; do | | 748 | for p in $failed; do |
761 | echo " $p" | | 749 | echo " $p" |
762 | done | | 750 | done |
763 | fi | | 751 | fi |
764 | } | | 752 | } |
765 | | | 753 | |
766 | # check_pkg_install | | | |
767 | # | | | |
768 | # Ensure that the version of pkg_install inside the sandbox is new | | | |
769 | # enough to work with pkgsrc. If not, rebuild it. | | | |
770 | # | | | |
771 | check_pkg_install() | | | |
772 | { | | | |
773 | local script | | | |
774 | | | | |
775 | copy_vulnerabilities | | | |
776 | | | | |
777 | # We assume filesystems are mounted! | | | |
778 | | | | |
779 | echo "PKG_COMP ==> Checking if pkg_install is up to date" | | | |
780 | script=$(mktemp $DESTDIR/pkg_comp/tmp/pkg_comp-XXXXXX).sh | | | |
781 | init_script $script | | | |
782 | cat >> $script <<EOF | | | |
783 | cd /usr/pkgsrc/pkgtools/pkg_comp | | | |
784 | fail=\$(make show-var VARNAME=PKG_FAIL_REASON) | | | |
785 | if echo \$fail | grep "package tools installed on this system are out of date" >/dev/null; then | | | |
786 | echo "PKG_COMP ==> pkg_install is out of date; rebuilding" | | | |
787 | cd /usr/pkgsrc/pkgtools/pkg_install | | | |
788 | make && make install && make clean | | | |
789 | fi | | | |
790 | EOF | | | |
791 | chmod +x $script | | | |
792 | chroot $DESTDIR /pkg_comp/tmp/`basename $script` | | | |
793 | rm $script | | | |
794 | } | | | |
795 | | | | |
796 | # build_and_install pkg | | 754 | # build_and_install pkg |
797 | # | | 755 | # |
798 | # Builds a package and ensures it gets installed. The use of destdir to | | 756 | # Builds a package and ensures it gets installed. The use of destdir to |
799 | # build packages may cause a package to get built but not installed, | | 757 | # build packages may cause a package to get built but not installed, |
800 | # which is not OK for this script. This is for internal usage only. | | 758 | # which is not OK for this script. This is for internal usage only. |
801 | # | | 759 | # |
802 | build_and_install() | | 760 | build_and_install() |
803 | { | | 761 | { |
804 | pkg=${1} | | 762 | pkg=${1} |
805 | fsmount | | 763 | fsmount |
806 | if pkg_build ${pkg}; then | | 764 | if pkg_build ${pkg}; then |
807 | script=$(mktemp ${DESTDIR}/pkg_comp/tmp/pkg_comp-XXXXXX).sh | | 765 | script=$(mktemp ${DESTDIR}/pkg_comp/tmp/pkg_comp-XXXXXX).sh |
808 | init_script ${script} | | 766 | init_script ${script} |