├── COPYING ├── src ├── include │ ├── image.common.d │ │ └── shared │ ├── image.common.el5.d │ │ └── includes │ ├── image.common.el6.d │ │ └── includes │ ├── image.common.el7.d │ │ └── includes │ ├── image.common.el.d │ │ ├── grub │ │ ├── docker │ │ ├── unfs │ │ ├── zfs │ │ ├── cvmfs │ │ ├── xcat │ │ ├── mongodb │ │ ├── rinse │ │ ├── KVM │ │ ├── additional_packages │ │ ├── ofed │ │ ├── lustre │ │ ├── chos │ │ ├── cleanup │ │ ├── shared │ │ └── generate_image │ ├── image_mgr_core.d │ │ ├── stats │ │ ├── scm │ │ ├── addon │ │ ├── util │ │ ├── shared │ │ └── args │ └── image_mgr.pre ├── image-specific │ └── include │ │ ├── README │ │ └── image.example.d │ │ ├── defs │ │ └── do_create ├── site-specific │ └── include │ │ └── README └── image_mgr.sh ├── AUTHORS ├── ChangeLog ├── NOTICE ├── LICENSE ├── NEWS └── README.md /COPYING: -------------------------------------------------------------------------------- 1 | LICENSE -------------------------------------------------------------------------------- /src/include/image.common.d/shared: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/image-specific/include/README: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/site-specific/include/README: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/image-specific/include/image.example.d/defs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | * Larry Pezzaglia 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2015-01-13 Larry Pezzaglia 2 | 3 | * 0.13.0 release 4 | 5 | 2014-10-03 Larry Pezzaglia 6 | 7 | * 0.12.5 release 8 | 9 | 2014-09-29 Larry Pezzaglia 10 | 11 | * 0.12.4 release 12 | 13 | 2014-08-01 Larry Pezzaglia 14 | 15 | * 0.12.3 release 16 | 17 | 2014-04-17 Larry Pezzaglia 18 | 19 | * 0.12.2 release 20 | 21 | 2014-02-14 Larry Pezzaglia 22 | 23 | * 0.12.1 release 24 | 25 | 2014-01-29 Larry Pezzaglia 26 | 27 | * 0.12.0 release 28 | 29 | 2013-10-22 Larry Pezzaglia 30 | 31 | * Initial release 32 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Auto-Versioning Systems Image Manager, Copyright (c) 2013, The Regents 2 | of the University of California, through Lawrence Berkeley National 3 | Laboratory (subject to receipt of any required approvals from the U.S. 4 | Dept. of Energy). All rights reserved. 5 | 6 | If you have questions about your rights to use or distribute this 7 | software, please contact Berkeley Lab's Technology Transfer Department 8 | at TTD@lbl.gov. 9 | 10 | NOTICE. This software is owned by the U.S. Department of Energy. As 11 | such, the U.S. Government has been granted for itself and others 12 | acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | license in the Software to reproduce, prepare derivative works, and 14 | perform publicly and display publicly. Beginning five (5) years after 15 | the date permission to assert copyright is obtained from the U.S. 16 | Department of Energy, and subject to any subsequent five (5) year 17 | renewals, the U.S. Government is granted for itself and others acting 18 | on its behalf a paid-up, nonexclusive, irrevocable, worldwide license 19 | in the Software to reproduce, prepare derivative works, distribute 20 | copies to the public, perform publicly and display publicly, and to 21 | permit others to do so. 22 | -------------------------------------------------------------------------------- /src/include/image.common.el5.d/includes: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | load_functions include/image.common.el.d/ 24 | 25 | -------------------------------------------------------------------------------- /src/include/image.common.el6.d/includes: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | load_functions include/image.common.el.d/ 24 | 25 | -------------------------------------------------------------------------------- /src/include/image.common.el7.d/includes: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | load_functions include/image.common.el.d/ 24 | 25 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/grub: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | # Install the GRUB bootloader 25 | setup_install_grub () { 26 | $YUM install grub 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/docker: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | # Create an add-on for Docker 24 | _create_addon_docker () { 25 | $YUM install docker-io 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/image-specific/include/image.example.d/do_create: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | # Example image_specialize function 24 | image_specialize() { 25 | run_step build_prep 26 | 27 | run_step setup_yum_repos 28 | 29 | run_step cleanup 30 | } 31 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/unfs: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | # Create an add-on for the userspace NFS server. 24 | _create_addon_unfs () { 25 | m4 $IMAGEFILES/image_mgr.unfs.repo.m4 > \ 26 | $ADDONROOT/etc/yum.repos.d/image_mgr.unfs.repo 27 | 28 | $YUM install unfs3 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/zfs: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | _create_addon_zfs_0_6_2 () { 25 | _addon_zfs 0.6.2 "$@" 26 | } 27 | 28 | _addon_zfs () { 29 | __add_zfs "$@" 30 | } 31 | 32 | __add_zfs () { 33 | _ZFSVERSION=$1 34 | shift 35 | 36 | m4 -DZFSVERSION="${_ZFSVERSION}" -DZFSKERNEL="${KERNEL_NOARCH}" $IMAGEFILES/image_mgr.zfs.repo.m4 > $ADDONROOT/etc/yum.repos.d/zfs.repo 37 | 38 | $YUM --enablerepo=sl-addons-64 install kmod-zfs kmod-spl zfs 39 | } 40 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/cvmfs: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | _create_addon_cvmfs () { 24 | 25 | [ -d $ADDONROOT/chos ] || mkdir $ADDONROOT/chos 26 | [ -d $ADDONROOT/chos/cvmfs ] || mkdir $ADDONROOT/chos/cvmfs 27 | [ -d $ADDONROOT/etc/cvmfs ] || mkdir $ADDONROOT/etc/cvmfs 28 | ln -s /chos/cvmfs $ADDONROOT/cvmfs 29 | 30 | echo 'user_allow_other # added by CernVM-FS' >> $ADDONROOT/etc/fuse.conf 31 | 32 | $YUM install http://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/EL/6/x86_64/cvmfs-release-2-4.el6.noarch.rpm 33 | $YUM install cvmfs cvmfs-keys cvmfs-init-scripts 34 | 35 | # TODO 36 | #rm -f $ADDONROOT/bin/cgexec 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/xcat: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | _create_addon_xcat_2_7_7_201212210343 () { 24 | _addon_xcat 2.7.7 201212210343 "$@" 25 | } 26 | 27 | 28 | _addon_xcat () { 29 | _XCAT_VERSION=$1 30 | shift 31 | _XCAT_DEP_SNAP_VERSION=$1 32 | shift 33 | 34 | m4 -DXCAT_VERSION="${_XCAT_VERSION}" -DsnapXCAT_DEP_SNAP_VERSION="snap${_XCAT_DEP_SNAP_VERSION}" $IMAGEFILES/image_mgr.xcat.repo.m4 > $ADDONROOT/etc/yum.repos.d/image_mgr.xcat.repo 35 | 36 | # Install xCAT and dependencies 37 | # perl-DBD-Pg is required to talk to an xCAT postgres database 38 | # perl-Sys-Virt is required for xCAT to control libvirt-based VM hosts 39 | $YUM install perl-DBD-Pg perl-Sys-Virt 40 | 41 | $YUM install --tsflags noscripts install xCAT 42 | 43 | } 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/mongodb: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | _create_addon_mongodb () { 25 | /bin/cp -v $IMAGEFILES/repo.10gen.sl6/* $ADDONROOT/etc/yum.repos.d/ 26 | $YUM install mongo-10gen-2.2.3-mongodb_1.x86_64 mongo-10gen-server-2.2.3-mongodb_1.x86_64 27 | } 28 | 29 | _create_addon_mongodb_225 () { 30 | /bin/cp -v $IMAGEFILES/repo.10gen.sl6/* $ADDONROOT/etc/yum.repos.d/ 31 | $YUM install mongo-10gen-2.2.5-mongodb_1.x86_64 mongo-10gen-server-2.2.5-mongodb_1.x86_64 32 | } 33 | 34 | _create_addon_mongodb_243 () { 35 | /bin/cp -v $IMAGEFILES/repo.10gen.sl6/* $ADDONROOT/etc/yum.repos.d/ 36 | $YUM install mongo-10gen-2.4.3-mongodb_1.x86_64 mongo-10gen-server-2.4.3-mongodb_1.x86_64 37 | } 38 | 39 | _create_addon_mongodb_2410 () { 40 | /bin/cp -v $IMAGEFILES/repo.10gen.sl6/* $ADDONROOT/etc/yum.repos.d/ 41 | $YUM install mongo-10gen-2.4.10-mongodb_1.x86_64 mongo-10gen-server-2.4.10-mongodb_1.x86_64 42 | } 43 | 44 | _create_addon_mongodb_263 () { 45 | /bin/cp -v $IMAGEFILES/repo.10gen.sl6/* $ADDONROOT/etc/yum.repos.d/ 46 | $YUM install mongodb-org-2.6.3-1.x86_64 mongodb-org-server-2.6.3-1.x86_64 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | "Auto-Versioning Systems Image Manager, Copyright (c) 2013, The Regents of 2 | the University of California, through Lawrence Berkeley National Laboratory 3 | (subject to receipt of any required approvals from the U.S. Dept. of 4 | Energy). All rights reserved." 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | (1) Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | (2) Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | (3) Neither the name of the University of California, Lawrence Berkeley 17 | National Laboratory, U.S. Dept. of Energy nor the names of its contributors 18 | may be used to endorse or promote products derived from this software 19 | without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | You are under no obligation whatsoever to provide any bug fixes, patches, 34 | or upgrades to the features, functionality or performance of the source 35 | code ("Enhancements") to anyone; however, if you choose to make your 36 | Enhancements available either publicly, or directly to Lawrence Berkeley 37 | National Laboratory, without imposing a separate written license agreement 38 | for such Enhancements, then you hereby grant the following license: a 39 | non-exclusive, royalty-free perpetual license to install, use, modify, 40 | prepare derivative works, incorporate into other computer software, 41 | distribute, and sublicense such enhancements or derivative works thereof, 42 | in binary and source code form. 43 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | avs_image_mgr 0.13.0 2015-01-13 2 | ====================================== 3 | * Loop-mounted ext4 filesystems are now used for image and addon 4 | builds. 5 | * Experimental support for using "rinse" as an image building 6 | backend (by setting IMAGE_BACKEND=rinse). 7 | * Separate logs are now kept from each addon and image build step. 8 | * Verbosity to stdout is greatly decreased. 9 | * All environment variables except PATH and TERM are now dropped 10 | during avs_image_mgr startup 11 | * Fixed a bug in the xCAT addon generation script which could cause 12 | image builds to hang indefinitely during certificate generation. 13 | * In EL images, all services are disabled by default. 14 | * Numerous code cleanups and error handling improvements. An attempt 15 | is now made to print out the full environment and grep out the 16 | lines being executed in each frame. 17 | * Add quick start guide. 18 | * Add an example image configuration. 19 | 20 | avs_image_mgr 0.12.5 2014-10-03 21 | ====================================== 22 | * Prune locales after every yum invocation. 23 | This should prevent subsequent package installations 24 | from placing unwanted locales in the image. 25 | 26 | avs_image_mgr 0.12.4 2014-09-29 27 | ====================================== 28 | * Immediately upgrade all packages after YUM repos have been 29 | configured. This should prevent issues in old packages from 30 | triggering problems later in the build. 31 | 32 | avs_image_mgr 0.12.3 2014-08-01 33 | ====================================== 34 | * Add support for Lustre 2.5.2 35 | * Add support for Docker 36 | * Add support for a new flag: -n. If -n is passed, only the base 37 | image will be built. 38 | * Add support for the case case were no kernel modules are present 39 | * Allow specifying additional OFED RPMs to newer mlnx_ofed add-ons 40 | through the OFED_RPMS environment variable 41 | 42 | avs_image_mgr 0.12.2 2014-04-17 43 | ====================================== 44 | * Improvements to error reporting 45 | * Improvements to bind mount handling 46 | * Add support for MLNX_OFED 2.1-1.1.0, Lustre 2.4.2, MongoDB 47 | 2.4.10, and unfsd, the userspace NFS server daemon 48 | * Add support for dm-multipath 49 | 50 | avs_image_mgr 0.12.1 2014-02-14 51 | ====================================== 52 | * Fixed a bug where yum would be invoked incorrectly if 53 | $YUM_EXTRA_ARGS was left at its default value of 54 | the empty string 55 | 56 | avs_image_mgr 0.12.0 2014-01-29 57 | ====================================== 58 | * Build the image in a separate mount namespace 59 | * Use built-in pkglist to avoid relying on the correctness of a 60 | manually installed pkglist 61 | * Add support for kernel variants 62 | * Add support for EL7beta 63 | * Overall code cleanups 64 | 65 | avs_image_mgr 0.11.0 2013-10-22 66 | ====================================== 67 | * Initial release 68 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/rinse: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | 25 | # generate_image_rinse [rootimgdir] [pkglist] 26 | # Create an image using the rinse backend. 27 | generate_image_rinse () { 28 | 29 | local _ROOTIMGDIR="$1"; shift 30 | local _PKGLIST="$1"; shift 31 | 32 | 33 | # Set up our temporary rinse configuration file. 34 | # Assume we have already been provided with a dedicated rinse 35 | # configuration area. 36 | cat >> "$RINSE_CONF" << EOF 37 | [image_mgr] 38 | mirror.${ARCH} = $(pkg_url) 39 | EOF 40 | 41 | rinse \ 42 | --verbose \ 43 | --cache 0 \ 44 | --distribution image_mgr \ 45 | --arch $ARCH \ 46 | --directory "${_ROOTIMGDIR}/rootimg/" 47 | 48 | case $OS_MAJOR_VERSION in 49 | SL5 ) 50 | { 51 | cd "${_ROOTIMGDIR}/rootimg/" 52 | wget http://mirror.mcs.anl.gov/pub/scientific-linux/55/x86_64/SL/yum-conf-55-1.SL.noarch.rpm -O conf.rpm 53 | rpm2cpio conf.rpm | cpio -idv 54 | cd - 55 | } 56 | ;; 57 | esac 58 | 59 | target_mkdir /var/lib/rpm 60 | 61 | rm -f "${_ROOTIMGDIR}/rootimg/var/lib/rpm/"* 62 | 63 | $RPM --initdb 64 | $RPM --rebuilddb 65 | 66 | touch "${_ROOTIMGDIR}/rootimg/etc/mtab" 67 | 68 | # Install the RPMs provided by rinse 69 | # This is necessary since we are running without rinse's default 70 | # post-install scripts. 71 | $RPM -i --nodeps "${_ROOTIMGDIR}"/rootimg/\''*rpm'\' 72 | $YUM clean all 73 | $YUM update 74 | $YUM check 75 | 76 | $YUM upgrade "${_ROOTIMGDIR}"/rootimg/*rpm 77 | 78 | # Remove the RPMs put in place by rinse 79 | rm -f "${_ROOTIMGDIR}"/rootimg/*rpm 80 | 81 | # Ensure no kernel package is installed 82 | $RPM -e --nodeps kernel &>/dev/null || /bin/true 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/KVM: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | _create_addon_kvm () { 24 | 25 | # Add repository for modified iPXE with customized 26 | # embedded script. 27 | cat > $ADDONROOT/etc/yum.repos.d/ipxe.repo << 'EOF' 28 | [ipxe] 29 | name=ipxe 30 | baseurl=file:///install/rpms/scientific/6.2/x86_64/ipxe.el6 31 | enabled=1 32 | gpgcheck=0 33 | EOF 34 | #$YUM install kvm libvirtd perl-Sys-Virt 35 | #$YUM install kvm perl-Sys-Virt libvirt bridge-utils dnsmasq iscsi-initiator-utils kvm gpxe-kvm 36 | 37 | $YUM install kvm perl-Sys-Virt libvirt bridge-utils kvm ipxe-roms-qemu screen 38 | 39 | #in_target chkconfig kvm off 40 | #in_target chkconfig libvirt off 41 | 42 | # Create a wrapper script for qemu-kvm to force-enable specific 43 | # options. We use this to load the SGABIOS option ROM to interact 44 | # with the BIOS via the serial console. 45 | 46 | # It would be better to modify the xCAT KVM plugin to 47 | # handle this in an integrated fashion. 48 | 49 | # This seems better than maintaining our own KVM RPMs. 50 | # Unfortunately, RPM does not appear to have a feature equivalent 51 | # to DPKG diversions 52 | 53 | # The final version of /usr/libexec/qemu-kvm-wrapper should be provided at 54 | # boot time. We provide a basic version here so that libvirtd will start 55 | # properly. 56 | 57 | 58 | cp -f $ADDONROOT/usr/libexec/qemu-kvm $ADDONROOT/usr/libexec/qemu-kvm.real 59 | 60 | rm -f $ADDONROOT/usr/libexec/qemu-kvm 61 | 62 | cat > $ADDONROOT/usr/libexec/qemu-kvm-wrapper << 'EOF' 63 | #!/bin/sh 64 | echo 'QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2), Copyright (c) 2003-2008 Fabrice Bellard' 65 | EOF 66 | chmod +x $ADDONROOT/usr/libexec/qemu-kvm-wrapper 67 | 68 | ln -s /usr/libexec/qemu-kvm-wrapper $ADDONROOT/usr/libexec/qemu-kvm 69 | 70 | # TODO 71 | #rm -f $ADDONROOT/bin/cgexec 72 | } 73 | 74 | -------------------------------------------------------------------------------- /src/include/image_mgr_core.d/stats: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | print_setuid() { 24 | echo "setuid files:" 25 | cd $IMGROOT && find . -xdev -perm /u+s -print0 |xargs -0 ls -ld 26 | 27 | echo "setgid files:" 28 | cd $IMGROOT && find . -xdev -perm /g+s -print0 |xargs -0 ls -ld 29 | } 30 | 31 | 32 | print_stats () { 33 | cd $IMG_BASE_DIR/markers 34 | printf "%30s" "PROCEDURE NAME" 35 | printf "%10s" "TIME" 36 | printf "%10s" "+/- RPMS" 37 | printf "%10s" "+/- SIZE" 38 | printf "%10s" "RPMS" 39 | printf "%10s" "SIZE" 40 | echo 41 | 42 | TOTAL_TIME=0 43 | TOTAL_SIZE=0 44 | TOTAL_RPMS=0 45 | 46 | for NAME in `ls -1tr *complete`; do 47 | SHORT_NAME=${NAME%%-complete} 48 | TIME=$(cat ${NAME}.time) 49 | 50 | if [ ! -f ${NAME}.rpms-pre ]; then 51 | RPMS_PRE=0 52 | else 53 | RPMS_PRE=$(wc -l ${NAME}.rpms-pre | awk '{print $1}') 54 | fi 55 | if [ ! -f ${NAME}.size-pre ]; then 56 | SIZE_PRE=0 57 | else 58 | SIZE_PRE=$(cat ${NAME}.size-pre | awk '{print $1}') 59 | fi 60 | if [ -f ${NAME}.rpms-post ] ; then 61 | RPMS_POST=$(wc -l ${NAME}.rpms-post | awk '{print $1}') 62 | RPMS_CHANGED=$(echo "${RPMS_POST}-0${RPMS_PRE}" | bc) 63 | else 64 | RPMS_CHANGED=0 65 | fi 66 | SIZE_POST=$(cat ${NAME}.size-post | awk '{print $1}') 67 | SIZE_CHANGED=$(echo "${SIZE_POST}-0${SIZE_PRE}" | bc) 68 | TOTAL_TIME="$(echo ${TOTAL_TIME}+${TIME} | bc)" 69 | TOTAL_SIZE="$(echo ${TOTAL_SIZE}+${SIZE_CHANGED}| bc)" 70 | TOTAL_RPMS="$(echo ${TOTAL_RPMS}+${RPMS_CHANGED} | bc)" 71 | 72 | printf "%30s" "${SHORT_NAME}" 73 | printf "%10s" "${TIME}s" 74 | printf "%10s" "${RPMS_CHANGED}" 75 | printf "%10s" "${SIZE_CHANGED}M" 76 | printf "%10s" "${TOTAL_RPMS}" 77 | printf "%10s" "${TOTAL_SIZE}M" 78 | echo 79 | 80 | done 81 | 82 | printf "%30s" "TOTAL" 83 | printf "%10s" "${TOTAL_TIME}s" 84 | printf "%10s" "${TOTAL_RPMS}" 85 | printf "%10s" "${TOTAL_SIZE}M" 86 | printf "%10s" "${TOTAL_RPMS}" 87 | printf "%10s" "${TOTAL_SIZE}M" 88 | echo 89 | } 90 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/additional_packages: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | additional_packages_default() { 24 | cat << EOF | tr -d ' ' | sed -e '/^\(#\|$\)/d' | tr '\n' ' ' 25 | # Disable colorls by default. colorls will stat every file in a 26 | # directory being ls'd in order to colorize them, which can 27 | # introduce difficulty and confusion when investigating 28 | # filesystem problems 29 | SL_no_colorls 30 | 31 | audit 32 | crontabs 33 | 34 | # CPU frequency settings 35 | cpufrequtils 36 | cpuspeed 37 | i7z 38 | 39 | dhclient 40 | iperf 41 | iptables 42 | libcgroup 43 | lsof 44 | lvm2 45 | man 46 | nc 47 | numactl 48 | psacct 49 | 50 | # Workload generator 51 | stress 52 | 53 | tcpdump 54 | tcsh 55 | telnet 56 | traceroute 57 | 58 | # Useful for debugging and diagnostics 59 | dmidecode 60 | pciutils 61 | strace 62 | mcelog 63 | 64 | # rsync is required for xCAT syncfiles 65 | rsync 66 | 67 | # Install attr to get and manipulate extended attributes 68 | # (Required for XRootD) 69 | attr 70 | 71 | # openssl and wget are needed by /opt/xcat/xcatdsklspost 72 | # to download postscripts. 73 | # (Busybox wget does not seem to have the required features.) 74 | openssl 75 | wget 76 | 77 | # Add multipath support 78 | device-mapper-multipath 79 | EOF 80 | 81 | ( 82 | case $OS_FAMILY in 83 | el5 ) 84 | echo nss_ldap 85 | echo smartmontools 86 | echo sysklogd 87 | ;; 88 | el[67] ) 89 | echo binutils 90 | echo cronie-noanacron 91 | echo nss-pam-ldapd 92 | echo portreserve 93 | echo rsyslog 94 | echo smartmontools 95 | 96 | # Minimal replacement for glibc nscd 97 | echo unscd 98 | ;; 99 | esac 100 | ) | tr -d ' ' | sed -e '/^\(#\|$\)/d' | tr '\n' ' ' 101 | } 102 | 103 | # Provide the path to genimage 104 | provide_additional_package_list () { 105 | additional_packages_${ADDITIONAL_PACKAGES_LIST_PROVIDER} 106 | } 107 | 108 | setup_additional_packages () { 109 | $YUM clean all 110 | $YUM install $(provide_additional_package_list) 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/ofed: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | _create_addon_ofed() { 24 | case $OS_FAMILY in 25 | el5 ) 26 | error "OFED not supported on pdsf-el5" 27 | ;; 28 | el6 ) 29 | /bin/cp -v $IMAGEFILES/repo.ofed.sl6/* $ADDONROOT/etc/yum.repos.d/ 30 | OFED_MINIMAL_RPMS="ofed-scripts libibverbs libibverbs-utils libmthca libmlx4 libcxgb3 libcxgb4 libnes libipathverbs libibverbs-devel librdmacm librdmacm-utils mstflint kernel-ib" 31 | OFED_RPMS="$OFED_MINIMAL_RPMS" 32 | $YUM install $OFED_RPMS 33 | cp -v $IMAGEFILES/etc/infiniband/openib.conf $ADDONROOT/etc/infiniband/ 34 | in_target chkconfig openibd off 35 | ;; 36 | esac 37 | } 38 | 39 | _create_addon_mlnx_ofed() { 40 | case $OS_FAMILY in 41 | el5 ) 42 | error "OFED not supported on el5" 43 | ;; 44 | el6 ) 45 | m4 -DKRNL=$KERNEL_NOARCH $IMAGEFILES/image_mgr.mlnx_ofed-1.5.3-3.1.0.repo.m4 > $ADDONROOT/etc/yum.repos.d/image_mgr.mlnx_ofed-1.5.3-3.1.0.repo 46 | cat $ADDONROOT/etc/yum.repos.d/image_mgr.mlnx_ofed-1.5.3-3.1.0.repo 47 | OFED_MINIMAL_RPMS="ofed-scripts libibverbs libibverbs-utils libmthca libmlx4 libcxgb3 libcxgb4 libnes libipathverbs libibverbs-devel librdmacm librdmacm-utils mstflint kernel-ib opensm" 48 | OFED_RPMS="$OFED_MINIMAL_RPMS infiniband-diags ibutils2 perftest" 49 | $YUM install $OFED_RPMS 50 | cp -v $IMAGEFILES/etc/infiniband/openib.conf $ADDONROOT/etc/infiniband/ 51 | in_target chkconfig openibd off 52 | sed -i -e '/^.*lro.*$/d' ${ADDONROOT}/etc/modprobe.d/ib_ipoib.conf 53 | ;; 54 | esac 55 | 56 | mv $ADDONROOT/usr/bin/ibdiagnet $ADDONROOT/usr/bin/ibdiagnet.cfdisabled 57 | chmod 600 $ADDONROOT/usr/bin/ibdiagnet.cfdisabled 58 | } 59 | 60 | _create_addon_mlnx_ofed_20_205() { 61 | __add_mlnx_ofed 2.0-2.0.5 "$@" 62 | 63 | # Install customized version of mlnx_affinity 64 | install -o root -g root -m 700 $IMAGEFILES/usr/sbin/mlnx_affinity \ 65 | $ADDONROOT/usr/sbin/mlnx_affinity 66 | } 67 | 68 | _create_addon_mlnx_ofed_20_300() { 69 | __add_mlnx_ofed 2.0-3.0.0 "$@" 70 | } 71 | 72 | _create_addon_mlnx_ofed_21_100() { 73 | __add_mlnx_ofed 2.1-1.0.0 "$@" 74 | } 75 | 76 | __add_mlnx_ofed() { 77 | 78 | MOFED_VERSION="$1" 79 | shift 80 | 81 | case $OS_FAMILY in 82 | el5 ) 83 | error "MOFED not supported on el5" 84 | ;; 85 | el6 ) 86 | m4 -DKRNL=$KERNEL_NOARCH $IMAGEFILES/image_mgr.mlnx_ofed-${MOFED_VERSION}.repo.m4 > $ADDONROOT/etc/yum.repos.d/image_mgr.mlnx_ofed-${MOFED_VERSION}.repo 87 | OFED_MINIMAL_RPMS="ofed-scripts libibverbs libibverbs-utils libmthca libmlx4 libcxgb3 libcxgb4 libnes libipathverbs libibverbs-devel librdmacm librdmacm-utils mstflint kernel-ib opensm" 88 | OFED_RPMS="${OFED_RPMS:-} $OFED_MINIMAL_RPMS infiniband-diags ibutils2 perftest" 89 | $YUM install $OFED_RPMS 90 | install -o root -g root -m 644 $IMAGEFILES/etc/infiniband/openib.conf $ADDONROOT/etc/infiniband/ 91 | sed -i -e '/^.*lro.*$/d' ${ADDONROOT}/etc/modprobe.d/ib_ipoib.conf 92 | ;; 93 | esac 94 | 95 | 96 | mv $ADDONROOT/usr/bin/ibdiagnet $ADDONROOT/usr/bin/ibdiagnet.cfdisabled 97 | chmod 600 $ADDONROOT/usr/bin/ibdiagnet.cfdisabled 98 | } 99 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/lustre: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | _create_addon_lustre_client_2_4_0 () { 24 | _addon_lustre client none 2.4.0 "$@" 25 | } 26 | 27 | _create_addon_lustre_server_2_4_0 () { 28 | _addon_lustre server none 2.4.0 "$@" 29 | } 30 | 31 | 32 | _create_addon_lustre_client_2_4_0_mlnx_ofed_20_205 () { 33 | _addon_lustre client mlnx_ofed-2.0-2.0.5 2.4.0 "$@" 34 | } 35 | 36 | _create_addon_lustre_server_2_4_0_mlnx_ofed_20_205 () { 37 | _addon_lustre server mlnx_ofed-2.0-2.0.5 2.4.0 "$@" 38 | } 39 | 40 | _create_addon_lustre_client_2_4_1 () { 41 | _addon_lustre client none 2.4.1 "$@" 42 | } 43 | 44 | _create_addon_lustre_server_2_4_1 () { 45 | _addon_lustre server none 2.4.1 "$@" 46 | } 47 | 48 | 49 | _create_addon_lustre_client_2_4_1_mlnx_ofed_20_205 () { 50 | _addon_lustre client mlnx_ofed-2.0-2.0.5 2.4.1 "$@" 51 | } 52 | 53 | _create_addon_lustre_server_2_4_1_mlnx_ofed_20_205 () { 54 | _addon_lustre server mlnx_ofed-2.0-2.0.5 2.4.1 "$@" 55 | } 56 | 57 | _create_addon_lustre_client_2_4_1_mlnx_ofed_20_300 () { 58 | _addon_lustre client mlnx_ofed-2.0-3.0.0 2.4.1 "$@" 59 | } 60 | 61 | _create_addon_lustre_server_2_4_1_mlnx_ofed_20_300 () { 62 | _addon_lustre server mlnx_ofed-2.0-3.0.0 2.4.1 "$@" 63 | } 64 | 65 | _create_addon_lustre_client_2_4_2 () { 66 | _addon_lustre client none 2.4.2 "$@" 67 | } 68 | 69 | _create_addon_lustre_server_2_4_2 () { 70 | _addon_lustre server none 2.4.2 "$@" 71 | } 72 | 73 | 74 | _create_addon_lustre_client_2_4_2_mlnx_ofed_20_205 () { 75 | _addon_lustre client mlnx_ofed-2.0-2.0.5 2.4.2 "$@" 76 | } 77 | 78 | _create_addon_lustre_server_2_4_2_mlnx_ofed_20_205 () { 79 | _addon_lustre server mlnx_ofed-2.0-2.0.5 2.4.2 "$@" 80 | } 81 | 82 | _create_addon_lustre_client_2_4_2_mlnx_ofed_20_300 () { 83 | _addon_lustre client mlnx_ofed-2.0-3.0.0 2.4.2 "$@" 84 | } 85 | 86 | _create_addon_lustre_server_2_4_2_mlnx_ofed_20_300 () { 87 | _addon_lustre server mlnx_ofed-2.0-3.0.0 2.4.2 "$@" 88 | } 89 | 90 | 91 | 92 | _create_addon_lustre_client_2_5_2 () { 93 | _addon_lustre client none 2.5.2 "$@" 94 | } 95 | 96 | _create_addon_lustre_server_2_5_2 () { 97 | _addon_lustre server none 2.5.2 "$@" 98 | } 99 | 100 | _create_addon_lustre_client_2_5_2_mlnx_ofed_21_100 () { 101 | _addon_lustre client mlnx_ofed-2.1-1.0.0 2.5.2 "$@" 102 | } 103 | 104 | _create_addon_lustre_server_2_5_2_mlnx_ofed_21_100 () { 105 | _addon_lustre server mlnx_ofed-2.1-1.0.0 2.5.2 "$@" 106 | } 107 | 108 | 109 | _addon_lustre () { 110 | _LUSTRETYPE=$1 111 | shift 112 | _LUSTREOFED=$1 113 | shift 114 | _LUSTREVERSION=$1 115 | shift 116 | 117 | if [[ "$_LUSTREOFED" == "none" ]]; then 118 | _LUSTRESUFFIX="${_LUSTREVERSION}-${KERNEL_NOARCH}-${_LUSTRETYPE}" 119 | else 120 | _LUSTRESUFFIX="${_LUSTREVERSION}-${KERNEL_NOARCH}-${_LUSTREOFED}-${_LUSTRETYPE}" 121 | fi 122 | 123 | m4 -DLUSTREVERSION="${_LUSTREVERSION}" -DLUSTRESUFFIX="${_LUSTRESUFFIX}" $IMAGEFILES/image_mgr.lustre.repo.m4 > $ADDONROOT/etc/yum.repos.d/lustre.repo 124 | 125 | case $_LUSTRETYPE in 126 | server) 127 | __add_zfs 0.6.2 128 | $YUM install lustre lustre-ldiskfs lustre-iokit lustre-tests lustre-osd-zfs lustre-osd-ldiskfs 129 | ;; 130 | client) 131 | $YUM install lustre 132 | ;; 133 | esac 134 | 135 | } 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/include/image_mgr.pre: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | generic_fail () { 25 | echo "Failure detected" >&2 26 | fail "$@" "Failure detected" 27 | } 28 | 29 | # hr 30 | # Print a horizontal line 31 | hr() { 32 | for _c in $(seq 1 $(tput cols)); do 33 | echo -n '-' 34 | done 35 | echo 36 | } 37 | 38 | fail () { 39 | # Unmount any mounts 40 | _umount_all 41 | 42 | cd "${CWD_ORIG}" 43 | if [ $# -gt 2 ]; then 44 | # Throw away the top frame information, since it is our error 45 | # handling function 46 | _FRAME=1 47 | _FILE="$(basename $0)" 48 | _SRC="$1" 49 | shift 50 | _LINE="$1" 51 | shift 52 | _CODE="$1" 53 | shift 54 | 55 | # If we are in a subshell, just exit 56 | if [ $BASH_SUBSHELL -ne $TOP_SUBSHELL_LEVEL ]; then 57 | echo "*** Error $_CODE in $_SRC near line $_LINE. ***" >&2 58 | exit 1 59 | fi 60 | 61 | echo -e "\n\n" >&2 62 | hr >&2 63 | echo -e "* Environment:" >&2 64 | hr >&2 65 | env >&2 66 | hr >&2 67 | 68 | echo -e "\n\n" >&2 69 | hr >&2 70 | echo -e "* Declarations:" >&2 71 | hr >&2 72 | declare >&2 73 | hr >&2 74 | 75 | echo -e "\n\n" >&2 76 | hr >&2 77 | echo -e "* Call stack:" >&2 78 | hr >&2 79 | while true; do 80 | # Get the information about this frame 81 | _C=($(caller $_FRAME)) || break 82 | 83 | # Get the line, function name, and file name of current 84 | # code location in this frame 85 | _ELINE="${_C[0]}" 86 | _EFUNC="${_C[1]}" 87 | _EFILE="${_C[2]}" 88 | 89 | # Determine how much space we have to print out the 90 | # pertinent lines 91 | _LN="$(($(tput cols)-70))" 92 | [ $_LN -gt 2 ] || _LN=2 93 | 94 | # Print the information about this frame 95 | printf "[%38s] [%-20s] %-${_LN}s\n" \ 96 | "$(echo ${_EFILE}:${_ELINE} | tail -c 37)" \ 97 | "$(echo ${_EFUNC} | cut -c -17)" \ 98 | "$(sed -n ${_ELINE}p ${_EFILE} || echo -n '(no data)' | tr -d '\n')" 99 | _FRAME=$((${_FRAME}+1)) 100 | done >&2 101 | hr >&2 102 | echo -e "\n*** Error $_CODE in $_SRC near line $_LINE. ***\n" >&2 103 | else 104 | echo -e "\n*** Error: ${@} ***\n" >&2 105 | fi 106 | hr >&2 107 | 108 | exit 1 109 | } 110 | 111 | load_functions () { 112 | if [ -d "${1}" ]; then 113 | for _FUNCTIONS in "${1}"/*; do 114 | . $_FUNCTIONS 115 | done 116 | fi 117 | } 118 | 119 | image_mgr_prep () { 120 | # Load core image_mgr functions 121 | load_functions include/image_mgr_core.d/ 122 | 123 | # Load functions that should be useful for all images 124 | load_functions include/image.common.d/ 125 | 126 | } 127 | 128 | image_mgr_specialize() { 129 | # Load functions specific to the OS Family of our image (e.g., el5 or 130 | # el6) 131 | load_functions include/image.common.${OS_FAMILY}.d/ 132 | 133 | # Load functions specific to our OS (e.g., SL6.3) 134 | load_functions include/image.common.${OS}.d/ 135 | 136 | # Load functions specific to our image 137 | load_functions image-specific/include/image.${PROFILE}.d/ 138 | } 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # avs_image_mgr 2 | 3 | ## Introduction 4 | 5 | The Auto-Versioning Systems Image Manager is a set of scripts which 6 | wrap around xCAT and FSVS to facilitate disciplined management of 7 | netboot images for computational systems. 8 | 9 | The interface for avs_image_mgr, and the primary use case, were 10 | presented in detail at the 2013 meeting of the Cray User Group. Details on `avs_image_mgr` use in a production environment are available in the [conference paper](http://cug.org/proceedings/cug2013_proceedings/includes/files/pap184.pdf) and accompanying [slides](http://cug.org/proceedings/cug2013_proceedings/includes/files/pap184-file2.pdf). 11 | 12 | ## Quick Start 13 | 14 | This section details how to set up image_mgr to create a basic xCAT 15 | boot image using avs_image_mgr. 16 | 17 | 1. Install and configure the following prerequisites: 18 | 19 | * A functioning [xCAT](http://xcat.sf.net/) environment. 20 | 21 | * The `tsflags` and `priorities` yum plugins 22 | 23 | * The [FSVS](http://fsvs.tigris.org/) tool for image versioning. 24 | 25 | * A node designated for image building. It is strongly recommended 26 | that you dedicate an xCAT service node for image builds. However, 27 | the xCAT management node can also be used. Currently, only 28 | EL6-based image building nodes are supported. 29 | 30 | 1. Check out image_mgr on your image building node. 31 | 32 | This node can be the xCAT MN, or a sufficiently privileged service 33 | node. For production deployments, a dedicated image building node is 34 | recommended: 35 | 36 | git clone https://github.com/lpezzaglia/avs_image_mgr 37 | 38 | By default, the image will be built and versioned within the 39 | checkout area, so ensure that sufficient space is available. 40 | 41 | 1. Choose a production name, test name, architecture, and OS for the image. `avs_image_mgr` has been most heavily tested with SL6. 42 | 43 | IMAGE_NAME=example.prod 44 | TEST_IMAGE_NAME=example.test 45 | ARCH=x86_64 46 | OS=SL6.3 47 | 48 | 1. Add this image to the xCAT configuration 49 | 50 | for _I in $IMAGE_NAME $TEST_IMAGE_NAME; do 51 | chdef -t osimage ${OS}-${ARCH}-netboot-${_I} \ 52 | provmethod=netboot \ 53 | pkglist=/install/custom/netboot/${OS}/${_I}.pkglist \ 54 | imagetype=linux \ 55 | rootimgdir=/install/netboot/${OS}/${ARCH}/${_I} 56 | done 57 | 58 | 1. Build the image: 59 | 60 | ./image_mgr.sh create -p $IMAGE_NAME -a $ARCH -o $OS -u [your username] -m "Initial build" 61 | 62 | Note that committing the first image build to SVN will take some 63 | time. Subsequent builds with fewer overall changes will commit more 64 | rapidly. 65 | 66 | Upon completion, an image build report will be generated: 67 | 68 | Image rebuild completed at Tue Aug 19 10:26:14 PDT 2014 69 | 70 | Initial build 71 | 72 | 73 | ------------------------------------------------------------------------- 74 | PROCEDURE NAME TIME +/- RPMS +/- SIZE RPMS SIZE 75 | prepare_image_directory 0s 0 0M 0 0M 76 | generate_image 591s 94 426M 94 426M 77 | build_prep 98s 0 0M 94 426M 78 | setup_yum_repos 98s 0 0M 94 426M 79 | cleanup 103s 0 -143M 94 283M 80 | TOTAL 890s 94 283M 94 283M 81 | 82 | Image example.prod created 83 | 84 | 1. Once the image is built to your satisfaction, tag it: 85 | 86 | ./image_mgr.sh tag -p $IMAGE_NAME -a $ARCH -o $OS 87 | 88 | 1. Display all available tags: 89 | 90 | ./image_mgr.sh list-tags -p $IMAGE_NAME -a $ARCH -o $OS 91 | 92 | 1. Pack a tag as the test image using the masquerading (`-x`) feature 93 | 94 | ./image_mgr.sh pack -p $IMAGE_NAME -a $ARCH -o $OS -t [tag name] -x $TEST_IMAGE_NAME 95 | 96 | 1. Ask xCAT to boot a node with the new test image image: 97 | 98 | nodeset [node] netboot=$TEST_IMAGE_NAME 99 | rpower [node] reset 100 | rcons [node] 101 | 102 | 1. Once testing is complete, pack the tag as the production image 103 | 104 | ./image_mgr.sh pack -p $IMAGE_NAME -a $ARCH -o $OS -t [tag name] 105 | 106 | 1. Boot a node with the new production image: 107 | 108 | nodeset [node] netboot=$IMAGE_NAME 109 | ... 110 | 111 | 112 | ### Customizing the base image: 113 | 114 | Customizing the base image is generally performed in two steps: 115 | 116 | 1. Adding new shell functions to any file in: 117 | * `site-specific/include/image.common.d/` 118 | * `site-specific/include/image.common.${OS,OS_FAMILY}.d/` 119 | * `image-specific/include/image.${IMAGE_NAME}.d/` 120 | 121 | 122 | 1. Modifying the do_create() function defined in `image-specific/include/image.${IMAGE_NAME}.d/` to call the new functions. 123 | -------------------------------------------------------------------------------- /src/include/image_mgr_core.d/scm: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | # Commit the built image to the SCM repository 24 | # No arguments are accepted 25 | commit_to_scm () { 26 | cd $IMG_BASE_DIR 27 | 28 | # Add the image creation script and the postscripts 29 | if [ ! -d build_info ]; then 30 | mkdir build_info 31 | fi 32 | cat $IMAGE_MGR > build_info/image_mgr.sh 33 | 34 | case $IMAGE_BACKEND in 35 | xcat ) 36 | rsync -aSHC /install/postscripts build_info/ 37 | rsync -aSHC /install/custom/netboot build_info/ 38 | ;; 39 | esac 40 | 41 | rsync -aSHC --exclude='_build.*' ${IMAGE_MGR_BASE}/ build_info/ 42 | rsync -aSHC "${LOG_DIR}" build_info/ 43 | cp $__IMG_MGR_LOG build_info/image_mgr.log 44 | print_stats > build_info/stats 45 | 46 | 47 | # Commit only changes to text,owner,group, and mode (not mtime), 48 | # and do not make a commit if no changes have been made. See 49 | # http://permalink.gmane.org/gmane.comp.sysutils.backup.fsvs.general/475 50 | # for more information. 51 | 52 | # The above link suggests that something like this ought to work: 53 | # $FSVS -C -o empty_commit=no -f text,owner,group,mode ci -m "${FULL_COMMIT_MESSAGE}" #1>/dev/null 54 | # However, this command still results in a list of mtime-only 55 | # changes being added to the commit log 56 | 57 | IMG_TMP_DIR=$(mktemp -d ${BASE}/image.XXXXXXXX) 58 | 59 | # We check out the previous revision to ${IMG_TMP_DIR}/, rsync our 60 | # changes, excluding mtime-only changes, to that directory, and 61 | # then do a checkin from ${IMG_TMP_DIR}/ 62 | 63 | FULL_COMMIT_MESSAGE=$(echo -e "${USER_NAME}; Image rebuild completed at $(date)\n${COMMIT_MESSAGE}") 64 | echo ${FSVS_REPOSITORY}/trunk/ | $FSVS urls load 65 | cd $IMG_TMP_DIR 66 | 67 | $FSVS co ${FSVS_REPOSITORY}/trunk/ 68 | rsync -crlpgoDS --exclude=markers --exclude=rootimg/chos/local/* --force --delete ${IMG_BASE_DIR}/ ${IMG_TMP_DIR}/ 69 | rm -rf ${IMG_TMP_DIR}/markers 70 | $FSVS -C -o empty_commit=no ci -m "${FULL_COMMIT_MESSAGE}" 71 | echo "fsvs exited with status: $?" 72 | $FSVS log -r HEAD -v 73 | } 74 | 75 | # Print diffs between two revisions of an image 76 | # Arguments: 77 | # $1 == old revision number (required) 78 | # $2 == new revision number (required) 79 | # $3... == Optional control keywords, which may be any of the 80 | # following: 81 | # 82 | # assume: Assume the preparatory checkout has already been done. Use 83 | # with caution. Incorrect use of this functionality may result in 84 | # inaccurate diffs. 85 | # 86 | # keep: Do not remove the preparatory checkout directory after the 87 | # diff is completed. This may be useful when combined with 88 | # "assume" 89 | diff_from_scm () { 90 | _ASSUME=1 91 | _KEEP=0 92 | 93 | while [ $# -gt 0 ] ; do 94 | case $1 in 95 | assume ) 96 | _ASSUME=1 97 | ;; 98 | keep ) 99 | _KEEP=1 100 | ;; 101 | * ) 102 | ;; 103 | esac 104 | shift 105 | done 106 | 107 | if [ $_ASSUME -eq 1 ]; then 108 | DIFF_SCRATCH_DIR="$(ls -1dtr ${BASE}/image.diff.${PROFILE}.${DIFF_OLD_REVISION}.* | tail -1)" 109 | echo $DIFF_SCRATCH_DIR 110 | cd $DIFF_SCRATCH_DIR 111 | else 112 | DIFF_SCRATCH_DIR=$(mktemp -d ${BASE}/image.diff.${PROFILE}.${DIFF_OLD_REVISION}.XXXXXXXX) 113 | cd $DIFF_SCRATCH_DIR 114 | $FSVS co -r $DIFF_OLD_REVISION ${FSVS_REPOSITORY}/${DIFF_OLD_PATH}/ 115 | fi 116 | 117 | echo ${FSVS_REPOSITORY}/${DIFF_NEW_PATH} | $FSVS urls load >/dev/null 118 | $FSVS sync-repos >/dev/null 119 | $FSVS diff -o diff_opt="-qpu" -r ${DIFF_NEW_REVISION} | \ 120 | grep -v '^diff -u.*$' | \ 121 | grep -v '^Type changed from local symlink to any-special.*$' | \ 122 | sed -ne 's/^\(.*\)\(\s\+\)\(.*\)$/\3\2:\1/p' | \ 123 | sed -e 's/^\(differ\s\+:Files\s\+\)\(.*\)$/\.\/\2 : \1/p' #| \ 124 | #cut -c -80 125 | #$FSVS diff -o diff_opt="-qpu" -r ${DIFF_NEW_REVISION} | \ 126 | #awk '/differ/ {print $2}' 127 | #$FSVS diff -o diff_opt="-qpu" -r ${DIFF_NEW_REVISION} | \ 128 | #awk '/^Only in repository/ {print $4}' 129 | } 130 | 131 | -------------------------------------------------------------------------------- /src/include/image_mgr_core.d/addon: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | make_addon() { 24 | ADDON_NAME="$1"; shift 25 | 26 | if [[ ! -z "$BASE_ONLY" ]]; then 27 | # Addon creation is disabled 28 | return 0 29 | fi 30 | 31 | echo -n "[addon] $ADDON_NAME (prep... " 32 | 33 | # Unmount the bind mounts in the image building area 34 | umount_fs || /bin/true 35 | 36 | _LOG=$(mklog "${ADDON_NAME}.stdout") 37 | 38 | ADDON_BASE_DIR=${IMG_BASE_DIR}/addons 39 | ADDONSCRATCH=$(mktemp -d ${BASE}/image.addonscratch.XXXXXXXX) 40 | ADDONTMP=$(mktemp -d ${BASE}/image.addontmp.XXXXXXXX) 41 | ADDONDEST=${IMG_BASE_DIR}/addons/${ADDON_NAME} 42 | ADDONROOT=${ADDONSCRATCH} 43 | 44 | local _ADDONROOT_BACKING="$(mktemp "${TMP_AREA}/${ADDON_NAME}.backing.XXXXXXXX")" 45 | 46 | IMGSCRATCHMANIFEST=${ADDONTMP}/IMG_SCRATCH_MANIFEST 47 | IMGMANIFEST=${ADDONTMP}/IMG_MANIFEST 48 | ADDONSCRATCHMANIFEST=${ADDONTMP}/IMG_ADDON_MANIFEST 49 | ADDONMANIFEST=${ADDONDEST}/etc/addons/MANIFEST_${ADDON_NAME} 50 | 51 | [ -d $ADDONROOT ] || mkdir -p $ADDONROOT 52 | [ -d $ADDONDEST ] || mkdir -p $ADDONDEST 53 | [ -d ${IMGROOT}/etc/addons/ ] || mkdir -p ${IMGROOT}/etc/addons 54 | echo -n "done) " 55 | 56 | echo -n "(scratch $_ADDONROOT_BACKING ... " 57 | # Create a temporary filesystem to use as the addon scratch area 58 | dd if=/dev/zero of="${_ADDONROOT_BACKING}" \ 59 | bs=1M count=1 seek=10240 &>/dev/null 60 | mkfs.ext4 -qF "${_ADDONROOT_BACKING}" &>/dev/null 61 | loop_mount "${_ADDONROOT_BACKING}" "${ADDONROOT}" 62 | 63 | echo -n "done) " 64 | 65 | echo -n "(sync... " 66 | # Copy the current image to the addon building area 67 | rsync -aSHx --exclude=export ${IMGROOT}/ ${ADDONROOT}/ 68 | echo -n "done) " 69 | 70 | mkdir "${ADDONROOT}/export/" 71 | 72 | ln -s /data ${ADDONROOT}/export/data 73 | # Modify the copy of the image 74 | echo -n "(log: \$LOG_DIR/$(basename "$_LOG"))... " 75 | _create_addon_${ADDON_NAME} > "$_LOG" 76 | echo -n "done ) (post... " 77 | 78 | # Apply module signing, if requested 79 | if [[ -z $KERNEL_MODULE_SIGNING_KEY ]]; then 80 | unsign_kmods ${ADDONROOT} 81 | else 82 | sign_kmods ${KERNEL_MODULE_SIGNING_KEY} ${ADDONROOT} 83 | fi 84 | 85 | rm -f ${ADDONROOT}/export/data 86 | rmdir ${ADDONROOT}/export/ 87 | 88 | 89 | # Create list of all files in the addon 90 | rpm --root $IMGROOT -qa > $ADDONTMP/img_rpms 91 | rpm --root $ADDONROOT -qa > $ADDONTMP/img_plus_addon_rpms 92 | diff $ADDONTMP/img_rpms $ADDONTMP/img_plus_addon_rpms | \ 93 | grep '^>' | \ 94 | cut -c 3- > \ 95 | $ADDONROOT/etc/addons/RPMS_${ADDON_NAME} || true 2>/dev/null 96 | 97 | # Clean up the addon build area 98 | rm --one-file-system -rf "${ADDONROOT}/data" 99 | rm --one-file-system -rf "${ADDONROOT}/var/lib/yum" 100 | rm --one-file-system -rf "${ADDONROOT}/var/cache/yum" 101 | rm --one-file-system -rf "${ADDONROOT}/usr/share/doc" 102 | rm --one-file-system -rf "${ADDONROOT}/usr/man" 103 | 104 | # Remove undesired files from the add-on 105 | rm --one-file-system -rf "${ADDONROOT}/var" 106 | rm --one-file-system -rf "${ADDONROOT}/etc/passwd" 107 | rm --one-file-system -rf "${ADDONROOT}/etc/group" 108 | rm --one-file-system -rf "${ADDONROOT}/etc/shadow" 109 | rm --one-file-system -rf "${ADDONROOT}/etc/gshadow" 110 | rm --one-file-system -rf "${ADDONROOT}/etc/ld.so.cache"* 111 | 112 | # Create list of all files in the original image 113 | cd $IMGROOT && find . | sort > ${IMGSCRATCHMANIFEST} 114 | cd $ADDONROOT && find . | sort > ${ADDONSCRATCHMANIFEST} 115 | 116 | # Perform a diff -qr $IMGROOT `pwd` to create $ADDONSCRATCHMANIFEST 117 | ( cd $ADDONROOT && diff -qr $IMGROOT . 2>&1 || true ) | \ 118 | sed -ne 's/^Files.*and \(\S\+\) differ/\1/p' | \ 119 | sort 2>&1 >> ${ADDONSCRATCHMANIFEST} 120 | 121 | # Perform a diff $IMGSCRATCHMANIFEST $ADDONSCRATCHMANIFEST to 122 | # create the addon entry list 123 | ( diff $IMGSCRATCHMANIFEST $ADDONSCRATCHMANIFEST || true ) | \ 124 | grep '^>' | \ 125 | cut -c 5- > $IMGMANIFEST 2>/dev/null 126 | 127 | # Copy all files in the addon building are that did not exist in 128 | # the original image into the addon destination area. This will 129 | # create an add-on that we can apply to an image as it boots 130 | cd $ADDONROOT 131 | rsync -aSHx --files-from=${IMGMANIFEST} ./ ${ADDONDEST}/ 132 | 133 | # Create list of all files in the addon 134 | cd $ADDONDEST && find . > ${ADDONMANIFEST} 135 | 136 | # Clean up the addon building area 137 | umount -d "${ADDONROOT}" 138 | rm -f "${_ADDONROOT_BACKING}" 139 | 140 | ADDONROOT="" 141 | 142 | echo " $(wc -l ${IMGMANIFEST} | cut -d' ' -f1 ) entries)" 143 | } 144 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/chos: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | _create_addon_chos () { 24 | #$YUM --disableexcludes=main install glibc.i686 25 | # TODO: The CHOS RPM depends on DKMS which we do not need. 26 | 27 | case $OS_FAMILY in 28 | el5 ) 29 | CHOS_RPM=$IMAGE_MGR_BASE/src//chos/chos-0.09-1.x86_64.rpm 30 | ;; 31 | el6 ) 32 | CHOS_RPM=$IMAGE_MGR_BASE/src/chos/chos-0.09-2larry4.x86_64.rpm 33 | ;; 34 | esac 35 | rpm --nodeps --force --root $ADDONROOT -ivh $CHOS_RPM 36 | __addon_chos_install 37 | cp $IMAGEFILES/pam_chos.so $ADDONROOT/lib64/security/ 38 | 39 | # Modify chos initscript to start later on boot, 40 | # not attempt to remount tmpfs filesystems 41 | patch -d $ADDONROOT/etc/init.d/ -p 0 -l << 'EOF' 42 | --- chos.orig Thu Apr 14 18:05:00 2011 43 | +++ chos Thu Apr 14 18:08:08 2011 44 | @@ -1,5 +1,5 @@ 45 | #!/bin/sh 46 | -# chkconfig: 2345 26 74 47 | +# chkconfig: 2345 80 76 48 | # 49 | #CHOS (c) 2004, The Regents of the University of California, through 50 | # Lawrence Berkeley National Laboratory (subject to receipt of any 51 | @@ -103,6 +103,7 @@ 52 | awk '{ 53 | if ($0 ~ /noauto/){next;} 54 | if ($0 ~ /swap/){next;} 55 | + if ($0 ~ /tmpfs/){printf "if [ ! -e \"/chos/local%s\" ] ; then mkdir /chos/local%s; fi;mount -t %s -o bind,%s %s /chos/local%s\n",$2,$2,$3,$4,$2,$2;next;} 56 | printf "if [ ! -e \"/chos/local%s\" ] ; then mkdir /chos/local%s; fi;mount -t %s -o %s %s /chos/local%s\n",$2,$2,$3,$4,$1,$2 57 | }'|sh 58 | mount --bind /dev /chos/dev 59 | EOF 60 | 61 | rmdir $ADDONROOT/chos/sys || /bin/true 62 | ln -sf /local/sys $ADDONROOT/chos/sys || /bin/true 63 | 64 | } 65 | 66 | _create_addon_chos_devel () { 67 | #$YUM --disableexcludes=main install glibc.i686 68 | # TODO: The CHOS RPM depends on DKMS which we do not need. 69 | 70 | case $OS_FAMILY in 71 | el6 ) 72 | CHOS_RPM=/install/rpms/scientific/6/x86_64/chos-0.11.1/chos-0.11.1-1.x86_64.rpm 73 | ;; 74 | esac 75 | rpm --nodeps --force --root $ADDONROOT -ivh $CHOS_RPM 76 | __addon_chos_install 77 | 78 | cp -f ${IMAGEFILES}/init.d.chos ${ADDONROOT}/etc/init.d/chos 79 | cp -f ${IMAGEFILES}/sysconfig.chos ${ADDONROOT}/etc/sysconfig/chos 80 | chmod +x ${ADDONROOT}/etc/init.d/chos 81 | 82 | # Some mountpoints 83 | for DIR in /chos/export /chos/sys ; do 84 | [ -d ${ADDONROOT}/${DIR} ] || mkdir -p ${ADDONROOT}/${DIR} 85 | done 86 | 87 | 88 | } 89 | 90 | _create_addon_chos_0_12_1rc1 () { 91 | __addon_chos 0.12.1rc1 "$@" 92 | } 93 | 94 | _create_addon_chos_0_12rc1 () { 95 | __addon_chos 0.12rc1 "$@" 96 | } 97 | 98 | _create_addon_chos_0_12rc2 () { 99 | __addon_chos 0.12rc2 "$@" 100 | } 101 | 102 | _create_addon_chos_0_13_0rc1 () { 103 | __addon_chos 0.13.0rc1 "$@" 104 | } 105 | 106 | __addon_chos () { 107 | _CHOS_VERSION=$1 108 | shift 109 | 110 | m4 -DCHOS_VERSION=$_CHOS_VERSION $IMAGEFILES/image_mgr.chos.repo.m4 > \ 111 | $ADDONROOT/etc/yum.repos.d/chos.repo 112 | 113 | $YUM install chos 114 | 115 | __addon_chos_install 116 | 117 | cp -f ${IMAGEFILES}/init.d.chos ${ADDONROOT}/etc/init.d/chos 118 | cp -f ${IMAGEFILES}/sysconfig.chos ${ADDONROOT}/etc/sysconfig/chos 119 | chmod +x ${ADDONROOT}/etc/init.d/chos 120 | 121 | # Some mountpoints 122 | for DIR in /chos/export /chos/sys ; do 123 | [ -d ${ADDONROOT}/${DIR} ] || mkdir -p ${ADDONROOT}/${DIR} 124 | done 125 | } 126 | 127 | __addon_chos_install () { 128 | cat > $ADDONROOT/netboot.install_chos << 'EOF' 129 | #!/bin/bash 130 | 131 | set -Eeu 132 | 133 | for file in /chos/var /chos/opt /chos/sgespool /chos/sys /usr/common /chos/dev/ptmx /chos/dev/pts /chos/dev/shm /chos/dev; do 134 | if [ -e $file ] || [ -L $file ]; then 135 | rm -f $file 136 | fi 137 | done 138 | 139 | for dir in /chos/dev; do 140 | if [ -e $dir ]; then 141 | rmdir $dir 142 | fi 143 | done 144 | 145 | 146 | EOF 147 | 148 | chmod +x $ADDONROOT/netboot.install_chos 149 | chroot $ADDONROOT bash -c "KERNEL=$KERNEL /netboot.install_chos" 150 | rm -f $ADDONROOT/netboot.install_chos 151 | 152 | # Build the CHOS module. This process is based on the stock CHOS 153 | # dkms build procedure 154 | CHOS_MODULE_DIR=${ADDONROOT}/lib/modules/${KERNEL}/kernel/misc/ 155 | CHOS_SRC_DIR=$(echo ${ADDONROOT}/usr/src/chos-*/) 156 | cd ${CHOS_SRC_DIR} 157 | ./find_fork.sh $KERNEL 158 | make -C /lib/modules/${KERNEL}/build SUBDIRS=${CHOS_SRC_DIR} modules 159 | if [ ! -e ${CHOS_MODULE_DIR} ]; then 160 | mkdir ${CHOS_MODULE_DIR} 161 | fi 162 | cp ${CHOS_SRC_DIR}/chos.ko ${CHOS_MODULE_DIR}/ 163 | in_target depmod -A ${KERNEL} 164 | 165 | 166 | # Create some additional directories in / so that CHOS will 167 | # create appropriate /chos/${DIR} -> /local/${DIR} links 168 | for DIR in u; do 169 | mkdir $ADDONROOT/$DIR 170 | done 171 | 172 | # Remove links 173 | for LINK in ${ADDONROOT}/chos/* ; do 174 | [ ! -L ${LINK} ] || rm -f ${LINK} 175 | done 176 | 177 | for LINK in bin etc lib lib64 sbin usr; do 178 | ln -sf /proc/chos/link/${LINK} ${ADDONROOT}/chos/ 179 | done 180 | 181 | ln -s /global/project ${ADDONROOT}/chos/project 182 | ln -s / ${ADDONROOT}/chos/chos 183 | 184 | # Some mountpoints 185 | for DIR in /chos/global /chos/global/project /chos/global/common /chos/common /chos/home /chos/local /chos/cgroup /chos/auto /chos/afs /chos/dev ; do 186 | [ -d ${ADDONROOT}/${DIR} ] || mkdir -p ${ADDONROOT}/${DIR} 187 | done 188 | } 189 | 190 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/cleanup: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | setup_remove_python () { 24 | # See https://bugzilla.redhat.com/show_bug.cgi?id=203327 25 | rpm --root=$IMGROOT --nodeps -e python #python-libs 26 | rm -rf $IMGROOT/usr/lib/python2.4/ $IMGROOT/usr/lib64/python2.4/ 27 | } 28 | 29 | # This function exists for historical reasons and does nothing 30 | setup_remove_man_pages () { 31 | /bin/true 32 | } 33 | 34 | # This function exists for historical reasons and does nothing 35 | setup_remove_doc () { 36 | /bin/true 37 | } 38 | 39 | # This function exists for historical reasons and does nothing 40 | setup_remove_locales () { 41 | /bin/true 42 | } 43 | 44 | setup_remove_zoneinfo () { 45 | rm -rf $IMGROOT/usr/share/zoneinfo 46 | case $OS_FAMILY in 47 | el5 ) 48 | ;; 49 | el6 ) 50 | mkdir $IMGROOT/usr/share/zoneinfo 51 | cp /usr/share/zoneinfo/UTC $IMGROOT/usr/share/zoneinfo 52 | ;; 53 | esac 54 | } 55 | 56 | # This function exists for historical reasons and does nothing 57 | setup_remove_info () { 58 | true 59 | } 60 | 61 | setup_remove_i18n () { 62 | rm -rf $IMGROOT/usr/share/i18n 63 | } 64 | 65 | setup_remove_cracklib () { 66 | rm -rf $IMGROOT/usr/share/cracklib 67 | } 68 | 69 | # svc_disable [service] 70 | # Take whatever action necessary to prevent [service] 71 | # from starting automatically upon boot 72 | svc_disable() { 73 | local _SERVICE="$1" 74 | 75 | in_target chkconfig "$_SERVICE" off &>/dev/null || \ 76 | return 0 # Service does not exist or is already disabled 77 | } 78 | 79 | # svc_enable [service] 80 | # Take whatever action necessary to make [service] 81 | # start automatically upon boot. Ignore the case 82 | # where [service] does not exist of chkconfig fails 83 | # to turn it on. 84 | svc_enable() { 85 | local _SERVICE="$1" 86 | 87 | # Try to chkconfig the service on. 88 | # Silently ignore failures. 89 | in_target chkconfig "$_SERVICE" || \ 90 | in_target chkconfig "$_SERVICE" on &>/dev/null || \ 91 | /bin/true # Service likely does not exist 92 | } 93 | 94 | cleanup () { 95 | 96 | case $OS_FAMILY in 97 | el5 ) 98 | ;; 99 | el6 ) 100 | $YUM erase cronie-anacron 101 | ;; 102 | esac 103 | 104 | # Link some additional busybox utilities 105 | for _UTIL in vi diff patch; do 106 | [ -e $IMGROOT/bin/$_UTIL ] || \ 107 | [ -e $IMGROOT/usr/bin/$_UTIL ] || \ 108 | ln -s /sbin/busybox $IMGROOT/bin/$_UTIL 109 | done 110 | 111 | case $OS_FAMILY in 112 | el5 ) 113 | sed -ie 's/Boron)/Boron) for '$SYSTEMNAME'/g' $IMGROOT/etc/issue 114 | ;; 115 | el6 ) 116 | sed -ie 's/Carbon)/Carbon) for '$SYSTEMNAME'/g' $IMGROOT/etc/issue 117 | sed -ie 's/\(\\m\)/\1 (\\l)/g' $IMGROOT/etc/issue 118 | rm -rf $IMGROOT/usr/share/wallpapers 119 | rm -rf $IMGROOT/usr/share/backgrounds 120 | rm -rf $IMGROOT/usr/share/firstboot 121 | rm -f $IMGROOT/etc/modprobe.conf 122 | ;; 123 | esac 124 | 125 | 126 | rm -rf $IMGROOT/boot/initrd* 127 | rm -f $IMGROOT/etc/aliases.db 128 | rm -f $IMGROOT/etc/mail/virtusertable.db 129 | rm -f $IMGROOT/etc/mail/access.db 130 | rm -f $IMGROOT/etc/mail/domaintable.db 131 | rm -f $IMGROOT/etc/mail/mailertable.db 132 | 133 | # Disable all services 134 | in_target chkconfig --list | awk '/:on/ {print $1}' | while read _SVC; do 135 | svc_disable $_SVC 136 | done 137 | 138 | # Delete these NSS .chk files as the RPM installation process 139 | # generates them differentely every time See:. 140 | # http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn6.html 141 | # Re-enable if needed 142 | rm -f $IMGROOT/usr/lib64/libfreebl3.chk 143 | rm -f $IMGROOT/usr/lib64/libsoftokn3.chk 144 | 145 | $YUM --enablerepo='*' clean all 146 | # "yum clean all" does not seem to really clean up 147 | # /var/cache/yum/, so we clean it up by hand 148 | for _dir in \ 149 | $IMGROOT/data \ 150 | $IMGROOT/misc \ 151 | $IMGROOT/scratch/image_build \ 152 | $IMGROOT/usr/lib/debug \ 153 | $IMGROOT/usr/local \ 154 | $IMGROOT/usr/src \ 155 | $IMGROOT/var/cache/yum \ 156 | $IMGROOT/var/lib/yum \ 157 | $IMGROOT/var/log \ 158 | $IMGROOT/xcatpost 159 | do 160 | [ ! -e "$_dir" ] || rm -rf "$_dir" 161 | done 162 | 163 | target_mkdir /var/log 164 | target_mkdir /var/lib/yum 165 | 166 | 167 | check_kernel_symbols 168 | 169 | } 170 | 171 | check_kernel_symbols() { 172 | 173 | local _DEPMOD_KERNEL="$(kernel_variant)" 174 | 175 | case $OS_FAMILY in 176 | el5 ) 177 | _DEPMOD_KERNEL="$(echo $_DEPMOD_KERNEL | sed -e 's/.'${ARCH}'//')" 178 | ;; 179 | esac 180 | 181 | ERRS="$(in_target depmod -ae "$_DEPMOD_KERNEL" -F /boot/System.map-"$_DEPMOD_KERNEL" >&2)" 182 | 183 | if [ ! -z "$ERRS" ]; then 184 | echo "$ERRS" 185 | fail "depmod failed to resolve all symbols" 186 | fi 187 | } 188 | 189 | # Removes the RPM database. This saves space, but removes the 190 | # ability to interrogate a running image about package management 191 | # information 192 | setup_remove_rpm_db () { 193 | rpm --root $IMGROOT -qa > $IMGROOT/etc/rpms 194 | rm -rf $IMGROOT/var/lib/rpm 195 | 196 | # Add a basic RPM wrapper script to provide fake support for 197 | # some basic RPM functions 198 | cat > $IMGROOT/bin/rpm << 'EOF' 199 | #!/bin/sh 200 | 201 | set -Eeu 202 | 203 | while [ $# -gt 0 ]; do 204 | if [[ "$1" == "-qa" ]]; then 205 | cat /etc/rpms 206 | fi 207 | shift 208 | done 209 | 210 | exit 0 211 | EOF 212 | chmod +x $IMGROOT/bin/rpm 213 | #ln -sf /sbin/busybox $IMGROOT/bin/rpm 214 | } 215 | 216 | -------------------------------------------------------------------------------- /src/include/image_mgr_core.d/util: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | target_mkdir () { 24 | TARGET_DIR="$(_rootdir)/${1}" 25 | 26 | [ -d "${TARGET_DIR}" ] || mkdir -p "${TARGET_DIR}" 27 | } 28 | 29 | _rootdir () { 30 | if [ -z "$ADDONROOT" ]; then 31 | echo "${IMGROOT}" 32 | else 33 | echo "${ADDONROOT}" 34 | fi 35 | } 36 | 37 | _do_install () { 38 | local OPTIND=1 39 | _SRC="" 40 | while getopts "do:g:m:" _OPTION; do 41 | case $_OPTION in 42 | o ) _OWNER="$OPTARG" ;; 43 | g ) _GROUP="$OPTARG" ;; 44 | m ) _MODE="$OPTARG" ;; 45 | d ) _SRC="-d" ;; 46 | esac 47 | done 48 | 49 | shift $((OPTIND - 1)) 50 | 51 | if [ -z "$_SRC" ]; then 52 | _SRC="$1" 53 | shift 54 | fi 55 | 56 | _DEST="$1" 57 | shift 58 | 59 | install -o "${_OWNER}" -g "${_GROUP}" -m "${_MODE}" "${_SRC}" "${_DEST}" 60 | } 61 | 62 | _do_rpm () { 63 | rpm --root "$(_rootdir)" "$@" 64 | } 65 | 66 | _do_yum () { 67 | _ROOT="$(_rootdir)" 68 | 69 | case $OS_FAMILY in 70 | el5 ) 71 | yum --installroot=$_ROOT -y $YUM_EXTRA_ARGS "$@" 72 | ;; 73 | el[67] ) 74 | yum --setopt=history_record=no --releasever=$OS_RELEASE --installroot=$_ROOT -y $YUM_EXTRA_ARGS "$@" 75 | ;; 76 | * ) 77 | echo "Unsupported \$OS_FAMILY $OS_FAMILY" 78 | ;; 79 | esac 80 | 81 | prune_locales "$_ROOT" 82 | } 83 | 84 | # Perform a bind mount of $1 on $2. 85 | # bind_mount 86 | bind_mount () { 87 | _MOUNTS="$_MOUNTS $2" 88 | _mount bind "$1" "$2" 89 | } 90 | 91 | # Perform a bind mount of $1 on $2. 92 | # bind_mount 93 | loop_mount () { 94 | _MOUNTS="$_MOUNTS $2" 95 | _mount loop "$1" "$2" 96 | } 97 | 98 | # Attempt to unmount all devices in $_MOUNTS 99 | _umount_all () { 100 | cd /tmp/ 101 | for _MOUNT in $_MOUNTS; do 102 | umount -d $_MOUNT || /bin/true 103 | done 104 | cd - 105 | } 106 | 107 | # Perform a mount of type $1 of $2 on $3 108 | # Create the target if it does not exist 109 | # _mount [type] [source] [target] 110 | _mount () { 111 | _TYPE="$1" 112 | shift 113 | _SOURCE="$1" 114 | shift 115 | _TARGET="$1" 116 | shift 117 | 118 | # Check if the directory containing $_TARGET exists. If it does 119 | # not exist, do not try to create it. 120 | _BASE_DIR="$(dirname "${_TARGET}")" 121 | [ -e "$_BASE_DIR" ] || fail "$_BASE_DIR does not exist" 122 | 123 | # Check if the target file/directory exists. If not, then create 124 | # it. If the source is a directory, then create a target 125 | # directory 126 | [ -e "$_TARGET" ] || { 127 | if [ -d "$_SOURCE" ]; then 128 | $INSTALL_ROOT -m 755 -d "$_TARGET" 129 | else 130 | $INSTALL_ROOT -m 644 /dev/null "$_TARGET" 131 | fi 132 | } 133 | 134 | mount -o "${_TYPE}" "$_SOURCE" "$_TARGET" 135 | } 136 | 137 | 138 | # Remove all kernel module signatures in ${_ROOTDIR}/lib/modules/ 139 | unsign_kmods () { 140 | _ROOTDIR="$1" 141 | shift 142 | 143 | # If the kernel modules directory does not exist, stop processing 144 | # now. 145 | [ -d "${_ROOTDIR}/lib/modules/" ] || return 0 146 | 147 | for _KMOD in $(find "${_ROOTDIR}/lib/modules/" -name '*.ko' || echo ''); do 148 | if ! [[ \ 149 | "$(readelf -n ${_KMOD} | grep -o '^ module.sig' || /bin/true)" \ 150 | != " module.sig" ]]; then 151 | # The module is signed. Remove the signature. 152 | objcopy -R .note.module.sig "${_KMOD}" 153 | fi 154 | done 155 | } 156 | 157 | # Sign all kernel module signatures in ${_ROOTDIR} with ${_KEY} 158 | sign_kmods () { 159 | 160 | _KEY="$1" 161 | shift 162 | _ROOTDIR="$1" 163 | shift 164 | 165 | _MOD_EXTRACT="$(echo /lib/modules/$(kernel_variant)/build/scripts/mod/mod-extract)" 166 | _K_INCLUDE="$(echo /lib/modules/$(kernel_variant)/build/include/)" 167 | _MODSIGN_NOTE="$(echo /lib/modules/$(kernel_variant)/build/scripts/mod/modsign-note.sh)" 168 | 169 | # If the kernel modules directory does not exist, stop processing 170 | # now. 171 | [ -d "${_ROOTDIR}/lib/modules/" ] || return 0 172 | 173 | # Iterate through each .ko file in the kernel modules area. 174 | # If it is not already signed, then sign it. 175 | for _KMOD in $(find "${_ROOTDIR}/lib/modules/" -name '*.ko'); do 176 | if [[ \ 177 | "$(readelf -n ${_KMOD} | grep -o '^ module.sig' || /bin/true)" \ 178 | != " module.sig" ]]; then 179 | # The module is not already signed, so sign it. 180 | 181 | # Create temprorary files 182 | _KMOD_EXTRACTED=$(mktemp ${TMP_AREA}/sign_kmods.XXXXXXXXXX) 183 | _KMOD_UNSIGNED=$(mktemp ${TMP_AREA}/gsign_kmods.XXXXXXXXXX) 184 | _KMOD_SIG=$(mktemp ${TMP_AREA}/gsign_kmods.XXXXXXXXXX) 185 | _KMOD_SIG_C=$(mktemp ${TMP_AREA}/gsign_kmods.XXXXXXXXXX) 186 | _KMOD_NOTE=$(mktemp ${TMP_AREA}/gsign_kmods.XXXXXXXXXX) 187 | 188 | cp $_KMOD $_KMOD_UNSIGNED 189 | 190 | # Extract the contents of the module 191 | $_MOD_EXTRACT $_KMOD $_KMOD_EXTRACTED 192 | 193 | # Create a detached signature using the provided key 194 | gpg -o - --batch -u $_KEY -b $_KMOD_EXTRACTED > $_KMOD_SIG 195 | 196 | # Create an ELF NOTE from the signature 197 | sh $_MODSIGN_NOTE $_KMOD_SIG > $_KMOD_SIG_C 198 | gcc -x assembler-with-cpp $_KMOD_SIG_C \ 199 | -I $_K_INCLUDE -DCONFIG_MODULE_SIG=1 \ 200 | -c -o ${_KMOD_NOTE} 201 | 202 | # Add the note to the module 203 | ld -r -m elf_x86_64 -o ${_KMOD} ${_KMOD_UNSIGNED} ${_KMOD_NOTE} 204 | 205 | # Remote temporary files 206 | rm -f $_KMOD_EXTRACTED 207 | rm -f $_KMOD_UNSIGNED 208 | rm -f $_KMOD_SIG 209 | rm -f $_KMOD_SIG_C 210 | rm -f $_KMOD_NOTE 211 | 212 | fi 213 | done 214 | } 215 | 216 | # Return the name of the current kernel variant 217 | kernel_variant() { 218 | if [ ! -z "$KERNEL_SUFFIX" ]; then 219 | echo "${KERNEL}.${KERNEL_SUFFIX}" 220 | else 221 | echo "${KERNEL}" 222 | fi 223 | } 224 | 225 | # Return the location of the "fsvs" command, if it is in $PATH 226 | _env_fsvs() { 227 | env fsvs "$@" 228 | } 229 | 230 | # Create a new logfile in the log area 231 | mklog() { 232 | _LOG_NAME="$1"; shift 233 | mktemp "$LOG_DIR/${_LOG_NAME}.XXXXXXX.log" 234 | } 235 | -------------------------------------------------------------------------------- /src/image_mgr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | 5 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 6 | # Regents of the University of California, through Lawrence Berkeley 7 | # National Laboratory (subject to receipt of any required approvals 8 | # from the U.S. Dept. of Energy). All rights reserved. 9 | # 10 | # If you have questions about your rights to use or distribute this 11 | # software, please contact Berkeley Lab's Technology Transfer 12 | # Department at TTD@lbl.gov. 13 | # 14 | # NOTICE. This software is owned by the U.S. Department of Energy. 15 | # As such, the U.S. Government has been granted for itself and others 16 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 17 | # license in the Software to reproduce, prepare derivative works, and 18 | # perform publicly and display publicly. Beginning five (5) years 19 | # after the date permission to assert copyright is obtained from the 20 | # U.S. Department of Energy, and subject to any subsequent five (5) 21 | # year renewals, the U.S. Government is granted for itself and others 22 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 23 | # license in the Software to reproduce, prepare derivative works, 24 | # distribute copies to the public, perform publicly and display 25 | # publicly, and to permit others to do so. 26 | 27 | 28 | 29 | # Netboot image generator 30 | # This utility wraps FSVS and xCAT {gen,pack}image 31 | 32 | # This file contains default settings. 33 | # You should not need to edit this file. Edit files in 34 | # include/image-specific/.d/ to override these settings. 35 | 36 | set -E 37 | set -e 38 | set -u 39 | set -o pipefail 40 | set -o posix 41 | 42 | # The path to the image_mgr.sh script 43 | IMAGE_MGR_SCRIPT_DIR="$(readlink -f "$(dirname "$0")")" 44 | CWD_ORIG="$(pwd)" 45 | cd "$IMAGE_MGR_SCRIPT_DIR" 46 | 47 | . include/image_mgr.pre 48 | 49 | trap 'generic_fail ${BASH_SOURCE[0]} $LINENO $?' 1 2 3 15 ERR 50 | 51 | 52 | # The subshell level 53 | TOP_SUBSHELL_LEVEL=$BASH_SUBSHELL 54 | 55 | 56 | # Set default values for many variables. Some of these 57 | # can be overridden by files included from the site-specific/ and 58 | # image-specific/ areas 59 | ADDITIONAL_PACKAGES_LIST_PROVIDER="default" 60 | ADDONROOT="" 61 | ARCH="" 62 | ATTEMPT_RESUME="" 63 | 64 | # Whether or not to build add-ons with images 65 | # By setting $BASE_ONLY, only the base 66 | # image will be built. 67 | BASE_ONLY="" 68 | 69 | COMMIT_MESSAGE="" 70 | DATE=`date '+%Y%m%d'` 71 | DATESTAMP="$(date +%Y-%m-%d-%H-%M-%S)" 72 | DIFF_OLD_REVISION="" 73 | DIFF_NEW_REVISION="" 74 | DIFF_SCRATCH_DIR="" 75 | 76 | # Set the filesystem type for disk installations (under supporting 77 | # backends) 78 | DISK_BOOT_PARTITION="/dev/sda1" 79 | DISK_BOOT_FS="ext4" 80 | DISK_ROOT_FS="ext4" 81 | 82 | FSVS="_env_fsvs" 83 | 84 | # The path to the FSVS repository where images will be stored 85 | FSVS_REPOSITORY="" 86 | 87 | # The backend to use for image management 88 | IMAGE_BACKEND="xcat" 89 | 90 | GENIMAGE_PROVIDER="default" 91 | GPFS_CONFIG_SERVERS="" 92 | 93 | # Whether or not to install documentation. Setting $INSTALL_DOCS to 94 | # "no" will activate the %_excludedocs RPM macro on RPM-based systems. 95 | # Any other value will result in distribution-default behavior. 96 | INSTALL_DOCS="no" 97 | 98 | # A colon-separated list of which locales to install. If set to the 99 | # empty string, distribution-default behavior will result. If set to 100 | # some other value, the value will be set as the %install_langs RPM 101 | # macro on RPM-based systems. 102 | INSTALL_LOCALES="C" 103 | 104 | 105 | # The path to a directory containing image support files. 106 | # By convention, most image building functions will 107 | # expect support files in ${IMAGE_MGR_BASE}/files or 108 | # ${IMAGE_MGR_BASE}/src 109 | IMAGE_MGR_BASE="$IMAGE_MGR_SCRIPT_DIR" 110 | 111 | # The path to the $IMAGEFILES area, which most image building 112 | # functions will expect to contain suppport files 113 | IMAGEFILES="${IMAGE_MGR_BASE}/files/" 114 | 115 | 116 | IMAGE_OUTPUT_NAME="" 117 | IMG_BASE_DIR="" 118 | IMGROOT="" 119 | KEEP_LOCALE="" 120 | KERNEL="$(uname -r)" 121 | KERNEL_NOARCH="$(echo $KERNEL | sed -e 's/.x86_64//')" 122 | KERNEL_SUFFIX="" 123 | 124 | # The directory in which log files should be stored. 125 | LOG_BASE_DIR="${IMAGE_MGR_BASE}/_build.logs/" 126 | 127 | # Sign kernel modules. This is currently only supported on EL6. 128 | # On EL6, this will sign any out-of-tree kernel modules with the 129 | # GPG secret key named by ${KERNEL_MODULE_SIGNING_KEY}. The secret 130 | # key must be present in the default GPG secret keyring, and the 131 | # kernel sources must be installed. 132 | # 133 | # If set to the empty string, no attempt to sign modules will be made. 134 | # Note that on EL6, kernel module signature enforcement can be enabled 135 | # by passing enforcemodulesig=1 on the kernel command line. If 136 | # module signature enforcement is disabled, then unsigned modules can 137 | # be loaded, but modules signed with the wrong signature will still be 138 | # rejected. 139 | # 140 | # The signature can be removed from a signed kernel module with: 141 | # objcopy -R .note.module.sig foo.ko 142 | KERNEL_MODULE_SIGNING_KEY="" 143 | 144 | # Activate "masquerading" capability. This allows you to pack any 145 | # image tag as any xCAT image. This can be used to perform testing on 146 | # a new version of an image without altering the production packed 147 | # image. Note that you will still need to update the xCAT synclist 148 | # files for the masqueraded image name. 149 | # 150 | # If $MASQUERADE_IMAGE is set to the empty string, no masquerading 151 | # will be done. Otherwise, the image will be packed as 152 | # $MASQUERADE_IMAGE instead of the true image name. 153 | # 154 | # This functionality is normally activated through the "-x" 155 | # command-line option 156 | MASQUERADE_IMAGE="" 157 | 158 | MODE="" 159 | OS="" 160 | OS_FAMILY="" 161 | OS_MAJOR_VERSION="" 162 | OS_RELEASE="" 163 | PACK_ON_COMPLETION="" 164 | PROFILE="" 165 | 166 | # Settings for the "rinse" image backend 167 | RINSE="/usr/bin/env rinse" 168 | RINSE_LIBDIR="/usr/lib/rinse" 169 | RINSE_SYSCONFDIR="/etc/rinse" 170 | RINSE_CONF="${RINSE_SYSCONFDIR}/rinse.conf" 171 | 172 | # The default size of the / tmpfs filesystem. 173 | # This must be large enough to accommodate the size of the image. 174 | ROOTSIZE="1024" 175 | RPM="" 176 | 177 | STAMP="" 178 | SVNHOST="" 179 | SVNPROTO="file" 180 | 181 | # The default path to the image repository area 182 | SVN_REPO_DIR="${IMAGE_MGR_BASE}/_build.image_repo" 183 | 184 | SYSTEMNAME="Generic" 185 | TAG_NAME="" 186 | TAG_PATH="" 187 | TAG_REVISION="" 188 | 189 | # Area to store temporary files 190 | TMP_BASE_DIR="${IMAGE_MGR_TMP_AREA:-${IMAGE_MGR_BASE}/_build.tmp}" 191 | [ -d "$TMP_BASE_DIR" ] || mkdir "$TMP_BASE_DIR" 192 | TMP_AREA=$(mktemp -d "${TMP_BASE_DIR}/tmp.XXXXXXXXXX") 193 | 194 | USER_NAME="" 195 | XCAT_NETBOOT_DIR="" 196 | YUM="" 197 | 198 | # Default extra arguments to pass to yum 199 | YUM_EXTRA_ARGS="-d 1" 200 | 201 | 202 | # The OS image will be built in BASE. 203 | # Placing this area on tmpfs may speed up image builds for compatible images 204 | BASE="${IMAGE_MGR_BASE}/_build.builddir/" 205 | 206 | 207 | 208 | # List of any active mounts 209 | _MOUNTS="" 210 | 211 | cd "$IMAGE_MGR_SCRIPT_DIR" 212 | IMAGE_MGR="$(pwd)/$(basename "$0")" 213 | 214 | # Ensure we are running in an unshared mount namespace 215 | env | grep '^__UNSHARED=1' >/dev/null 2>&1 || { 216 | # Unset our trap to avoid undesired double handling of errors 217 | trap - 1 2 3 15 ERR 218 | exec env -i PATH="$PATH" TERM="$TERM" \ 219 | __UNSHARED=1 unshare -m -- bash --norc ${IMAGE_MGR} "$@" 220 | } 221 | 222 | [ -d "$LOG_BASE_DIR" ] || mkdir "$LOG_BASE_DIR" 223 | LOG_DIR="$(mktemp -d "${LOG_BASE_DIR}/log.$(date +%Y-%m-%d-%H-%M-%S).XXXXX")" 224 | 225 | # Import all functions 226 | image_mgr_prep "$@" 227 | 228 | _IMGROOT_BACKING="${BASE}/_build.backing.img" 229 | 230 | # Begin the image build 231 | image_mgr_main "$@" 232 | 233 | 234 | trap - 1 2 3 15 ERR 235 | 236 | 237 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/shared: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | # Install a file from $IMAGEFILES into the image 24 | # install_file [source filename relative to $IMAGEFILES] [destdir] 25 | install_file () { 26 | local _FILE="$1"; shift 27 | local _DEST="$(get_buildroot)/$1"; shift 28 | local _MODE="$1"; shift 29 | local _SRC_FILE="$IMAGEFILES/$_FILE" 30 | 31 | [ ! -e "$_SRC_FILE" ] || \ 32 | $INSTALL_ROOT -m $_MODE "$_SRC_FILE" "$_DEST" 33 | } 34 | 35 | build_prep () { 36 | 37 | install_file etc/hosts /etc/ 644 38 | install_file etc/hosts.allow /etc/ 644 39 | install_file etc/hosts.deny /etc/ 644 40 | install_file etc/localtime /etc/ 644 41 | install_file etc/resolv.conf /etc/ 644 42 | 43 | # Disable zeroconf 44 | echo "NOZEROCONF=yes" >> $IMGROOT/etc/sysconfig/network 45 | 46 | # Remove home area 47 | rmdir $IMGROOT/home 48 | } 49 | 50 | mount_fs () { 51 | echo 52 | } 53 | 54 | setup_yum_repos () { 55 | install_file config/yum.conf /etc/ 644 56 | 57 | [ -e $IMGROOT/etc/yum.conf ] || \ 58 | cat > $IMGROOT/etc/yum.conf << 'EOF' 59 | [main] 60 | cachedir=/var/cache/yum 61 | logfile=/var/log/yum.log 62 | pluginpath=/usr/lib/yum-plugins/ 63 | debuglevel=2 64 | distroverpkg=redhat-release 65 | metadata_expire=72000 66 | tolerant=0 67 | exactarch=1 68 | plugins=1 69 | http_caching=packages 70 | EOF 71 | 72 | # Do not install 32-bit RPMS. 73 | echo 'exclude = *.i?86' >> $IMGROOT/etc/yum.conf 74 | 75 | case $OS_FAMILY in 76 | el5 ) 77 | #rm -rf $IMGROOT/etc/yum.repos.d 78 | #$YUM clean all 79 | #cp -a /etc/yum.repos.d/ $IMGROOT/etc/ 80 | #rm -rf $IMGROOT/etc/yum.repos.d/xCAT-* 81 | rpm --root $IMGROOT -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 82 | ;; 83 | el6 ) 84 | rm -rf $IMGROOT/etc/yum.repos.d 85 | $YUM clean all 86 | target_mkdir /etc/yum.repos.d/ 87 | rm -f $IMGROOT/etc/yum.repos.d/local-repository.repo 88 | 89 | [ ! -d $IMAGEFILES/repo.sl6 ] || \ 90 | rsync -a $IMAGEFILES/repo.sl6/* $IMGROOT/etc/yum.repos.d/ 91 | 92 | [ ! -d $IMAGEFILES/repo.unscd.sl6 ] || \ 93 | rsync -a $IMAGEFILES/repo.unscd.sl6/* $IMGROOT/etc/yum.repos.d/ 94 | 95 | [ ! -e $IMAGEFILES/kernel.repo.m4 ] || \ 96 | m4 -DKRNL=$KERNEL_NOARCH $IMAGEFILES/kernel.repo.m4 \ 97 | > $IMGROOT/etc/yum.repos.d/kernel.repo 98 | ;; 99 | el7 ) 100 | cp -av $IMAGEFILES/repo.el7/* $IMGROOT/etc/yum.repos.d/ 101 | #m4 -DKRNL=$KERNEL_NOARCH $IMAGEFILES/kernel.repo.m4 > $IMGROOT/etc/yum.repos.d/kernel.repo 102 | ;; 103 | esac 104 | 105 | $YUM upgrade 106 | } 107 | 108 | setup_disable_selinux () { 109 | cp -f $IMAGEFILES/config/selinux.config /etc/selinux/config 110 | } 111 | 112 | setup_fstab () { 113 | 114 | case $IMAGE_BACKEND in 115 | 116 | xcat ) 117 | # Set the contents of the device field for / in fstab to $DATESTAMP 118 | # This must be no more than 20 characters to avoid an extra line 119 | # break in the "df" output 120 | cat > $IMGROOT/etc/fstab << EOF 121 | $DATESTAMP / tmpfs rw 0 1 122 | EOF 123 | ;; 124 | rinse ) 125 | cat > $IMGROOT/etc/fstab << EOF 126 | ${DISK_BOOT_PARTITION} /boot $DISK_BOOT_FS 0 2 127 | /dev/mapper/vg_${DATESTAMP}-root / $DISK_ROOT_FS 0 2 128 | EOF 129 | ;; 130 | esac 131 | 132 | 133 | cat >> $IMGROOT/etc/fstab << EOF 134 | tmpfs /tmp tmpfs rw,size=${ROOTSIZE}M 0 0 135 | tmpfs /var/log tmpfs rw,size=512M 0 0 136 | proc /proc proc rw 0 0 137 | sysfs /sys sysfs rw 0 0 138 | tmpfs /dev/shm tmpfs defaults 0 0 139 | EOF 140 | 141 | case $OS_FAMILY in 142 | el5 ) 143 | ;; 144 | el6 ) 145 | cat >> $IMGROOT/etc/fstab << EOF 146 | devpts /dev/pts devpts gid=5,mode=620 0 0 147 | EOF 148 | ;; 149 | esac 150 | 151 | } 152 | 153 | setup_enable_ntpd () { 154 | $YUM install ntp 155 | #in_target chkconfig --level 345 ntpd on 156 | } 157 | 158 | _create_addon_backuputils () { 159 | $YUM install ncftp dump 160 | rm -rf ${ADDONROOT}/usr/share/man 161 | } 162 | 163 | _create_addon_modules () { 164 | $YUM install environment-modules 165 | rm -rf ${ADDONROOT}/usr/share/man 166 | } 167 | 168 | setup_debug_image() { 169 | $YUM install yum 170 | } 171 | 172 | setup_nrpe() { 173 | if [ ! -d $IMGROOT/etc/nagios/ ]; then 174 | mkdir $IMGROOT/etc/nagios/ 175 | fi 176 | cp $IMAGEFILES/etc/nrpe.cfg $IMGROOT/etc/nagios/ 177 | 178 | $YUM install sudo pam_radius pam-radius-auth nrpe nagios-plugins-nrpe nagios-plugins-disk nagios-plugins-ide_smart nagios-plugins-tcp nagios-plugins-ssh 179 | 180 | case $OS_FAMILY in 181 | el[56] ) 182 | in_target chkconfig nrpe on 183 | chmod u-s $IMGROOT/usr/lib64/nagios/plugins/* 184 | ;; 185 | esac 186 | 187 | } 188 | 189 | 190 | setup_sshd () { 191 | # IPV4 for /etc/sysconfig/sshd 192 | cat << EOF > $IMGROOT/etc/sysconfig/sshd 193 | OPTIONS="-4" 194 | EOF 195 | 196 | $YUM install 'openssh-clients*' 'openssh-server*' 197 | } 198 | 199 | setup_ganglia () { 200 | 201 | case $OS_FAMILY in 202 | el[567] ) 203 | $YUM install ganglia-gmond 204 | 205 | GMOND_CONF=$IMGROOT/etc/ganglia/gmond.conf 206 | GMOND_CONF_SRC=$IMAGEFILES/gmond.conf 207 | ;; 208 | esac 209 | mkdir -p $IMGROOT/etc/ganglia 210 | cp -f $GMOND_CONF_SRC $GMOND_CONF 211 | 212 | case $OS_FAMILY in 213 | el[56] ) 214 | in_target chkconfig gmond off 215 | ;; 216 | esac 217 | } 218 | 219 | setup_authorized_keys () { 220 | # Setup authorized_keys 221 | target_mkdir /root/.ssh 222 | chmod 700 $IMGROOT/root/.ssh/ 223 | install -o root -g root -m 400 $IMAGEFILES/authorized_keys $IMGROOT/root/.ssh/ 224 | } 225 | 226 | setup_ssh_host_keys () { 227 | #cp -a $IMAGEFILES/ssh_boot_tmp/* $IMGROOT/etc/ssh/ 228 | target_mkdir /etc/ssh/ 229 | cp -a /etc/xcat/hostkeys/* $IMGROOT/etc/ssh/ 230 | chmod 600 $IMGROOT/etc/ssh/*key 231 | } 232 | 233 | setup_install_autofs () { 234 | $YUM install autofs nfs-utils 235 | in_target chkconfig nfs on 236 | in_target chkconfig autofs on 237 | 238 | cp $IMAGEFILES/auto.master $IMGROOT/etc/ 239 | cp $IMAGEFILES/auto.${SYSTEMNAME_LOWER} $IMGROOT/etc/ 240 | #cp /etc/auto.linux $IMGROOT/etc/ 241 | chmod 600 $IMGROOT/etc/auto.${SYSTEMNAME_LOWER} 242 | #chmod 600 $IMGROOT/etc/auto.linux 243 | } 244 | 245 | setup_install_kernel () { 246 | case $OS_FAMILY in 247 | el* ) 248 | $YUM install kernel-${KERNEL} kernel-firmware-${KERNEL} 249 | ;; 250 | * ) 251 | echo "Unsupoorted \$OS_RELEASE $OS_RELEASE" 252 | ;; 253 | esac 254 | 255 | touch $IMGROOT/etc/modprobe.conf 256 | 257 | cat > $IMGROOT/etc/modprobe.d/disable-ipv6.conf << 'EOF' 258 | #alias net-pf-10 off 259 | #alias ipv6 off 260 | options ipv6 disable=1 261 | EOF 262 | } 263 | 264 | # Remove unnecessary locales, if requested 265 | # prune_locales root_directory 266 | prune_locales() { 267 | 268 | local _ROOT="$1" 269 | 270 | [ -f "${_ROOT}/usr/lib/locale/locale-archive" ] || \ 271 | in_target build-locale-archive 272 | 273 | if [[ "$INSTALL_LOCALES" != "" ]]; then 274 | echo "Removing locales not matching $INSTALL_LOCALES" 275 | # %_install_langs does not seem to affect what is in the localedef 276 | # file. Remove unnecessary locales from the localedef file 277 | for _LOCALE in $(in_target localedef --list-archive); do 278 | _LOCALE_VALIDATED=0 279 | for _OK_LOCALE in $(echo "$INSTALL_LOCALES" | tr ':' ' '); do 280 | if [[ "$_LOCALE" == "$_OK_LOCALE" ]]; then 281 | _LOCALE_VALIDATED=1 282 | fi 283 | done 284 | if [ $_LOCALE_VALIDATED -eq 0 ]; then 285 | in_target localedef --delete-from-archive "$_LOCALE" 286 | fi 287 | done 288 | 289 | # Now, we need to install the new locale-archive file as 290 | # locale-archive.tmpl, and run build-locale-archive to 291 | # generate a much smaller locale-archive file. Once this is 292 | # done, we can remove locale-archive.tmpl 293 | install -o root -g root -m 644 "$_ROOT/usr/lib/locale/locale-archive" \ 294 | "$_ROOT/usr/lib/locale/locale-archive.tmpl" 295 | in_target build-locale-archive 296 | rm -f "$_ROOT/usr/lib/locale/locale-archive.tmpl" 297 | 298 | fi 299 | } 300 | -------------------------------------------------------------------------------- /src/include/image_mgr_core.d/shared: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | umount_fs () { 25 | echo -n 26 | } 27 | 28 | error () { 29 | echo -e "\n* Error: ${@}\n" 30 | usage_and_fail 31 | } 32 | 33 | 34 | list_tags () { 35 | TAG_LIST="$(svn ls ${FSVS_REPOSITORY}/tags/)" 36 | 37 | if [ -z "$TAG_LIST" ] ; then 38 | echo "(no tags found)" 39 | else 40 | echo "$TAG_LIST" 41 | fi 42 | 43 | } 44 | 45 | 46 | create_tag () { 47 | echo "Creating tag ${TAG_NAME}" 48 | svn cp -r ${TAG_REVISION} ${FSVS_REPOSITORY}/trunk/ ${TAG_PATH} -m "${COMMIT_MESSAGE}" 1>/dev/null 49 | } 50 | 51 | 52 | sleep_5 () { 53 | echo 54 | echo "Process will begin in 5 seconds..." 55 | sleep 5 56 | echo "Process starting..." 57 | } 58 | 59 | # Provide the path to the default xCAT genimage utility 60 | provide_genimage_default () { 61 | echo "/opt/xcat/share/xcat/netboot/$(echo $OS |tr -d [0-9\.])/genimage" 62 | } 63 | 64 | # Provide the path to genimage 65 | provide_genimage () { 66 | provide_genimage_${GENIMAGE_PROVIDER} 67 | } 68 | 69 | 70 | # in_target [command] [args] ... 71 | # Run $@ inside the image context 72 | in_target() { 73 | chroot $(get_buildroot) $@ 74 | } 75 | 76 | # get_buildroot 77 | # Return the path of the root of the current 78 | # building area 79 | get_buildroot() { 80 | if [ -z "$ADDONROOT" ]; then 81 | echo "${IMGROOT}" 82 | else 83 | echo "${ADDONROOT}" 84 | fi 85 | } 86 | 87 | # prep_build_dir 88 | # Prepare the image build directory inside $BASE 89 | prep_build_dir () { 90 | if [ ! -d "$BASE" ]; then 91 | mkdir -p "$BASE" 92 | fi 93 | 94 | if [ -z "$ATTEMPT_RESUME" ]; then 95 | BASE_DIR_NAME="$(echo "$(dirname "$BASE")"/"$(basename "$BASE")")" 96 | mv ${BASE_DIR_NAME} $(mktemp -d ${BASE_DIR_NAME}.XXXXXXXX) 97 | fi 98 | 99 | mkdir -p $IMGROOT 100 | _IMGROOT_BACKING="${BASE}/_build.backing.img" 101 | 102 | if [ ! -e "${_IMGROOT_BACKING}" ]; then 103 | dd if=/dev/zero of="${_IMGROOT_BACKING}" \ 104 | bs=1M count=1 seek=10240 &>/dev/null 105 | mkfs.ext4 -qF "${_IMGROOT_BACKING}" &>/dev/null 106 | fi 107 | loop_mount "${_IMGROOT_BACKING}" "${BASE}/install" 108 | 109 | echo "Backing file is ${_IMGROOT_BACKING}" 110 | 111 | 112 | mkdir -p ${IMGROOT}/../markers/ 113 | } 114 | 115 | # prepare_image_directory 116 | # This function exists for historical reasons, and does nothing. 117 | prepare_image_directory () { 118 | echo 119 | } 120 | 121 | run_step () { 122 | _STEP_NAME="$1" 123 | shift 124 | 125 | MARKER_DIR=${IMGROOT}/../markers/ 126 | COMPLETION_MARKER=${MARKER_DIR}/${_STEP_NAME}-complete 127 | 128 | _LOG=$(mklog "${_STEP_NAME}.stdout") 129 | 130 | if [ -z "$ATTEMPT_RESUME" ]; then 131 | rm -f ${COMPLETION_MARKER}* 132 | fi 133 | 134 | if [ ! -d $MARKER_DIR ]; then 135 | mkdir -p $MARKER_DIR 136 | fi 137 | 138 | RPM_QUERY="rpm --root $IMGROOT -qa --qf '%{NAME}-%{VERSION}-%{ARCH}\n'" 139 | echo -n "[+] $_STEP_NAME (log: \$LOG_DIR/$(basename "$_LOG"))... " 140 | if [ ! -f $COMPLETION_MARKER ]; then 141 | if [ -d ${MARKER_DIR} ]; then 142 | if [ -d $IMGROOT/var/lib/rpm ]; then 143 | $RPM_QUERY > ${COMPLETION_MARKER}.rpms-pre 144 | fi 145 | du -mxs $IMGROOT > ${COMPLETION_MARKER}.size-pre 146 | fi 147 | TIME_BEGIN=$(date +%s) 148 | #subshell_inc 149 | $_STEP_NAME > "$_LOG" 150 | #subshell_dec 151 | 152 | if [[ -z $KERNEL_MODULE_SIGNING_KEY ]]; then 153 | unsign_kmods ${IMGROOT} | sed 's/^/[unsign_kmods] /g' 154 | else 155 | sign_kmods ${KERNEL_MODULE_SIGNING_KEY} ${IMGROOT} | \ 156 | sed 's/^/[sign_kmods] /g' 157 | fi 158 | 159 | TIME_END=$(date +%s) 160 | if [ ! -d $MARKER_DIR ]; then 161 | mkdir -p $MARKER_DIR 162 | fi 163 | echo $((${TIME_END}-${TIME_BEGIN})) > ${COMPLETION_MARKER}.time 164 | du -mxs $IMGROOT > ${COMPLETION_MARKER}.size-post 165 | if [ -d $IMGROOT/var/lib/rpm ]; then 166 | $RPM_QUERY > ${COMPLETION_MARKER}.rpms-post 167 | fi 168 | touch $COMPLETION_MARKER 169 | echo " done" 170 | else 171 | echo " (skipping)" 172 | fi 173 | } 174 | 175 | 176 | 177 | pack_image() { 178 | 179 | local _OUTPUT_AREA 180 | 181 | case $IMAGE_BACKEND in 182 | xcat ) 183 | if [[ "$(egrep -v ':(\*|!!|x):' /etc/shadow | wc -l)" != 0 ]]; then 184 | echo "Password hashes were found in /etc/shadow" 185 | echo "packimage.pm may copy these hashes into the image." 186 | echo "This is probably not what you want." 187 | echo "The pack process will be aborted." 188 | echo "" 189 | echo "You must remove these hashes from /etc/shadow before" 190 | echo "the pack process will succeed." 191 | echo "" 192 | echo "Note that /etc/shadow is read by the xcatd daemon," 193 | echo "so any changes must be made within the context visible" 194 | echo "to xcatd." 195 | false 196 | fi 197 | 198 | _OUTPUT_AREA="${XCAT_NETBOOT_DIR}" 199 | ;; 200 | rinse ) 201 | _OUTPUT_AREA="${TMP_AREA}/_out/" 202 | ;; 203 | * ) 204 | fail "Unsupported \$IMAGE_BACKEND $IMAGE_BACKEND" 205 | ;; 206 | esac 207 | 208 | EXTRACT_DIR="${_OUTPUT_AREA}/${IMAGE_OUTPUT_NAME}.${TAG_NAME}/" 209 | if [ -d $EXTRACT_DIR ]; then 210 | echo "${EXTRACT_DIR} already exists." 211 | echo "Please manually move it aside." 212 | false 213 | fi 214 | 215 | mkdir -p ${EXTRACT_DIR} 216 | cd ${EXTRACT_DIR} 217 | 218 | echo -n "Checking out $TAG_PATH... " 219 | echo $TAG_PATH | $FSVS urls load >/dev/null 220 | $FSVS sync-repos >/dev/null 221 | $FSVS co $TAG_PATH >/dev/null 222 | echo "done" 223 | 224 | echo "Packing into ${EXTRACT_DIR}:" 225 | 226 | cd "${_OUTPUT_AREA}" 227 | 228 | if [ -d $IMAGE_OUTPUT_NAME ]; then 229 | mv $IMAGE_OUTPUT_NAME ${IMAGE_OUTPUT_NAME}.moved.aside.on.$(date +%Y-%m-%d-%H-%M-%S) 230 | fi 231 | 232 | ln -s "$EXTRACT_DIR" "$IMAGE_OUTPUT_NAME" 233 | cd "$IMAGE_OUTPUT_NAME/" 234 | 235 | # Pack addons 236 | if [ -d ./addons ]; then 237 | _OLDWD="$(pwd)" 238 | 239 | cd ./addons/ 240 | 241 | local _ADDONS="$(echo *)" 242 | local _ADDON_COUNT="$(echo "$_ADDONS" | wc -w)" 243 | 244 | local _COUNTER=0 245 | 246 | for _ADDON in $_ADDONS; do 247 | _COUNTER=$((${_COUNTER}+1)) 248 | echo -n "Packing addon ${_COUNTER}/${_ADDON_COUNT} ($_ADDON)... " 249 | cd $_ADDON && find . | cpio -oHcrc | gzip > ../${_ADDON}.cpio.gz && cd - >/dev/null 250 | done 251 | cd "$_OLDWD" 252 | fi 253 | 254 | case $IMAGE_BACKEND in 255 | xcat ) 256 | echo "Running packimage" 257 | packimage -a ${ARCH} -p $IMAGE_OUTPUT_NAME -o ${OS} 258 | echo "Packimage completed" 259 | ;; 260 | rinse ) 261 | echo -n "Packing image... " 262 | cd ./rootimg/ && find . | cpio -oHcrc | gzip > ../rootimg.cpio.gz && cd - >/dev/null 263 | IMGGZ="${EXTRACT_DIR}/rootimg.cpio.gz" 264 | ;; 265 | esac 266 | } 267 | 268 | xcat_image_metadata() { 269 | lsdef -t osimage ${OS}-${ARCH}-netboot-${PROFILE} -l 270 | } 271 | 272 | pack_sanitycheck () { 273 | SIZE_IN_MB=$(du -m $IMGGZ | awk '{print $1}') 274 | if [ $SIZE_IN_MB -gt 4096 ]; then 275 | echo "*** $IMGGZ is larger than 4096M" 276 | return -1 277 | fi 278 | } 279 | 280 | do_tag() { 281 | 282 | check_args_tag 283 | 284 | sleep_5 285 | 286 | create_tag 287 | } 288 | 289 | do_list_tags() { 290 | check_args_list_tags 291 | 292 | list_tags 293 | } 294 | 295 | do_diff() { 296 | check_args_diff 297 | 298 | diff_from_scm 299 | } 300 | 301 | do_pack() { 302 | check_args_pack 303 | 304 | sleep_5 305 | 306 | pack_image 307 | 308 | pack_sanitycheck 309 | } 310 | 311 | do_create() { 312 | check_args_create 313 | 314 | sleep_5 315 | 316 | prep_build_dir 317 | 318 | image_buildenv_prep 319 | 320 | run_step prepare_image_directory 321 | 322 | run_step generate_image 323 | 324 | mount_fs 325 | 326 | image_specialize 327 | 328 | umount_fs || /bin/true 329 | 330 | print_setuid 331 | 332 | commit_to_scm 333 | 334 | print_stats 335 | 336 | if [ ! -z "$PACK_ON_COMPLETION" ]; then 337 | echo "* Launching tag process as requested: " 338 | do_tag 339 | echo "* Launching pack process as requested: " 340 | do_pack 341 | fi 342 | 343 | echo "Image $PROFILE created" 344 | } 345 | 346 | do_env() { 347 | echo export FSVS_REPOSITORY=${FSVS_REPOSITORY} 348 | #print_env 349 | } 350 | 351 | 352 | img_main() { 353 | get_mode "$@" 354 | shift 355 | 356 | parse_args "$@" 357 | 358 | check_args_common 359 | 360 | image_mgr_specialize 361 | 362 | check_args_specialized 363 | 364 | case $MODE in 365 | "create" ) do_create "$@" ;; 366 | "tag" ) do_tag "$@" ;; 367 | "list_tags" ) do_list_tags "$@" ;; 368 | "pack" ) do_pack "$@" ;; 369 | "diff" ) do_diff "$@" ;; 370 | "env" ) do_env "$@" ;; 371 | esac 372 | } 373 | 374 | image_mgr_main() { 375 | env | grep '^__IMG_MGR_LOG=' >/dev/null 2>&1 || export __IMG_MGR_LOG=$(mklog image_mgr) 376 | 377 | echo "Logging to $__IMG_MGR_LOG" >&2 378 | 379 | 380 | subshell_inc 381 | img_main "$@" 2>&1 | tee -a $__IMG_MGR_LOG 382 | subshell_dec 383 | 384 | local _STATUS=${PIPESTATUS[0]} 385 | 386 | _umount_all 387 | 388 | return $_STATUS 389 | } 390 | 391 | subshell_inc() { 392 | TOP_SUBSHELL_LEVEL=$((${TOP_SUBSHELL_LEVEL}+1)) 393 | } 394 | 395 | subshell_dec() { 396 | TOP_SUBSHELL_LEVEL=$((${TOP_SUBSHELL_LEVEL}-1)) 397 | } 398 | 399 | image_buildenv_prep() { 400 | true 401 | } 402 | 403 | image_specialize() { 404 | run_step build_prep 405 | 406 | run_step setup_yum_repos 407 | 408 | run_step cleanup 409 | } 410 | 411 | -------------------------------------------------------------------------------- /src/include/image_mgr_core.d/args: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | usage_and_fail () { 24 | usage 25 | fail "Invalid usage" 26 | } 27 | 28 | usage () { 29 | echo -e "\nUsage:" 30 | echo "`basename $0` create -p profile -o os -a arch -u your_username -m commit_message [ -b ] [ -n ] [ -f ] [ -s fsvs_repository ]" 31 | echo "`basename $0` diff -p profile -o os -a arch -t :[]" 32 | echo "`basename $0` diff -p profile -o os -a arch -r :[]" 33 | echo "`basename $0` list-tags -p profile -o os -a arch [ -s fsvs_repository ]" 34 | echo "`basename $0` pack -p profile -o os -a arch -t tag [ -s fsvs_repository ]" 35 | echo "`basename $0` tag -p profile -o os -a arch -u your_username [ -r revision (default: HEAD) ] [ -m commit_message ] [ -s fsvs_repository ]" 36 | } 37 | 38 | get_mode () { 39 | if [ $# -lt 1 ]; then 40 | error "No mode provided" 41 | fi 42 | 43 | case $1 in 44 | "create" ) MODE="create" ;; 45 | "tag" ) MODE="tag" ;; 46 | "list-tags" ) MODE="list_tags" ;; 47 | "list_tags" ) MODE="list_tags" ;; 48 | "diff" ) MODE="diff" ;; 49 | "pack" ) MODE="pack" ;; 50 | "env" ) MODE="env" ;; 51 | * ) error "Unknown mode: $1" ;; 52 | esac 53 | 54 | } 55 | 56 | print_env () { 57 | parse_args 58 | env 59 | } 60 | 61 | parse_args () { 62 | 63 | while getopts "o:a:p:u:m:s:r:t:x:befn" OPTION; do 64 | case $OPTION in 65 | o ) OS="$OPTARG" ;; 66 | a ) ARCH="$OPTARG" ;; 67 | p ) PROFILE="$OPTARG" ;; 68 | u ) USER_NAME="$OPTARG" ;; 69 | m ) COMMIT_MESSAGE="$OPTARG" ;; 70 | s ) FSVS_REPOSITORY="$OPTARG" ;; 71 | r ) TAG_REVISION="$OPTARG" ;; 72 | t ) TAG_NAME="$OPTARG" ;; 73 | b ) ATTEMPT_RESUME=1 ;; 74 | f ) PACK_ON_COMPLETION=1 ;; 75 | x ) MASQUERADE_IMAGE="$OPTARG" ;; 76 | e ) print_env ;; 77 | n ) BASE_ONLY=1 ;; 78 | * ) usage_and_fail ;; 79 | esac 80 | done 81 | } 82 | 83 | check_args_specialized () { 84 | 85 | 86 | # If a custom FSVS_REPOSITORY was not specified, then construct a 87 | # URI based on the settings for SVNPROTO, SVNHOST, and 88 | # SVN_REPO_DIR 89 | 90 | local _FSVS_URI_PREFIX="${SVNPROTO}://${SVNHOST}" 91 | local _FSVS_URI_REPO_BASE="${_FSVS_URI_PREFIX}${SVN_REPO_DIR}" 92 | if [ -z "$FSVS_REPOSITORY" ]; then 93 | 94 | FSVS_REPOSITORY="${_FSVS_URI_REPO_BASE}/netboot/${OS}/${ARCH}/${PROFILE}" 95 | 96 | # Additionally, for file-based repositories, ensure the 97 | # repository directory exists: 98 | 99 | if [[ "${_FSVS_URI_PREFIX}" == "file://" ]]; then 100 | if [ ! -e "${SVN_REPO_DIR}" ]; then 101 | mkdir -p "${SVN_REPO_DIR}" 102 | svnadmin create "${SVN_REPO_DIR}" 103 | fi 104 | fi 105 | 106 | # Ensure that the repository is accessible 107 | svn info "${_FSVS_URI_REPO_BASE}" >/dev/null 108 | fi 109 | 110 | 111 | # Create the directory skeleton if it does not already exist 112 | for _DIR in "${FSVS_REPOSITORY}"/{trunk,tags,branches}; do 113 | svn info "${_DIR}" &>/dev/null || \ 114 | svn mkdir --parents \ 115 | -m "Automatically creating directory skeleton" "${_DIR}" 116 | # Ensure the creation was successful 117 | svn info "${_DIR}" >/dev/null 118 | done 119 | 120 | if [ -z "$TAG_REVISION" ]; then 121 | TAG_REVISION="HEAD" 122 | fi 123 | 124 | } 125 | 126 | check_args_common () { 127 | for REQUIRED_OPTION in \ 128 | x${OS} \ 129 | x${ARCH} \ 130 | x${PROFILE} \ 131 | ; do 132 | 133 | if [ "${REQUIRED_OPTION}" == "x" ]; then 134 | echo -e "\nError: -u, -o, -a, and -p are required" 135 | usage_and_fail 136 | fi 137 | done 138 | 139 | OS_MAJOR_VERSION=$(echo $OS | cut -d . -f 1) 140 | OS_RELEASE=$(echo $OS | cut -d . -f 2) 141 | 142 | case $OS_MAJOR_VERSION in 143 | rhels5 ) 144 | OS_FAMILY=el5 145 | ;; 146 | rhels6 ) 147 | OS_FAMILY=el6 148 | OS_RELEASE=6.${OS_RELEASE} 149 | ;; 150 | rhel7|rhels7b ) 151 | OS_FAMILY=el7 152 | OS_RELEASE=7.0 153 | ;; 154 | SL7 ) 155 | OS_FAMILY=el7 156 | OS_RELEASE=7.0 157 | ;; 158 | SL6 ) 159 | OS_FAMILY=el6 160 | OS_RELEASE=6.${OS_RELEASE} 161 | ;; 162 | SL5 ) 163 | OS_FAMILY=el5 164 | OS_RELEASE=5.${OS_RELEASE} 165 | ;; 166 | fedora ) 167 | case $OS_RELEASE in 168 | 18 ) 169 | OS_FAMILY=el7 170 | OS_RELEASE=18 171 | ;; 172 | * ) 173 | echo -e "\nError: Unsupported Fedora release $OS_RELEASE" 174 | usage_and_fail 175 | ;; 176 | esac 177 | ;; 178 | * ) 179 | echo -e "\nError: Unable to determine kernel for $OS" 180 | usage_and_fail 181 | ;; 182 | esac 183 | 184 | } 185 | 186 | check_args_list_tags () { 187 | for REQUIRED_OPTION in \ 188 | x${OS} \ 189 | x${ARCH} \ 190 | x${PROFILE} \ 191 | ; do 192 | 193 | if [ "${REQUIRED_OPTION}" == "x" ]; then 194 | echo -e "\nError: -u, -o, -a, and -p are required" 195 | usage_and_fail 196 | fi 197 | done 198 | 199 | } 200 | 201 | check_args_diff () { 202 | 203 | _TAG_ARG_COUNT=0 204 | _DIFF_MODE="" 205 | 206 | 207 | for REQUIRED_OPTION in \ 208 | x${OS} \ 209 | x${ARCH} \ 210 | x${PROFILE} \ 211 | ; do 212 | 213 | if [ "${REQUIRED_OPTION}" == "x" ]; then 214 | echo -e "\nError: -u, -o, -a, -r, and -p are required" 215 | usage_and_fail 216 | fi 217 | done 218 | 219 | if [ "${TAG_REVISION}" != "HEAD" ]; then 220 | _TAG_ARG_COUNT=$((${_TAG_ARG_COUNT}+1)) 221 | _DIFF_MODE="by-revision" 222 | fi 223 | 224 | if [ "x${TAG_NAME}" != "x" ]; then 225 | _TAG_ARG_COUNT=$((${_TAG_ARG_COUNT}+1)) 226 | _DIFF_MODE="by-tag" 227 | fi 228 | 229 | if [ $_TAG_ARG_COUNT -ne 1 ]; then 230 | echo -e "\nError: Exactly one of -r or -t are required" 231 | usage_and_fail 232 | fi 233 | 234 | # Process $TAG_REVISION or $TAG_NAME as follows: 235 | # If $TAG_x does not include a colon delimeter, assume it 236 | # is the old revision number or tag name and that the new 237 | # revision/tag is HEAD/trunk 238 | # 239 | # If a colon delimiter is present, assume $TAG_x is of the 240 | # form ${DIFF_OLD_{REVISION,TAG}}:${DIFF_NEW_${REVISION,TAG}} 241 | 242 | case $_DIFF_MODE in 243 | "by-revision" ) 244 | 245 | DIFF_OLD_REVISION=$(echo "${TAG_REVISION}:" | cut -d : -f 1) 246 | DIFF_NEW_REVISION=$(echo "${TAG_REVISION}:" | cut -d : -f 2) 247 | 248 | if [ -z ${DIFF_NEW_REVISION} ]; then 249 | DIFF_NEW_REVISION="HEAD" 250 | fi 251 | 252 | DIFF_OLD_PATH="/trunk" 253 | DIFF_NEW_PATH="/trunk" 254 | ;; 255 | "by-tag" ) 256 | 257 | DIFF_OLD_PATH="/tags/"$(echo "${TAG_NAME}:" | cut -d : -f 1)"/" 258 | DIFF_NEW_PATH="/tags/"$(echo "${TAG_NAME}:" | cut -d : -f 2)"/" 259 | 260 | if [ "${DIFF_NEW_PATH}" == "/tags//" ]; then 261 | DIFF_NEW_PATH="/trunk/" 262 | fi 263 | 264 | DIFF_OLD_REVISION="HEAD" 265 | DIFF_NEW_REVISION="HEAD" 266 | 267 | ;; 268 | * ) 269 | echo -e "\nError: invalid diff mode $_DIFF_MODE" 270 | usage_and_fail 271 | ;; 272 | esac 273 | 274 | echo 275 | echo "# Diffing image for:" 276 | echo "# OS: ${OS} (Kernel: $KERNEL)" 277 | echo "# Arch: ${ARCH}" 278 | echo "# Profile: ${PROFILE}" 279 | echo 280 | echo "# Old revision: ${DIFF_OLD_REVISION}" 281 | echo "# New revision: ${DIFF_NEW_REVISION}" 282 | echo 283 | echo "# Old path: ${DIFF_OLD_PATH}" 284 | echo "# New path: ${DIFF_NEW_PATH}" 285 | echo 286 | 287 | } 288 | 289 | 290 | check_args_tag () { 291 | for REQUIRED_OPTION in \ 292 | x${USER_NAME} \ 293 | x${OS} \ 294 | x${ARCH} \ 295 | x${PROFILE} \ 296 | ; do 297 | 298 | if [ "${REQUIRED_OPTION}" == "x" ]; then 299 | echo -e "\nError: -u, -o, -a, and -p are required" 300 | usage_and_fail 301 | fi 302 | done 303 | 304 | if [ -z "$TAG_NAME" ]; then 305 | TAG_NAME="${DATESTAMP}-RELEASE-by-${USER_NAME}" 306 | fi 307 | 308 | if [ -z "$COMMIT_MESSAGE" ]; then 309 | COMMIT_MESSAGE="Tag created at ${DATESTAMP} by ${USER_NAME}" 310 | fi 311 | 312 | TAG_PATH="${FSVS_REPOSITORY}/tags/${TAG_NAME}" 313 | 314 | echo 315 | echo "Tagging image for:" 316 | echo "OS: ${OS}" 317 | echo "Arch: ${ARCH}" 318 | echo "Profile: ${PROFILE}" 319 | echo "Revision: ${TAG_REVISION}" 320 | echo 321 | echo "${FSVS_REPOSITORY}/trunk/ at revision ${TAG_REVISION} will be tagged as ${TAG_PATH}" 322 | } 323 | 324 | check_args_pack () { 325 | for REQUIRED_OPTION in \ 326 | x${TAG_NAME} \ 327 | x${OS} \ 328 | x${ARCH} \ 329 | x${PROFILE} \ 330 | ; do 331 | 332 | if [ "${REQUIRED_OPTION}" == "x" ]; then 333 | echo -e "\nError: -t, -o, -a, and -p are required" 334 | usage_and_fail 335 | fi 336 | done 337 | 338 | 339 | if [ ! -z "${MASQUERADE_IMAGE}" ]; then 340 | IMAGE_OUTPUT_NAME="${MASQUERADE_IMAGE}" 341 | else 342 | IMAGE_OUTPUT_NAME="${PROFILE}" 343 | fi 344 | 345 | XCAT_NETBOOT_DIR=/install/netboot/$OS/$ARCH/ 346 | IMGGZ=${XCAT_NETBOOT_DIR}/${IMAGE_OUTPUT_NAME}/rootimg.gz 347 | TAG_PATH="${FSVS_REPOSITORY}/tags/${TAG_NAME}" 348 | 349 | 350 | echo 351 | echo "Packing image for:" 352 | echo "OS: ${OS}" 353 | echo "Arch: ${ARCH}" 354 | echo "Profile: ${PROFILE}" 355 | echo "Tag name: ${TAG_NAME}" 356 | if [ ! -z "${MASQUERADE_IMAGE}" ]; then 357 | echo "Masquerade as: ${IMAGE_OUTPUT_NAME}" 358 | fi 359 | echo 360 | echo "${TAG_PATH} will be packed for the ${IMAGE_BACKEND} backend" 361 | } 362 | 363 | check_args_create () { 364 | for REQUIRED_OPTION in \ 365 | x${USER_NAME} \ 366 | x${COMMIT_MESSAGE} \ 367 | x${OS} \ 368 | x${ARCH} \ 369 | x${PROFILE} \ 370 | ; do 371 | 372 | if [ "${REQUIRED_OPTION}" == "x" ]; then 373 | echo -e "\nError: -u, -m, -o, -a, and -p are required" 374 | usage_and_fail 375 | fi 376 | done 377 | 378 | 379 | IMG_BASE_DIR=${BASE}/install/netboot/$OS/$ARCH/$PROFILE/ 380 | IMGROOT=${IMG_BASE_DIR}/rootimg 381 | RPM="_do_rpm" 382 | YUM="_do_yum" 383 | INSTALL="_do_install" 384 | INSTALL_ROOT="_do_install -o root -g root" 385 | 386 | #STAMP="$PROFILE-$ARCH-$OS" 387 | STAMP="$PROFILE" 388 | 389 | echo 390 | echo "Creating image for:" 391 | echo "OS: ${OS} (Kernel: $KERNEL)" 392 | echo "Arch: ${ARCH}" 393 | echo "Profile: ${PROFILE}" 394 | echo "Backend : ${IMAGE_BACKEND}" 395 | if [ ! -z "${MASQUERADE_IMAGE}" ]; then 396 | echo "Masquerade as: ${MASQUERADE_IMAGE}" 397 | fi 398 | echo "User name: ${USER_NAME}" 399 | echo "Commit message: ${COMMIT_MESSAGE}" 400 | echo 401 | echo "Log directory: ${LOG_DIR}" 402 | echo "Output will be committed to: ${FSVS_REPOSITORY}/trunk/" 403 | if [ ! -z "${ATTEMPT_RESUME}" ]; then 404 | echo "Will attempt to resume a previous build (-b flag passed)" 405 | fi 406 | if [ ! -z "${BASE_ONLY}" ]; then 407 | echo "Will build only the base image (-n flag passed)" 408 | fi 409 | if [ ! -z "${PACK_ON_COMPLETION}" ]; then 410 | echo "Will automatically tag and pack upon completion (-f flag passed)" 411 | fi 412 | 413 | } 414 | -------------------------------------------------------------------------------- /src/include/image.common.el.d/generate_image: -------------------------------------------------------------------------------- 1 | # Auto-Versioning Systems Image Manager, Copyright (c) 2013, The 2 | # Regents of the University of California, through Lawrence Berkeley 3 | # National Laboratory (subject to receipt of any required approvals 4 | # from the U.S. Dept. of Energy). All rights reserved. 5 | # 6 | # If you have questions about your rights to use or distribute this 7 | # software, please contact Berkeley Lab's Technology Transfer 8 | # Department at TTD@lbl.gov. 9 | # 10 | # NOTICE. This software is owned by the U.S. Department of Energy. 11 | # As such, the U.S. Government has been granted for itself and others 12 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 13 | # license in the Software to reproduce, prepare derivative works, and 14 | # perform publicly and display publicly. Beginning five (5) years 15 | # after the date permission to assert copyright is obtained from the 16 | # U.S. Department of Energy, and subject to any subsequent five (5) 17 | # year renewals, the U.S. Government is granted for itself and others 18 | # acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 19 | # license in the Software to reproduce, prepare derivative works, 20 | # distribute copies to the public, perform publicly and display 21 | # publicly, and to permit others to do so. 22 | 23 | 24 | # generate_image 25 | # Create the most minimal EL image as possible 26 | # inside the build directory. Use the specified 27 | # generate_image_backend. 28 | generate_image() { 29 | 30 | bind_mount "$(mktemp -d ${TMP_AREA}/image_mgr.XXXXXXXXXX)" /etc/yum.repos.d 31 | 32 | # Create a minimal list of packages 33 | local _TMP_PKGLIST="$(mktemp ${TMP_AREA}/image_mgr.XXXXXXXXXX)" 34 | print_minimal_pkglist > $_TMP_PKGLIST 35 | 36 | local _IMAGEMETADATA 37 | local _PKGLIST 38 | local _ROOTIMGDIR 39 | 40 | local _TMP_RINSE_SYSCONFDIR 41 | local _TMP_RINSE_LIBDIR 42 | 43 | case $IMAGE_BACKEND in 44 | xcat ) 45 | # Gather information about this image from xCAT 46 | _IMAGEMETADATA="$(xcat_image_metadata)" 47 | 48 | _PKGLIST="$(echo "$_IMAGEMETADATA" | \ 49 | sed -ne 's/^\ *pkglist=\(.*\)$/\1/p')" 50 | 51 | _ROOTIMGDIR="$(echo "$_IMAGEMETADATA" | \ 52 | sed -ne 's/^\ *rootimgdir=\(.*\)$/\1/p')" 53 | 54 | if [ -z $_PKGLIST ]; then 55 | fail "No pkglist found; check osimage settings " \ 56 | "(lsdef -t osimage ${OS}-${ARCH}-netboot-${PROFILE} -l) " \ 57 | "and the osimage and linuximage tables" 58 | elif [ -z $_ROOTIMGDIR ]; then 59 | fail "No rootimgdir found; check osimage settings " \ 60 | "(lsdef -t osimage ${OS}-${ARCH}-netboot-${PROFILE} -l) " \ 61 | "and the osimage and linuximage tables" 62 | fi 63 | ;; 64 | rinse ) 65 | _TMP_RINSE_SYSCONFDIR="$(mktemp -d ${TMP_AREA}/image_mgr.rinse_confdir.XXXXXXXXXX)" 66 | _TMP_RINSE_LIBDIR="$(mktemp -d ${TMP_AREA}/image_mgr.rinse_libdir.XXXXXXXXXX)" 67 | 68 | bind_mount "$_TMP_RINSE_SYSCONFDIR" "$RINSE_SYSCONFDIR" 69 | bind_mount "$_TMP_RINSE_LIBDIR" "$RINSE_LIBDIR" 70 | 71 | _PKGLIST="${RINSE_SYSCONFDIR}/image_mgr.packages" 72 | sed -i 's/\.'${ARCH}'//g' "$_TMP_PKGLIST" 73 | sed -i 's/^-.*$//g' "$_TMP_PKGLIST" 74 | sed -i 's/^kernel.*$//g' "$_TMP_PKGLIST" 75 | 76 | cat "$_TMP_PKGLIST" 77 | 78 | _ROOTIMGDIR="${TMP_AREA}/_world" 79 | ;; 80 | * ) 81 | fail "Unsupported \$IMAGE_BACKEND $IMAGE_BACKEND" 82 | ;; 83 | esac 84 | 85 | 86 | # Mount our build area at the image root location 87 | bind_mount $IMG_BASE_DIR $_ROOTIMGDIR 88 | 89 | # Mount the provided pkglist at the target pkglist location 90 | bind_mount $_TMP_PKGLIST $_PKGLIST 91 | 92 | # Check that the image location now only contains 4 items: . 93 | # .. markers and rootimg 94 | if [[ "$(ls -a1 $_ROOTIMGDIR | wc -l)" != "4" ]]; then 95 | echo "$_ROOTIMGDIR is not a fresh build directory" 96 | echo "Only markers and rootimg should be present." 97 | ls -a1 $_ROOTIMGDIR 98 | return 1 99 | fi 100 | 101 | # Copy some default directories 102 | target_mkdir /etc 103 | target_mkdir /etc/rpm 104 | 105 | # Install default passwd, group, shadow, and MOTD 106 | install_file etc/group.netboot /etc/group 644 107 | install_file etc/motd.netboot /etc/motd 644 108 | install_file etc/passwd.netboot /etc/passwd 644 109 | install_file etc/shadow.netboot /etc/shadow 400 110 | 111 | # Create an RPM macros file 112 | if [[ "$INSTALL_DOCS" == "no" ]]; then 113 | echo '%_excludedocs 1' >> $IMGROOT/etc/rpm/macros 114 | fi 115 | if [[ "$INSTALL_LOCALES" != "" ]]; then 116 | echo '%_install_langs '"${INSTALL_LOCALES}" >> $IMGROOT/etc/rpm/macros 117 | fi 118 | 119 | # Mount this macros file at ${HOME}/.rpmmacros and /etc/rpm/macros 120 | bind_mount $IMGROOT/etc/rpm/macros ~/.rpmmacros 121 | bind_mount $IMGROOT/etc/rpm/macros /etc/rpm/macros 122 | 123 | 124 | case $IMAGE_BACKEND in 125 | xcat ) 126 | generate_image_xcat "$_ROOTIMGDIR" "$_PKGLIST" 127 | ;; 128 | rinse ) 129 | generate_image_rinse "$_ROOTIMGDIR" "$_PKGLIST" 130 | ;; 131 | esac 132 | 133 | # Unmount our pkglist and build area 134 | umount $_ROOTIMGDIR 135 | umount $_PKGLIST 136 | 137 | 138 | # Remove some packages that cannot be excluded in the packages 139 | # file. See 140 | # http://lists.centos.org/pipermail/centos/2009-April/075627.html 141 | # 142 | case $OS_FAMILY in 143 | el6 ) 144 | case $IMAGE_BACKEND in 145 | xcat ) 146 | # Removing util-linux-ng with yum and %_excludedocs set appears 147 | # not to work; use the "rpm" utility instead until a solution can 148 | # be found 149 | $YUM install rpm 150 | $RPM -e --nodeps util-linux-ng 151 | $YUM remove rpm 152 | ;; 153 | esac 154 | ;; 155 | esac 156 | 157 | case $OS_FAMILY in 158 | el5 ) 159 | $YUM remove slang usermode wireless-tools \ 160 | cryptsetup-luks dbus dmidecode \ 161 | hwdata libusb libxml2-python cyrus-sasl-lib \ 162 | libgpg-error libvolume_id pciutils logrotate 163 | ;; 164 | esac 165 | 166 | # Remove any stale OFED modules from the image 167 | rm -rf $IMGROOT/lib/modules/*/extra/ofa_kernel 168 | 169 | # Update the shadow file 170 | install_file etc/shadow.netboot /etc/shadow 400 171 | rm -f "$_TMP_PKGLIST" 172 | } 173 | 174 | # generate_image_xcat [rootimgdir] [pkglist] 175 | # Create an image using the xCAT backend. Use the genimage utility 176 | # provided by provide_genimage() 177 | generate_image_xcat () { 178 | 179 | local _ROOTIMGDIR="$1"; shift 180 | local _PKGLIST="$1"; shift 181 | 182 | # Set up symbolic links required by newer versions of Fedora 183 | case $OS_FAMILY in 184 | el[56] ) 185 | FS_PREFIX="" 186 | ;; 187 | el[7] ) 188 | FS_PREFIX="usr" 189 | install -d -m 755 -o root -g root "${IMGROOT}/usr/" 190 | for dir in sbin bin lib64 lib; do 191 | ln -sf "${FS_PREFIX}/${dir}" "${IMGROOT}/${dir}" 192 | mkdir "${IMGROOT}/${FS_PREFIX}/${dir}" 193 | done 194 | install -d -m 755 -o root -g root "${IMGROOT}/lib/modules/" 195 | ;; 196 | * ) 197 | echo "Unsupported \$OS_FAMILY $OS_FAMILY" 198 | ;; 199 | esac 200 | 201 | # Create some default directories 202 | target_mkdir "/${FS_PREFIX}/sbin" 203 | target_mkdir /dev 204 | 205 | GENIMAGE=$(provide_genimage) 206 | 207 | echo "Using genimage from $GENIMAGE" 208 | 209 | # Install "busybox.anaconda" and "nash" if they are present 210 | # in $IMAGEFILES. These are needed for initrds created 211 | # with old versions of genimage 212 | install_file busybox.anaconda /sbin/ 755 213 | install_file nash /sbin/ 755 214 | 215 | 216 | 217 | NET_MODULES="bnx2,tg3,forcedeth,igb,e1000,e1000e,virtio,virtio_pci,virtio_net" 218 | STORAGE_MODULES="sd_mod,scsi_transport_sas,mptscsih,mptsas,ata_piix,sata_nv,sata_mv,virtio_blk,auth_rpcgss" 219 | 220 | case $OS_FAMILY in 221 | el5 ) 222 | FS_MODULES="ext3" 223 | ;; 224 | el[67] ) 225 | FS_MODULES="ext3,ext4" 226 | target_mkdir /${FS_PREFIX}/lib/firmware 227 | for MODULE in $(echo $NET_MODULES $STORAGE_MODULES | tr ',' ' '); do 228 | if [ -e /lib/firmware/$MODULE ]; then 229 | rsync -avSH /lib/firmware/$MODULE $IMGROOT/lib/firmware/ 230 | fi 231 | done 232 | 233 | # Create a hotplug script to handle firmware load requests 234 | _TMP_HOTPLUG=$(mktemp ${TMP_AREA}/image_mgr.XXXXXXXXXX) 235 | cat > $_TMP_HOTPLUG << 'EOF' 236 | #!/sbin/busybox.anaconda sh 237 | echo "$0 active:" 238 | /sbin/busybox.anaconda sh 239 | env 240 | echo 1 > /sys/$DEVPATH/loading 241 | cat /lib/firmware/$FIRMWARE > /sys/$DEVPATH/data 242 | echo 0 > /sys/$DEVPATH/loading 243 | echo "$0 exiting" 244 | EOF 245 | install -o root -g root -m 755 \ 246 | $_TMP_HOTPLUG $IMGROOT/sbin/hotplug 247 | ;; 248 | * ) 249 | echo "Unsupported \$OS_FAMILY $OS_FAMILY" 250 | fail 251 | ;; 252 | esac 253 | 254 | 255 | # Hide the weak-updates area to prevent any links there from 256 | # being placed into the image by genimage 257 | case $OS_FAMILY in 258 | el* ) 259 | _WEAK_UPDATES="/lib/modules/${KERNEL}/weak-updates/" 260 | [ ! -d "$_WEAK_UPDATES" ] || \ 261 | bind_mount /var/empty "$_WEAK_UPDATES" 262 | ;; 263 | esac 264 | 265 | # Launch genimage with the following arguments: 266 | # -i: Interfaces to activate 267 | # -n: Modules to try loading before bringing up the network 268 | # -o: OS version 269 | # -p: xCAT profile to use 270 | # -l: Maximum size of / ramdisk (tmpfs) 271 | cd "$(dirname "$GENIMAGE")" 272 | PERL5LIB=/opt/xcat/share/xcat/netboot/imgutils/ "$GENIMAGE" \ 273 | -l ${ROOTSIZE}m \ 274 | -i eth0 \ 275 | -n ${NET_MODULES},${FS_MODULES},${STORAGE_MODULES} \ 276 | -a $ARCH \ 277 | -k $(kernel_variant) \ 278 | -o $OS \ 279 | -p $PROFILE \ 280 | 0>/dev/null 281 | 282 | case $OS_FAMILY in 283 | el5 ) 284 | mknod $IMGROOT/dev/rtc c 10 135 285 | ;; 286 | el6 ) 287 | $YUM remove dracut 288 | ;; 289 | esac 290 | 291 | 292 | } 293 | 294 | # Print a URL pointing to packages for $OS 295 | pkg_url () { 296 | case $OS_MAJOR_VERSION in 297 | SL5 ) 298 | echo "http://ftp.scientificlinux.org/linux/scientific/$(echo ${OS_RELEASE}|tr -d '.')/${ARCH}/SL/" 299 | ;; 300 | SL[67] ) 301 | echo "http://ftp.scientificlinux.org/linux/scientific/${OS_RELEASE}/${ARCH}/os/Packages/" 302 | ;; 303 | * ) 304 | fail "Unsupported \$OS_MAJOR_VERSION $OS_MAJOR_VERSION" 305 | ;; 306 | esac 307 | } 308 | 309 | # Print the most minimal pkglist possible for this image type 310 | print_minimal_pkglist () { 311 | 312 | # See http://lists.centos.org/pipermail/centos/2009-April/075627.html 313 | cat << EOF 314 | 315 | -audit-libs-python 316 | -checkpolicy 317 | -dhcpv6-client 318 | -ecryptfs-utils 319 | -ed 320 | -file 321 | -gnu-efi 322 | -gpm 323 | -hdparm 324 | -kbd 325 | -libhugetlbfs 326 | -libselinux-python 327 | -libsemanage 328 | -nspr 329 | -nss 330 | -perl 331 | -policycoreutils 332 | -prelink 333 | -selinux-policy 334 | -selinux-policy-targeted 335 | -setools 336 | -setserial 337 | -sysfsutils 338 | -tcl 339 | -udftools 340 | -vim-enhanced 341 | -kernel 342 | -openafs 343 | busybox.${ARCH} 344 | initscripts.${ARCH} 345 | kernel.${ARCH} 346 | rpm.${ARCH} 347 | sl-release 348 | util-linux-ng.${ARCH} 349 | EOF 350 | 351 | 352 | case $OS_MAJOR_VERSION in 353 | SL5) 354 | echo yum-conf-$(echo $OS_RELEASE | tr -d '.') 355 | echo yum-conf-sl5x 356 | echo rpm.${ARCH} 357 | cat << EOF 358 | audit-libs 359 | basesystem 360 | bash 361 | beecrypt 362 | binutils 363 | bzip2-libs 364 | centos-release 365 | chkconfig 366 | coreutils 367 | cpio 368 | cracklib 369 | cracklib-dicts 370 | crontabs 371 | db4 372 | device-mapper 373 | device-mapper-event 374 | device-mapper-multipath 375 | dmraid 376 | dmraid-events 377 | e2fsprogs 378 | e2fsprogs-libs 379 | elfutils-libelf 380 | ethtool 381 | expat 382 | filesystem 383 | findutils 384 | gawk 385 | gdbm 386 | glib2 387 | glibc 388 | glibc-common 389 | grep 390 | gzip 391 | hmaccalc 392 | info 393 | initscripts 394 | iproute 395 | iputils 396 | keyutils-libs 397 | keyutils-libs-devel 398 | kpartx 399 | krb5-libs 400 | less 401 | libacl 402 | libattr 403 | libcap 404 | libgcc 405 | libidn 406 | libselinux 407 | libsepol 408 | libstdc++ 409 | libsysfs 410 | libtermcap 411 | libxml2 412 | libxml2-python 413 | logrotate 414 | lvm2 415 | m2crypto 416 | MAKEDEV 417 | mcstrans 418 | mingetty 419 | mkinitrd 420 | mktemp 421 | module-init-tools 422 | nash 423 | ncurses 424 | neon 425 | net-tools 426 | nspr 427 | nss 428 | openssl 429 | pam 430 | pcre 431 | popt 432 | procps 433 | psmisc 434 | python 435 | python-elementtree 436 | python-iniparse 437 | python-libs 438 | python-libs 439 | python-sqlite 440 | python-urlgrabber 441 | readline 442 | rpm 443 | rpm-libs 444 | rpm-python 445 | sed 446 | setup 447 | sgpio 448 | shadow-utils 449 | sqlite 450 | sysklogd 451 | SysVinit 452 | tar 453 | termcap 454 | tzdata 455 | udev 456 | util-linux 457 | yum 458 | yum-autoupdate 459 | yum-metadata-parser 460 | zlib 461 | EOF 462 | ;; 463 | SL6) 464 | case $IMAGE_BACKEND in 465 | rinse ) 466 | cat << EOF 467 | audit-libs 468 | basesystem 469 | bash 470 | binutils 471 | bzip2-libs 472 | ca-certificates 473 | chkconfig 474 | compat-libtermcap 475 | coreutils 476 | coreutils-libs 477 | cpio 478 | cracklib 479 | cracklib-dicts 480 | cronie 481 | cronie-noanacron 482 | crontabs 483 | curl 484 | cyrus-sasl 485 | cyrus-sasl-lib 486 | dailyjobs 487 | db4 488 | db4-utils 489 | dbus-libs 490 | device-mapper 491 | device-mapper-libs 492 | e2fsprogs 493 | e2fsprogs-libs 494 | elfutils-libelf 495 | ethtool 496 | expat 497 | file-libs 498 | filesystem 499 | findutils 500 | gamin 501 | gawk 502 | gdbm 503 | glib2 504 | glibc 505 | glibc-common 506 | gmp 507 | gnupg2 508 | gnutls 509 | gpgme 510 | grep 511 | groff 512 | gzip 513 | hesiod 514 | hwdata 515 | info 516 | initscripts 517 | iproute 518 | iptables 519 | iputils 520 | keyutils-libs 521 | krb5-libs 522 | less 523 | libacl 524 | libattr 525 | libblkid 526 | libcap 527 | libcom_err 528 | libcurl 529 | libffi 530 | libgcc 531 | libgcrypt 532 | libgpg-error 533 | libidn 534 | libnih 535 | libproxy 536 | libproxy-bin 537 | libproxy-python 538 | libselinux 539 | libsepol 540 | libss 541 | libssh2 542 | libstdc++ 543 | libsysfs 544 | libtasn1 545 | libudev 546 | libusb 547 | libuser 548 | libutempter 549 | libuuid 550 | libxml2 551 | libxml2-python 552 | logrotate 553 | lua 554 | m2crypto 555 | MAKEDEV 556 | mcstrans 557 | mingetty 558 | mlocate 559 | module-init-tools 560 | ncurses 561 | ncurses-base 562 | ncurses-libs 563 | neon 564 | net-tools 565 | nspr 566 | nss 567 | nss-softokn 568 | nss-softokn-freebl 569 | nss-sysinit 570 | nss-tools 571 | nss-util 572 | openldap 573 | openssl 574 | pakchois 575 | pam 576 | passwd 577 | pcre 578 | pinentry 579 | popt 580 | procmail 581 | procps 582 | psmisc 583 | pth 584 | pygpgme 585 | python 586 | python-iniparse 587 | python-libs 588 | python-pycurl 589 | python-urlgrabber 590 | readline 591 | rpm 592 | rpm-libs 593 | rpm-python 594 | rsyslog 595 | sed 596 | sendmail 597 | setup 598 | shadow-utils 599 | sl-release 600 | sqlite 601 | sysvinit-tools 602 | tcp_wrappers-libs 603 | tzdata 604 | udev 605 | upstart 606 | util-linux-ng 607 | xz 608 | xz-libs 609 | yum 610 | yum-metadata-parser 611 | yum-plugin-fastestmirror 612 | yum-plugin-keys 613 | yum-plugin-protectbase 614 | yum-utils 615 | zlib 616 | EOF 617 | ;; 618 | esac 619 | ;; 620 | SL7) 621 | echo yum-conf-sl7x 622 | ;; 623 | esac 624 | 625 | 626 | } 627 | --------------------------------------------------------------------------------