Kaydet (Commit) 58693f9a authored tarafından Your Name's avatar Your Name

tonla ayar çektim. efsane oldu moruq

üst 65f691b1
#!/bin/bash
[ ! -n "$KERNELVER" ] && KERNELVER=$(uname -r)
[ ! -n "$MODDIR" ] && MODDIR=/lib/modules/${KERNELVER}
if [ ! -d $MODDIR ] ; then
echo -e "\033[31;1mModule directory not found"
echo -e " ->$MODDIR\033[;0m"
exit 1
fi
echo -e " \033[34;1mKernel Version:\033[;0m ${KERNELVER}"
echo -e " \033[34;1mModule Directory:\033[;0m ${MODDIR}"
[ -d $MODDIR ] || err "Module directory not found -> $MODDIR"
debug "Kernel Version: ${KERNELVER}"
debug "Module Directory: ${MODDIR}"
mkdir -p ${WORKDIR}/${MODDIR}
echo -e " \033[34;1mInstall:\033[;0m main modules"
debug "Install: main modules"
cp -prf ${MODDIR}/kernel/{crypto,fs,lib} ${WORKDIR}/${MODDIR}
echo -e " \033[34;1mInstall:\033[;0m drivers"
debug "Install: drivers"
cp -prf ${MODDIR}/kernel/drivers/{block,ata,md,firewire} ${WORKDIR}/${MODDIR}
cp -prf ${MODDIR}/kernel/drivers/{scsi,pcmcia,virtio} ${WORKDIR}/${MODDIR}
cp -prf ${MODDIR}/kernel/drivers/usb/{host,storage} ${WORKDIR}/${MODDIR}
get_module_with_dep(){
name=$1
modinfo $name | grep filename | awk '{print $2}'
for i in $(modinfo $name | grep depends | awk '{print $2}' | sed "s/,/ /g")
do
modinfo $i | grep filename | awk '{print $2}'
done
}
add_extra_module(){
while read line
do
name=$(basename $line)
echo -e " \033[34;1mInstall:\033[;0m $name"
debug "Install: $name"
mkdir -p ${WORKDIR}/$line
rmdir ${WORKDIR}/$line
cat $line > ${WORKDIR}/$line
......
debug "Install busybox: $(which busybox)"
install $(which busybox) $WORKDIR/busybox >/dev/null
[ "$CONFIG" != "" ] || CONFIG=/etc/initrd.conf
echo -e " \033[34;1mUsing config:\033[;0m $CONFIG"
debug "Using config: $CONFIG"
mkdir -p ${WORKDIR}/etc
if [ -f $CONFIG ] ; then
cat ${CONFIG} > ${WORKDIR}/etc/initrd.conf
......
. /lib/initrd/common.sh
help_msg(){
cat << EOF
Usage $(basename $0) [OPTIONS]
Targeting options list:
OUPTUP Target initrd file output location.
WORKDIR Working directory. Created by mktemp command.
KERNELVER Target kernel version. Default is current kernel.
MODDIR Target module director. Default is current module directory.
CONFIG Used config file location. Default is /etc/initrd.conf
General option list:
-d / --debug Print debug log.
-k / --keep Do not remove working directory after building.
-h / --help Print this message.
-n / --no-color Disable colorized output.
-c / --no-cpio Do not generate initrd image.
-f / --fallback Generate fallback initrd image.
EOF
}
get_module_with_dep(){
name=$1
modinfo $name | grep filename | awk '{print $2}'
for i in $(modinfo $name | grep depends | awk '{print $2}' | sed "s/,/ /g")
do
modinfo $i | grep filename | awk '{print $2}'
done
}
parse_args(){
export src=/lib/initrd/
export WORKDIR=$(mktemp)
export OUTPUT=/boot/initrd.img-$(uname -r)
export nocolor=false
for i in $*
do
if [ "$i" == "-h" ] || [ "$i" == "--help" ] ; then
help_msg
exit 0
elif [ "$i" == "-d" ] || [ "$i" == "--debug" ]; then
export debug=true
elif [ "$i" == "-k" ] || [ "$i" == "--keep" ] ; then
export keepwordkir=true
elif [ "$i" == "-n" ] || [ "$i" == "--no-color" ] ; then
nocolor=true
elif [ "$i" == "-c" ] || [ "$i" == "--no-cpio" ] ; then
nocpio=true
elif [ "$i" == "-f" ] || [ "$i" == "--fallback" ] ; then
fallback=true
else
export $i
fi
done
}
generate_workdir(){
msg "Creating workdir $WORKDIR"
rm -f $WORKDIR
mkdir -p $WORKDIR
cp -prf $src/scripts $WORKDIR/scripts
for file in functions vars common init
do
install $src/$file.sh $WORKDIR/$file
done
}
modules_install(){
for i in $(ls $src/addons | sort)
do
inf "Install modules: $i"
. $src/addons/$i
done
}
generate_cpio(){
msg "Build: $OUTPUT "
cd $WORKDIR
if [ "$nocpio" != "true" ] ; then
echo -ne " ${C_GREEN}*${C_CLEAR} Generating: "
find . | cpio -R root:root -H newc -o | gzip > $OUTPUT
fi
if [ "$fallback" == "true" ] ; then
echo -ne " ${C_GREEN}*${C_CLEAR} Generating fallback: "
find . | cpio -R root:root -H newc -o | gzip > $OUTPUT-fallback
fi
}
clean_directory(){
if [ "$keepworkdir" == "true" ] ; then
rm -rf $WORKDIR
msg "Clearing workdir."
else
inf "Keeping workdir: $WORKDIR"
fi
}
#!/bin/bash
export src=/lib/initrd/
export WORKDIR=$(mktemp)
export OUTPUT=/boot/initrd.img-$(uname -r)
for i in $*
do
export $i
done
rm -f $WORKDIR
mkdir -p $WORKDIR
echo -e "\033[32;1mCreating workdir\033[;0m $WORKDIR"
cp -prf $src/scripts $WORKDIR/scripts
install $src/functions.sh $WORKDIR/functions
install $src/vars.sh $WORKDIR/vars
install $src/init.sh $WORKDIR/init
for i in $(ls $src/addons | sort)
do
echo -e "\033[32;1mInstall modules:\033[;0m $i"
. $src/addons/$i
done
echo -e "\033[32;1mInstall busybox:\033[;0m $(which busybox)"
install $(which busybox) $WORKDIR/busybox >/dev/null
cd $WORKDIR
echo -en "\033[32;1mBuild:\033[;0m $OUTPUT "
find . | cpio -R root:root -H newc -o | gzip > $OUTPUT
echo -e "\033[32;1mDone\033[;0m"
set -e
. /lib/initrd/build-functions.sh
parse_args $*
. /lib/initrd/common.sh
generate_workdir
modules_install
generate_cpio
clean_directory
if [ -t 0 ] && [ "$nocolor" == "false" ] ;then
C_BLACK='\e[1;30m'
C_RED='\e[1;31m'
C_GREEN='\e[1;32m'
C_YELLOW='\e[1;33m'
C_BLUE='\e[1;34m'
C_PURPLE='\e[1;35m'
C_CYAN='\e[1;36m'
C_WHITE='\e[1;37m'
C_CLEAR='\e[m'
fi
msg() {
echo -e " ${C_GREEN}*${C_CLEAR} ${@}"
}
inf() {
echo -e " ${C_CYAN}*${C_CLEAR} ${@}"
}
debug() {
[ ! -n "$debug" ] || echo -e " ${C_BLUE}*${C_CLEAR} ${@}"
}
warn() {
echo -e " ${C_YELLOW}*${C_CLEAR} ${@}"
}
err() {
echo -e " ${C_RED}*${C_CLEAR} ${@}"
}
#!/busybox ash
. /vars
. /etc/initrd.conf
. /common
. /functions
generate_rootfs
mount_handler
......
PATH=/bin:/usr/bin:/usr/sbin:/sbin
TERM=linux
rootfstype=ext4
if [ -t 0 ];then
C_BLACK='\e[1;30m'
C_RED='\e[1;31m'
C_GREEN='\e[1;32m'
C_YELLOW='\e[1;33m'
C_BLUE='\e[1;34m'
C_PURPLE='\e[1;35m'
C_CYAN='\e[1;36m'
C_WHITE='\e[1;37m'
C_CLEAR='\e[m'
fi
msg() {
echo -e " ${C_GREEN}*${C_CLEAR} ${@}"
}
debug() {
[ ! -n "$debug" ] || echo -e " ${C_BLUE}*${C_CLEAR} ${@}"
}
warn() {
echo -e " ${C_YELLOW}*${C_CLEAR} ${@}"
}
err() {
echo -e " ${C_RED}*${C_CLEAR} ${@}"
}
. /etc/initrd.conf
nocolor=false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment