Browse Source
git-svn-id: svn://svn.opensde.net/opensde/package/branches/udev@21268 10447126-35f2-4685-b0cf-6dd780d3921fearly
Alejandro Mery
18 years ago
1 changed files with 85 additions and 0 deletions
@ -0,0 +1,85 @@
|
||||
#!/bin/sh |
||||
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
||||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
||||
# |
||||
# Filename: package/.../mkinitrd/mkinitrd.sh |
||||
# Copyright (C) 2007 The OpenSDE Project |
||||
# |
||||
# More information can be found in the files COPYING and README. |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; version 2 of the License. A copy of the |
||||
# GNU General Public License can be found in the file COPYING. |
||||
# --- SDE-COPYRIGHT-NOTE-END --- |
||||
|
||||
set -e |
||||
|
||||
root= |
||||
kernever= |
||||
template= |
||||
running= |
||||
|
||||
mkinitrd_usage() { |
||||
cat <<-EOT |
||||
Usage: $0 [ -R <root> ] [ -T <template> ] [<kernelver>] |
||||
root.....: location of the sandbox to work in |
||||
(default: /) |
||||
template.: file to use as template for this image |
||||
(default: \$root/boot/initrd.img) |
||||
kernelver: kerner version to use when grabbing the |
||||
modules. (default: $( uname -r )) |
||||
EOT |
||||
} |
||||
|
||||
while [ $# -gt 1 ]; do |
||||
case "$1" in |
||||
-R) root="$2"; shift ;; |
||||
-T) template="$2"; shift ;; |
||||
[0-9]*) kernelver="$1" ;; |
||||
*) usage; exit 1 ;; |
||||
esac |
||||
shift |
||||
done |
||||
|
||||
# $root - root of the sandbox |
||||
[ "$root" ] || root="/" |
||||
if [ -d "$root" ]; then |
||||
echo "ERROR: '$root' is not a directory" |
||||
exit 2 |
||||
else |
||||
root=$( cd "$root"; pwd -P ) |
||||
echo "root: '$root'" |
||||
|
||||
[ "$root" != "/" ] || root="" |
||||
fi |
||||
|
||||
# $template - cpio.gz file to use as base for this initrd |
||||
[ "$template" ] || template="${root}/boot/initrd.img" |
||||
if [ ! -r "$template" ]; then |
||||
echo "ERROR: template '$template' not found." |
||||
exit 3 |
||||
else |
||||
echo "template: '${template#$root}'" |
||||
fi |
||||
|
||||
# $kernelver - kernel version, only useful if we have modules |
||||
if [ -z "$kernelver" ]; then |
||||
kernelver=$( uname -r ) |
||||
running=yes |
||||
fi |
||||
|
||||
moddir="${root}/lib/modules/$kernelver" |
||||
sysmap="${root}/boot/System.map_$kernelver" |
||||
if [ -d "$moddir" ]; then |
||||
echo "kernel: $kernelver, module dir: $moddir" |
||||
if [ ! -r "$sysmap" ]; then |
||||
echo "ERROR: System.map file not found." |
||||
exit 4 |
||||
fi |
||||
else |
||||
echo "kernel: $kernelver, no modules found." |
||||
moddir= |
||||
fi |
||||
|
||||
echo "done." |
Loading…
Reference in new issue