Browse Source

内部 CVS から import

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@118 ec354946-7b23-47d6-9f5a-488ba84defc7
daisuke 15 years ago
commit
5918cda38d

+ 30 - 0
Makefile

@@ -0,0 +1,30 @@
+NAME=vbootstrap
+VERSION=$(shell awk '/%define version/ { print $$3 }' ${NAME}.spec)
+DEFAULT_VERSION=VineSeed
+
+DESTDIR=
+
+all:
+	sed -e "s/@@VBOOTSTRAP_VERSION@@/${VERSION}/g" vbootstrap.sh.in > vbootstrap.sh
+	sed -e "s/@@DEFAULT_VERSION@@/${DEFAULT_VERSION}/g" vbuilder.sh.in > vbuilder.sh
+
+install:
+	install -d ${DESTDIR}/usr/share/vbootstrap/{scripts,sources.list.d}
+	install -d ${DESTDIR}/usr/sbin
+	install -m 644 vbootstrap/scripts/* ${DESTDIR}/usr/share/vbootstrap/scripts/
+	install -m 644 vbootstrap/sources.list.d/* ${DESTDIR}/usr/share/vbootstrap/sources.list.d
+	install -m 755 vbootstrap.sh ${DESTDIR}/usr/sbin/vbootstrap
+	install -m 755 vbuilder.sh ${DESTDIR}/usr/sbin/vbuilder
+
+tarbz2: clean
+	cd .. && rm -rf ${NAME}-${VERSION}
+	cd .. && cp -arf ${NAME} ${NAME}-${VERSION}
+	cd .. && tar --exclude CVS -cf - ${NAME}-${VERSION} | bzip2 -9 > ${NAME}-${VERSION}.tar.bz2
+	mv ../${NAME}-${VERSION}.tar.bz2 ~/rpm/SOURCES/
+	rm -rf ${NAME}-${VERSION}
+
+rpm: tarbz2
+	rpm -ba ${NAME}.spec
+
+clean:
+	rm -fr *~ .*???~ vbootstrap.sh

+ 95 - 0
vbootstrap.sh.in

@@ -0,0 +1,95 @@
+#!/bin/bash
+
+VERSION=@@VBOOTSTRAP_VERSION@@
+
+##
+
+VBOOTSTRAPDIR="/usr/share/vbootstrap"
+SUPPORTED_VERSION="$(ls $VBOOTSTRAPDIR/scripts/)"
+
+##
+
+usage()
+{
+  echo "Usage: vbootstrap <version> <targetdir>"
+  echo "  supported version:"
+  for ver in $SUPPORTED_VERSION
+  do
+    echo "    $ver"
+  done
+}
+
+##
+
+if [ "$(id -u)" != "0" ]
+then
+  usage
+  echo "E: You should run vbooststrap as super user."
+  exit 0
+fi
+
+if ! [ $# -eq 2 ]
+then
+  usage
+  echo "E: You must specify a vine version and target."
+  exit 0
+fi
+
+INSTVER=$1
+shift
+
+if [ -f "$VBOOTSTRAPDIR/scripts/$INSTVER" ]
+then
+  source $VBOOTSTRAPDIR/scripts/$INSTVER
+else
+  usage
+  echo "E: $INSTVER is not supported."
+  exit 0
+fi
+
+INSTDIR=$1
+shift
+
+if [ -d "$INSTDIR" ]
+then
+  echo "E: Specified directory \"$INSTDIR\" is already exists."
+  usage
+  exit 0
+fi
+
+##
+
+APT_OPTS="$APT_LINE -o RPM::RootDir=$INSTDIR -o Dir::Etc::sourceparts=$INSTDIR/etc/apt/sources.list.d "
+
+##
+
+# initialize rpm database
+echo "Initializing RPM database in $INSTDIR."
+mkdir -p $INSTDIR/var/lib/rpm
+rpm --initdb --root $INSTDIR
+
+# update apt database
+echo "update apt database."
+apt-get -qq $APT_OPTS update
+
+# misc setup files
+mkdir -p $INSTDIR/etc
+touch $INSTDIR/etc/mtab
+
+# create some device files
+mkdir $INSTDIR/dev
+mknod $INSTDIR/dev/null c 1 3
+mknod $INSTDIR/dev/console c 5 1
+
+# install base vine linux system.
+echo "Installing basesystem."
+for i in $BASE_PKGS
+do
+  apt-get -y -qq $APT_OPTS install $i
+done
+
+# run post install script
+vbootstrap_post
+
+echo "vboostrap done."
+

+ 70 - 0
vbootstrap.spec

@@ -0,0 +1,70 @@
+# This package is maintained with CVS. Please do not change on local.
+# If you find a BUG, report to Vine@vinelinux.org or mailing list or BTS.
+# $Id: vbootstrap.spec,v 1.4 2009/06/28 15:54:18 daisuke Exp $
+
+%define version 0.0.2
+
+Summary: bootstrap scripts to create a basic Vine Linux system
+Summary(ja): Vine Linux の基本システムを作成するためのスクリプト
+Name: vbootstrap
+Version: %{version}
+Release: 1%{?_dist_release}
+License: public domain
+Group: Development/Tools
+Url: http://trac.vinelinux.org/wiki/VineBootstrap
+
+Source0: %{name}-%{version}.tar.bz2
+
+Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
+BuildArch: noarch
+BuildRequires: sed
+Requires: bash, apt
+
+Vendor: Project Vine
+Distribution: Vine Linux
+Packager: daisuke, munepi
+
+%description
+vbootstrap is used to create a basic Vine Linux system on existing Vine Linux
+system. It uses rpm and apt to install basic rpm package into a directory
+which can be chrooted into.
+
+%description -l ja
+vbootstrap は Vine Linux の基本システムを既存の Vine Linux システム上で
+作成するスクリプトです。rpm および apt を利用して、指定したディレクトリ
+以下に基本の rpm パッケージをインストールし、chroot できるようにします。
+
+
+%prep
+[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
+
+%setup
+
+%build
+make
+
+%install
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%ifnarch x86_64
+rm -f $RPM_BUILD_ROOT%{_datadir}/vbootstrap/*/VineSeed_i386
+%endif
+
+%clean
+[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
+
+
+%files
+%defattr(-,root,root)
+%{_sbindir}/vbootstrap
+%{_sbindir}/vbuilder
+%dir %{_datadir}/vbootstrap
+%{_datadir}/vbootstrap/*
+
+
+%changelog
+* Mon Jun 29 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.0.2-1
+- add vbuilder
+
+* Wed Mar 18 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.0.1-1
+- initial build

+ 18 - 0
vbootstrap/scripts/4.2

@@ -0,0 +1,18 @@
+# Vine Linux 4.2
+
+INSTVER="4.2"
+BASE_PKGS="setup glibc coreutils bash rpm apt rootfiles"
+APT_LINE="-o Dir::Etc::sourcelist=$VBOOTSTRAPDIR/sources.list.d/$INSTVER"
+
+vbootstrap_post()
+{
+echo "running vbootstrap post install scripts for $INSTVER on $INSTDIR"
+cp -a /etc/resolv.conf $INSTDIR/etc/
+rm -f $INSTDIR/var/lib/rpm/__db.00*
+echo " rebuilding rpm database"
+chroot $INSTDIR rpm --rebuilddb
+echo " updating apt database"
+chroot $INSTDIR apt-get -qq update
+echo " installing vine-keyring"
+chroot $INSTDIR apt-get -qq -y --reinstall install vine-keyring
+}

+ 18 - 0
vbootstrap/scripts/VineSeed

@@ -0,0 +1,18 @@
+# VineSeed
+
+INSTVER="VineSeed"
+BASE_PKGS="setup glibc coreutils bash rpm apt rootfiles libstdc++34"
+APT_LINE="-o Dir::Etc::sourcelist=$VBOOTSTRAPDIR/sources.list.d/$INSTVER"
+
+vbootstrap_post()
+{
+echo "running vbootstrap post install scripts for $INSTVER on $INSTDIR"
+cp -a /etc/resolv.conf $INSTDIR/etc/
+rm -f $INSTDIR/var/lib/rpm/__db.00*
+echo " rebuilding rpm database"
+chroot $INSTDIR rpm --rebuilddb
+echo " updating apt database"
+chroot $INSTDIR apt-get -qq update
+echo " installing vine-keyring"
+chroot $INSTDIR apt-get -qq -y --reinstall install vine-keyring
+}

+ 18 - 0
vbootstrap/scripts/VineSeed_i386

@@ -0,0 +1,18 @@
+# VineSeed_i386
+
+INSTVER="VineSeed_i386"
+BASE_PKGS="setup glibc coreutils bash rpm apt rootfiles libstdc++34"
+APT_LINE="-o Dir::Etc::sourcelist=$VBOOTSTRAPDIR/sources.list.d/$INSTVER"
+
+vbootstrap_post()
+{
+echo "running vbootstrap post install scripts for $INSTVER on $INSTDIR"
+cp -a /etc/resolv.conf $INSTDIR/etc/
+rm -f $INSTDIR/var/lib/rpm/__db.00*
+echo " rebuilding rpm database"
+chroot $INSTDIR rpm --rebuilddb
+echo " updating apt database"
+chroot $INSTDIR apt-get -qq update
+echo " installing vine-keyring"
+chroot $INSTDIR apt-get -qq -y --reinstall install vine-keyring
+}

+ 1 - 0
vbootstrap/sources.list.d/4.2

@@ -0,0 +1 @@
+rpm http://updates.vinelinux.org/apt 4.2/$(ARCH) main plus updates

+ 1 - 0
vbootstrap/sources.list.d/VineSeed

@@ -0,0 +1 @@
+rpm http://updates.vinelinux.org/apt VineSeed/$(ARCH) main plus nonfree

+ 1 - 0
vbootstrap/sources.list.d/VineSeed_i386

@@ -0,0 +1 @@
+rpm http://updates.vinelinux.org/apt VineSeed/i386 main plus nonfree

+ 179 - 0
vbuilder.sh.in

@@ -0,0 +1,179 @@
+#!/bin/bash
+# -*- coding: utf-8-unix -*-
+
+## default settings
+VBOOTSTRAP_DIR=/var/local/vbootstrap
+[ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
+DEFAULT_VERSION=@@DEFAULT_VERSION@@
+VERSION=$DEFAULT_VERSION
+
+Usage(){
+    cat<<EOF
+Usage:	$(basename $0) {--version [version]} {--arch [arch]} {--with-compat32} {--build-rpm [src.rpm]|--install-rpm [arch.rpm]|--remove-rpm [package]|--build|--clean}
+	--version:		set [version] (default: ${DEFAULT_VERSION})
+	--arch:			set [arch] (default: $(uname -i))
+	--with-compat32:	build with compat32 on boostrap
+	--build-rpm:		build [src.rpm] on boostrap
+	--install-rpm:		install [arch.rpm] on boostrap
+	--remove-rpm:		remove [package] on boostrap
+	--build:		build boostrap of [version]
+	--clean:		clean boostrap of [version]
+
+For example, 
+* make plain build environment:
+$(basename $0) --clean --build
+* build source RPM:
+$(basename $0) --build-rpm [src.rpm]
+* make Vine Linux 4.2 environment:
+$(basename $0) --version 4.2 --clean --build
+* i386 chroot on x86_64:
+$(basename $0) --arch i386 --clean --build
+* build compat32:
+$(basename $0) --arch i386 --with-compat32 --build-rpm [src.rpm]
+EOF
+exit 1
+}
+
+FLAG_setup_vbootstrap=0
+setup-vbootstrap(){
+    if [ ${FLAG_setup_vbootstrap} -eq 0 ]; then
+	FLAG_setup_vbootstrap=1
+
+	[ -z ${VARCH} ] && VARCH=$(uname -i)
+	[ "${VARCH}" != "$(uname -i)" ] && VERSION=${VERSION}_${VARCH}
+	
+	BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
+	CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}
+	BUILD_DIR=/usr/src/vine
+    fi
+}
+
+##############################################################################
+
+Clean(){
+    setup-vbootstrap
+
+    umount ${BUILD_ROOT}/proc
+
+    if [ -d ${BUILD_ROOT}/var/cache/apt/archives ]; then
+	[ -d ${CACHE_DIR}/apt/archives ] || mkdir -p ${CACHE_DIR}/apt/archives
+	mv -f ${BUILD_ROOT}/var/cache/apt/archives/*.rpm ${CACHE_DIR}/apt/archives/
+    fi
+
+    rm -rf $BUILD_ROOT/
+}
+
+Build(){
+    setup-vbootstrap
+
+    /usr/sbin/vbootstrap ${VERSION} ${BUILD_ROOT}
+
+    [ -d ${BUILD_ROOT}/proc ] || mkdir -p ${BUILD_ROOT}/proc
+    mount -t proc proc ${BUILD_ROOT}/proc
+
+    [ -d ${CACHE_DIR} -a "${VARCH}" = "$(uname -i)" ] && \
+	cp -f ${CACHE_DIR}/apt/archives/*.rpm ${BUILD_ROOT}/var/cache/apt/archives/
+
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c 'apt-get update && apt-get -y dist-upgrade'
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c 'apt-get -y install apt-sourceslist-plus && apt-get update'
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c 'apt-get -y install apt-sourceslist-nonfree && apt-get update'
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c 'apt-get -y install build-essential self-build-setup'
+
+    /usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c 'cd /dev && /sbin/MAKEDEV console'
+    /usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c 'cd /dev && /sbin/MAKEDEV null'
+    /usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c 'cd /dev && /sbin/MAKEDEV zero'
+}
+
+setup-vbootstrap-rpm(){
+    setup-vbootstrap
+
+    if [ -f $RPM_PKG ]; then
+	BASE_RPM_PKG=$(basename $RPM_PKG)
+	cp -f $RPM_PKG $BUILD_ROOT${BUILD_DIR}
+    else
+	BASE_RPM_PKG=$RPM_PKG	
+    fi
+}
+
+RPM_Remove(){
+    setup-vbootstrap-rpm
+
+    if [ -f $RPM_PKG ]; then
+	echo "$RPM_PKG: not package name."
+	exit 1
+    fi
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "apt-get -y remove $BASE_RPM_PKG"
+}
+
+RPM_Install(){
+    setup-vbootstrap-rpm
+
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y install $BASE_RPM_PKG"
+}
+
+RPM_Build(){
+    setup-vbootstrap-rpm
+
+    if [ ! -f $RPM_PKG ]; then
+	echo "$RPM_PKG: not source RPM package."
+	exit 1
+    fi
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y build-dep $BASE_RPM_PKG"
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "cd ${BUILD_DIR} && rpmbuild --rebuild $RPM_OPTS $BASE_RPM_PKG"
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y install $(find $BUILD_ROOT${BUILD_DIR}/RPMS -type f -regex '.*\.rpm' | sed -e s@${BUILD_ROOT}@@g -e 's/$/ \\/g')"
+}
+
+
+[ $# -eq 0 ] && Usage 
+while [ $# -gt 0 ]; do
+    case "$1" in
+	--version)
+	    shift;
+	    VERSION=$1
+	    ;;
+	--arch)
+	    shift;
+	    VARCH=$1
+	    ;;
+	--with-compat32)
+	    RPM_OPTS="--with compat32"
+	    ;;
+	--build-rpm)
+	    shift;
+	    RPM_PKG=$1
+	    RPM_Build
+	    ;;
+	--install-rpm)
+	    shift;
+	    RPM_PKG=$1
+	    RPM_Install
+	    ;;
+	--remove-rpm)
+	    shift;
+	    RPM_PKG=$1
+	    RPM_Remove
+	    ;;
+	--build)
+	    Build
+	    ;;
+	--clean)
+	    Clean
+	    ;;
+	*)
+	    Usage
+	    ;;
+    esac
+    shift
+done
+
+exit
+