Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
alpine-conf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
18
Issues
18
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
alpine-conf
Commits
0cc00b53
Commit
0cc00b53
authored
Jul 15, 2015
by
Natanael Copa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup-bootable: warn and fix kernel name change
parent
2a97a54f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
9 deletions
+94
-9
setup-bootable.in
setup-bootable.in
+94
-9
No files found.
setup-bootable.in
View file @
0cc00b53
...
...
@@ -84,10 +84,87 @@ find_disk_dev() {
return
1
}
find_syslinux_cfg
()
{
# find where new syslinux.cfg is
for
i
in
boot/syslinux/syslinux.cfg syslinux.cfg
;
do
if
[
-e
"
$1
"
/
$i
]
;
then
syslinux_cfg
=
$i
vecho
"Found
$syslinux_cfg
"
break
fi
done
}
fix_syslinux_kernel
()
{
echo
"Fixing
$syslinux_cfg
: kernel
$1
->
$2
"
sed
-i
-e
"/^
\s
*[Kk][Ee][Rr][Nn][Ee][Ll]
\s
/s|
$1
|
$2
|"
\
"
$destdir
/
$syslinux_cfg
"
}
fix_syslinux_initrd
()
{
echo
"Fixing
$syslinux_cfg
: initrd
$1
->
$2
"
sed
-i
-e
"/^
\s
*[Ii][Nn][Ii][Tt][Rr][Dd]
\s
/s|
$1
|
$2
|"
\
-e
"/^
\s
*[Aa][Pp][Pp][Ee][Nn][Dd]
\s
/s|initrd=
$1
|initrd=
$2
|"
\
"
$destdir
/
$syslinux_cfg
"
}
check_syslinux
()
{
if
[
-z
"
$syslinux_cfg
"
]
;
then
find_syslinux_cfg
"
$destdir
"
fi
if
[
-z
"
$syslinux_cfg
"
]
;
then
die
"Could not find any syslinux.cfg. Aborting"
fi
# kernels
for
i
in
$(
awk
'tolower($1) == "kernel" {print $2}'
"
$destdir
"
/
$syslinux_cfg
)
;
do
k
=
"
${
destdir
%/
}
/
${
i
#/
}
"
f
=
${
k
##*/
}
if
[
-e
"
$k
"
]
&&
[
"
${
f
#vmlinuz
}
"
!=
"
$f
"
]
;
then
continue
fi
if
[
-e
"
${
k
%/*
}
"
/vmlinuz-
$f
]
&&
[
-n
"
$fix_syslinux_cfg
"
]
;
then
fix_syslinux_kernel
"
$i
"
"
${
i
%/*
}
"
/vmlinuz-
$f
elif
!
[
-e
"
$k
"
]
;
then
echo
"Warning:
$syslinux_cfg
: kernel
$k
was not found"
echo
" Run
$0
-c -f "
$destdir
" to fix"
fi
done
#initramfs
initrds
=
$(
awk
'tolower($1) == "initrd" {print $2}'
\
"
$destdir
"
/
$syslinux_cfg
)
for
i
in
$(
awk
'tolower($1) == "append" {print $0}'
\
"
$destdir
"
/
$syslinux_cfg
)
;
do
case
$i
in
initrd
=
*
)
initrds
=
${
i
#initrd=
}
;;
esac
done
for
i
in
$initrds
;
do
if
[
-e
"
$destdir
"
/
$i
]
;
then
continue
fi
fname
=
${
i
##*/
}
flavor
=
${
fname
%.gz
}
new
=
${
i
%/*
}
/initramfs-
$flavor
if
[
-e
"
$destdir
"
/
$new
]
&&
[
-n
"
$fix_syslinux_cfg
"
]
;
then
fix_syslinux_initrd
"
$i
"
"
$new
"
else
echo
"Warning: initrd
$i
was not found. System will likely not boot"
echo
" Run
$0
-f -c "
$destdir
" to fix"
fi
done
}
usage
()
{
cat
<<
__EOF__
$prog
$version
usage:
$prog
[-fhUusv] SOURCE [DEST]
$prog
-c DIR
Copy the contents of SOURCE to DEST and make DEST bootable.
...
...
@@ -97,19 +174,24 @@ or a device. If DEST is ommitted /media/usb will be used.
Options:
-f Force overwrite existing files. Will overwrite syslinux.cfg if upgrade.
-h Show this help.
-k fix kernel and initrd name in syslinux.cfg if needed.
-U Replace current alpine_dev in syslinux.cfg with UUID if UUID found.
-u Upgrade mode. Keep existing syslinux.cfg and don't run syslinux.
-s Force run syslinux, even if upgrade mode.
-v Verbose mode. Display whats going on.
-c Check syslinux.cfg in destination DIR. Use with -f to fix.
__EOF__
exit
1
}
while
getopts
"
fh
Uusv"
opt
;
do
while
getopts
"
c:fhk
Uusv"
opt
;
do
case
"
$opt
"
in
f
)
force
=
1
;;
c
)
check_syslinux
=
"
$OPTARG
"
;;
f
)
force
=
1
;
fix_syslinux_cfg
=
1
;;
h
)
usage
;;
k
)
fix_syslinux_cfg
=
1
;;
U
)
replace_alpine_dev
=
1
;;
u
)
upgrade
=
1
;;
s
)
syslinux
=
1
;;
...
...
@@ -122,6 +204,11 @@ shift $(($OPTIND - 1))
src
=
${
1
}
dest
=
${
2
:-
/media/usb
}
if
[
-n
"
$check_syslinux
"
]
;
then
destdir
=
"
$check_syslinux
"
check_syslinux
exit
0
fi
[
-z
"
$src
"
]
&&
usage
...
...
@@ -235,13 +322,8 @@ elif [ -n "$srcurl" ]; then
fi
# find where new syslinux.cfg is
for
i
in
boot/syslinux/syslinux.cfg syslinux.cfg
;
do
if
[
-e
"
$destdir
"
/.new/
$i
]
;
then
syslinux_cfg
=
$i
vecho
"Found
$syslinux_cfg
"
break
fi
done
find_syslinux_cfg
"
$destdir
"
/.new
# abort early in case unexpected trouble
if
[
-z
"
$syslinux_cfg
"
]
;
then
die
"Could not find any syslinux.cfg on new iso?"
...
...
@@ -288,6 +370,9 @@ if [ -n "$replace_alpine_dev" -o -z "$upgrade" ] && [ -n "$UUID" ]; then
"
$destdir
"
/
$syslinux_cfg
fi
# verify syslinux.cfg
check_syslinux
# cleanup
[
-z
"
$keep_old
"
]
&&
rm
-rf
"
$destdir
"
/.old
"
$destdir
"
/.new
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment