| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | # | | 2 | # |
3 | # $NetBSD: pkg_comp.sh,v 1.40 2012/02/27 22:42:27 jmmv Exp $ | | 3 | # $NetBSD: pkg_comp.sh,v 1.41 2012/05/19 10:54:40 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. |
| @@ -41,27 +41,27 @@ ProgName="`basename $0`" | | | @@ -41,27 +41,27 @@ ProgName="`basename $0`" |
41 | # as they require special handling. | | 41 | # as they require special handling. |
42 | _MKCONF_VARS="WRKDIR_BASENAME MKOBJDIRS BSDSRCDIR WRKOBJDIR DISTDIR PACKAGES \ | | 42 | _MKCONF_VARS="WRKDIR_BASENAME MKOBJDIRS BSDSRCDIR WRKOBJDIR DISTDIR PACKAGES \ |
43 | PKG_DEVELOPER CLEANDEPENDS LOCALBASE PKG_SYSCONFBASE \ | | 43 | PKG_DEVELOPER CLEANDEPENDS LOCALBASE PKG_SYSCONFBASE \ |
44 | CFLAGS CPPFLAGS CXXFLAGS USE_AUDIT_PACKAGES PKGVULNDIR \ | | 44 | CFLAGS CPPFLAGS CXXFLAGS USE_AUDIT_PACKAGES PKGVULNDIR \ |
45 | USE_XPKGWEDGE PKGSRC_COMPILER \ | | 45 | USE_XPKGWEDGE PKGSRC_COMPILER \ |
46 | LIBKVER_STANDALONE_PREFIX PKG_DBDIR" | | 46 | LIBKVER_STANDALONE_PREFIX PKG_DBDIR" |
47 | | | 47 | |
48 | _TEMPLATE_VARS="DESTDIR ROOTSHELL COPYROOTCFG BUILD_TARGET DISTRIBDIR SETS \ | | 48 | _TEMPLATE_VARS="DESTDIR ROOTSHELL COPYROOTCFG BUILD_TARGET DISTRIBDIR SETS \ |
49 | SETS_X11 REAL_SRC REAL_SRC_OPTS REAL_PKGSRC \ | | 49 | SETS_X11 REAL_SRC REAL_SRC_OPTS REAL_PKGSRC \ |
50 | REAL_PKGSRC_OPTS REAL_DISTFILES REAL_DISTFILES_OPTS \ | | 50 | REAL_PKGSRC_OPTS REAL_DISTFILES REAL_DISTFILES_OPTS \ |
51 | REAL_PACKAGES REAL_PACKAGES_OPTS REAL_PKGVULNDIR \ | | 51 | REAL_PACKAGES REAL_PACKAGES_OPTS REAL_PKGVULNDIR \ |
52 | NETBSD_RELEASE MAKEROOT_HOOKS MOUNT_HOOKS UMOUNT_HOOKS \ | | 52 | NETBSD_RELEASE MAKEROOT_HOOKS MOUNT_HOOKS UMOUNT_HOOKS \ |
53 | SYNC_UMOUNT AUTO_TARGET AUTO_PACKAGES BUILD_PACKAGES \ | | 53 | SYNC_UMOUNT AUTO_TARGET AUTO_PACKAGES BUILD_PACKAGES \ |
54 | REAL_CCACHE LIBKVER_STANDALONE_PREFIX" | | 54 | REAL_CCACHE LIBKVER_STANDALONE_PREFIX GENERATE_PKG_SUMMARY" |
55 | | | 55 | |
56 | _BUILD_RESUME= | | 56 | _BUILD_RESUME= |
57 | | | 57 | |
58 | # env_clean | | 58 | # env_clean |
59 | # | | 59 | # |
60 | # Sets all variables that may appear in the config file to the null | | 60 | # Sets all variables that may appear in the config file to the null |
61 | # string, so that we know the environment is in a consistent state. | | 61 | # string, so that we know the environment is in a consistent state. |
62 | # | | 62 | # |
63 | env_clean() | | 63 | env_clean() |
64 | { | | 64 | { |
65 | MKCONF_VARS="" | | 65 | MKCONF_VARS="" |
66 | TEMPLATE_VARS="" | | 66 | TEMPLATE_VARS="" |
67 | for var in ${_MKCONF_VARS} ${_TEMPLATE_VARS}; do | | 67 | for var in ${_MKCONF_VARS} ${_TEMPLATE_VARS}; do |
| @@ -116,26 +116,27 @@ env_setdefaults() | | | @@ -116,26 +116,27 @@ env_setdefaults() |
116 | : ${REAL_PKGSRC_OPTS:=-t null -o ro} | | 116 | : ${REAL_PKGSRC_OPTS:=-t null -o ro} |
117 | : ${REAL_DISTFILES:=/usr/pkgsrc/distfiles} | | 117 | : ${REAL_DISTFILES:=/usr/pkgsrc/distfiles} |
118 | : ${REAL_DISTFILES_OPTS:=-t null -o rw} | | 118 | : ${REAL_DISTFILES_OPTS:=-t null -o rw} |
119 | : ${REAL_PACKAGES:=/usr/pkgsrc/packages} | | 119 | : ${REAL_PACKAGES:=/usr/pkgsrc/packages} |
120 | : ${REAL_PACKAGES_OPTS:=-t null -o rw} | | 120 | : ${REAL_PACKAGES_OPTS:=-t null -o rw} |
121 | : ${REAL_PKGVULNDIR:=/usr/pkgsrc/distfiles} | | 121 | : ${REAL_PKGVULNDIR:=/usr/pkgsrc/distfiles} |
122 | : ${NETBSD_RELEASE:=no} | | 122 | : ${NETBSD_RELEASE:=no} |
123 | : ${LIBKVER_STANDALONE_PREFIX:=/libkver} | | 123 | : ${LIBKVER_STANDALONE_PREFIX:=/libkver} |
124 | : ${MAKEROOT_HOOKS:=} | | 124 | : ${MAKEROOT_HOOKS:=} |
125 | : ${MOUNT_HOOKS:=} | | 125 | : ${MOUNT_HOOKS:=} |
126 | : ${UMOUNT_HOOKS:=} | | 126 | : ${UMOUNT_HOOKS:=} |
127 | : ${SYNC_UMOUNT:=no} | | 127 | : ${SYNC_UMOUNT:=no} |
128 | : ${REAL_CCACHE:=} | | 128 | : ${REAL_CCACHE:=} |
| | | 129 | : ${GENERATE_PKG_SUMMARY:=yes} |
129 | | | 130 | |
130 | if [ -n "${MAKE_PACKAGES}" ]; then | | 131 | if [ -n "${MAKE_PACKAGES}" ]; then |
131 | warn "MAKE_PACKAGES is deprecated; use {AUTO,BUILD}_PACKAGES instead." | | 132 | warn "MAKE_PACKAGES is deprecated; use {AUTO,BUILD}_PACKAGES instead." |
132 | : ${AUTO_PACKAGES:=${MAKE_PACKAGES}} | | 133 | : ${AUTO_PACKAGES:=${MAKE_PACKAGES}} |
133 | : ${BUILD_PACKAGES:=${MAKE_PACKAGES}} | | 134 | : ${BUILD_PACKAGES:=${MAKE_PACKAGES}} |
134 | fi | | 135 | fi |
135 | | | 136 | |
136 | if [ -n "${MOUNT_SCRIPT}" ]; then | | 137 | if [ -n "${MOUNT_SCRIPT}" ]; then |
137 | warn "MOUNT_SCRIPT is deprecated; use MOUNT_HOOKS instead." | | 138 | warn "MOUNT_SCRIPT is deprecated; use MOUNT_HOOKS instead." |
138 | : ${MOUNT_HOOKS:=${MOUNT_SCRIPT}} | | 139 | : ${MOUNT_HOOKS:=${MOUNT_SCRIPT}} |
139 | fi | | 140 | fi |
140 | | | 141 | |
141 | if [ -n "${UMOUNT_SCRIPT}" ]; then | | 142 | if [ -n "${UMOUNT_SCRIPT}" ]; then |
| @@ -678,26 +679,38 @@ pkg_auto() | | | @@ -678,26 +679,38 @@ pkg_auto() |
678 | makeroot | | 679 | makeroot |
679 | | | 680 | |
680 | [ "$nflag" = "no" -a -n "$INSTALL_PACKAGES" ] && | | 681 | [ "$nflag" = "no" -a -n "$INSTALL_PACKAGES" ] && |
681 | pkg_install $INSTALL_PACKAGES | | 682 | pkg_install $INSTALL_PACKAGES |
682 | | | 683 | |
683 | echo ${pkgs} | tr ' ' '\n' > ${rfile} | | 684 | echo ${pkgs} | tr ' ' '\n' > ${rfile} |
684 | fi | | 685 | fi |
685 | | | 686 | |
686 | checkroot | | 687 | checkroot |
687 | _BUILD_RESUME=${rfile} BUILD_TARGET=${target} pkg_build ${pkgs} | | 688 | _BUILD_RESUME=${rfile} BUILD_TARGET=${target} pkg_build ${pkgs} |
688 | pkg_removeroot | | 689 | pkg_removeroot |
689 | } | | 690 | } |
690 | | | 691 | |
| | | 692 | # generate_pkg_summary directory |
| | | 693 | # |
| | | 694 | # Generates a pkg_summary.gz file in the specified directory. |
| | | 695 | generate_pkg_summary() |
| | | 696 | { |
| | | 697 | local directory="${1}"; shift |
| | | 698 | |
| | | 699 | echo "PKG_COMP ==> Generating pkg_summary.tgz" |
| | | 700 | for pkg in "${directory}"/*.tgz; do pkg_info -X "${pkg}"; done \ |
| | | 701 | | gzip -c >"${directory}"/pkg_summary.gz |
| | | 702 | } |
| | | 703 | |
691 | # ---------------------------------------------------------------------- | | 704 | # ---------------------------------------------------------------------- |
692 | # build target | | 705 | # build target |
693 | # ---------------------------------------------------------------------- | | 706 | # ---------------------------------------------------------------------- |
694 | | | 707 | |
695 | # pkg_build pkgs | | 708 | # pkg_build pkgs |
696 | # | | 709 | # |
697 | # The build target. Also used as a helper function within this script | | 710 | # The build target. Also used as a helper function within this script |
698 | # to build several packages when needed. | | 711 | # to build several packages when needed. |
699 | # | | 712 | # |
700 | pkg_build() | | 713 | pkg_build() |
701 | { | | 714 | { |
702 | local failed invalid p pkgs script statfile | | 715 | local failed invalid p pkgs script statfile |
703 | | | 716 | |
| @@ -743,26 +756,29 @@ EOF | | | @@ -743,26 +756,29 @@ EOF |
743 | elif [ -n "${_BUILD_RESUME}" ]; then | | 756 | elif [ -n "${_BUILD_RESUME}" ]; then |
744 | grep -v "^${p}\$" < ${_BUILD_RESUME} > ${_BUILD_RESUME}.new | | 757 | grep -v "^${p}\$" < ${_BUILD_RESUME} > ${_BUILD_RESUME}.new |
745 | mv ${_BUILD_RESUME}.new ${_BUILD_RESUME} | | 758 | mv ${_BUILD_RESUME}.new ${_BUILD_RESUME} |
746 | fi | | 759 | fi |
747 | done | | 760 | done |
748 | fsumount | | 761 | fsumount |
749 | if [ -n "$failed" ]; then | | 762 | if [ -n "$failed" ]; then |
750 | echo "PKG_COMP ==> Build error summary" | | 763 | echo "PKG_COMP ==> Build error summary" |
751 | echo "Build failed for:" | | 764 | echo "Build failed for:" |
752 | for p in $failed; do | | 765 | for p in $failed; do |
753 | echo " $p" | | 766 | echo " $p" |
754 | done | | 767 | done |
755 | fi | | 768 | fi |
| | | 769 | if [ "${GENERATE_PKG_SUMMARY}" = yes ]; then |
| | | 770 | generate_pkg_summary "${REAL_PACKAGES}/All" |
| | | 771 | fi |
756 | } | | 772 | } |
757 | | | 773 | |
758 | # find_pkg name | | 774 | # find_pkg name |
759 | # | | 775 | # |
760 | # Checks if the given package exists and outputs its path within pkgsrc. | | 776 | # Checks if the given package exists and outputs its path within pkgsrc. |
761 | # Outputs nothing if the package is not found. | | 777 | # Outputs nothing if the package is not found. |
762 | find_pkg() | | 778 | find_pkg() |
763 | { | | 779 | { |
764 | local name="${1}" | | 780 | local name="${1}" |
765 | | | 781 | |
766 | case "${name}" in | | 782 | case "${name}" in |
767 | */*) | | 783 | */*) |
768 | if [ -d "${REAL_PKGSRC}/${name}" ]; then | | 784 | if [ -d "${REAL_PKGSRC}/${name}" ]; then |