[Frugalware-git] fw-initramfs: create_static.sh *for don't build static pkg every time we build initramfs *can be used into a fb for the final user don't build this pkg
bouleetbil
bouleetbil at frogdev.info
Sun Nov 8 19:15:56 CET 2009
Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fw-initramfs.git;a=commitdiff;h=04c76cebd8f68d8a6040941c559b49e2050221cd
commit 04c76cebd8f68d8a6040941c559b49e2050221cd
Author: bouleetbil <bouleetbil at frogdev.info>
Date: Sun Nov 8 19:21:22 2009 +0100
create_static.sh
*for don't build static pkg every time we build initramfs
*can be used into a fb for the final user don't build this pkg
diff --git a/create_static.sh b/create_static.sh
new file mode 100644
index 0000000..e3e6aa3
--- /dev/null
+++ b/create_static.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+#GNU General Public License Version
+#This program is free software; you can redistribute it and/or
+#modify it under the terms of the GNU General Public License
+#version 2 as published by the Free Software Foundation.
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+
+HOMESOURCE=/usr/share/fw-initramfs/
+. $HOMESOURCE/default.sh
+. $HOMESOURCE/create_functions.sh
+. $HOMESOURCE/modules.sh
+
+###############################################################
+#Sources for build some statics binary only used for build
+#initramfs
+###############################################################
+REDHAT_URL="ftp://sources.redhat.com/pub/"
+DM_URL="http://www.kernel.org/pub/linux/utils/raid/mdadm/"
+
+#TODO build it
+#busybox
+BUSYBOX_URL="http://www.busybox.net/downloads"
+
+#lvm2
+LVM2_VERS='2.02.53'
+LVM2_SOURCE="lvm2/LVM2.${LVM2_VERS}.tgz"
+LVM2_ARCHIVE="LVM2.${LVM2_VERS}.tgz"
+LVM2_DIR="LVM2.${LVM2_VERS}"
+
+#mdadm
+DMRAID_VERS='3.0'
+DMRAID_SOURCE="mdadm-${DMRAID_VERS}.tar.bz2"
+DMRAID_ARCHIVE="mdadm-${DMRAID_VERS}.tar.bz2"
+DMRAID_DIR="mdadm-${DMRAID_VERS}"
+
+##########################################################
+#Some functions for build static binary
+##########################################################
+Download_Archive() {
+ good_msg "Download $2"
+ wget $1
+}
+
+Build_Lvm2() {
+ if [ ! -f "${DESTBUILD}/lvm/sbin/dmsetup.static" ]
+ then
+ mkdir -p $DESTBUILD
+ cd $DESTBUILD
+ if [ ! -f "${LVM2_ARCHIVE}" ]
+ then
+ #If don't find archive we download it
+ Download_Archive ${REDHAT_URL}${LVM2_SOURCE} "LVM2"
+ fi
+ rm -rf ${LVM2_DIR} > /dev/null
+ tar -zxpf ${LVM2_ARCHIVE}
+ if [ ! -d "${LVM2_DIR}" ]
+ then
+ die_msg 'LVM2 directory invalid'
+ fi
+ #time to build it!
+ cd ${LVM2_DIR}
+ good_msg "Build LVM2"
+ unset MAKEFLAGS
+ ./configure --enable-static_link --prefix=${DESTBUILD}/lvm >> ${LOGFILE} 2>&1 ||
+ die_msg 'Configure of lvm failed!'
+ make >> ${LOGFILE} 2>&1 || die_msg 'make lvm2 failed!'
+ make install >> ${LOGFILE} 2>&1 || die_msg 'make install lvm2 failed!'
+ make device-mapper || die_msg 'make lvm2 failed!'
+ make install >> ${LOGFILE} 2>&1 || die_msg 'make install device-mapper failed!'
+ strip "${DESTBUILD}/lvm/sbin/lvm.static" ||
+ die_msg 'Could not strip lvm binary!'
+ strip "${DESTBUILD}/lvm/sbin/dmsetup.static" ||
+ die_msg 'Could not strip dmsetup binary!'
+ rm -rf ${DESTBUILD}/${LVM2_DIR}
+ fi
+}
+
+Build_Mdadm() {
+ if [ ! -f "${DESTBUILD}/mdadm/sbin/mdadm" ]
+ then
+ mkdir -p $DESTBUILD
+ cd $DESTBUILD
+ if [ ! -f "${DMRAID_ARCHIVE}" ]
+ then
+ #If don't find archive we download it
+ Download_Archive ${DM_URL}${DMRAID_SOURCE} "mdadm"
+ fi
+ rm -rf ${DMRAID_DIR} > /dev/null
+ tar -jxf ${DMRAID_ARCHIVE}
+ if [ ! -d "${DMRAID_DIR}" ]
+ then
+ die_msg 'Mdadm directory invalid'
+ fi
+ #time to build it!
+ cd ${DMRAID_DIR}
+ good_msg "Build Mdadm"
+ export LDFLAGS="${LDFLAGS} -static"
+ make all mdassemble >> ${LOGFILE} 2>&1 || die_msg 'make Mdadm failed!'
+ make DESTDIR="${DESTBUILD}/mdadm" install >> ${LOGFILE} 2>&1 || die_msg 'make install Mdadm failed!'
+ strip "${DESTBUILD}/mdadm/sbin/mdadm" ||
+ die_msg 'Could not strip lvm binary!'
+ rm -rf ${DESTBUILD}/${DMRAID_DIR}
+ fi
+}
+
+build_Static() {
+ LOGFILE=${DESTBUILD}/log.txt
+ good_msg "log can be find into ${LOGFILE}"
+ good_msg "build static into ${DESTBUILD}"
+ Build_Lvm2
+ Build_Mdadm
+}
+
+op=$1
+shift
+
+if [ "$op" != "" ]; then
+ DESTBUILD=$op
+ build_Static
+fi
+
More information about the Frugalware-git
mailing list