Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
aTc
pyra-install
Commits
f6fa8672
Commit
f6fa8672
authored
Aug 31, 2017
by
aTc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial version
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
install.sh
install.sh
+96
-0
No files found.
install.sh
0 → 100755
View file @
f6fa8672
#!/bin/bash
version_gt
()
{
test
"
$(
echo
"
$@
"
|
tr
" "
"
\n
"
|
sort
-V
|
tail
-n
1
)
"
==
"
$1
"
;
}
check_exists
()
{
if
!
hash
$1
2>/dev/null
;
then
echo
$1
not found
;
exit
1
;
fi
;
}
if
[
"$#"
-ne
3
]
;
then
echo
"Usage:
$0
: rootfs.tgz u-boot /dev/mmcblk1"
;
exit
1
;
fi
if
[
$(
id
-u
)
-ne
0
]
;
then
echo
"Must be run as root"
;
exit
0
;
fi
check_exists
dd
check_exists sfdisk
check_exists mkfs.ext4
check_exists lsblk
check_exists
id
UBOOT
=
$2
IMAGE
=
$1
DISK
=
$3
echo
Image:
$IMAGE
Disk:
$DISK
U-Boot:
$UBOOT
#if [ ! -d $UBOOT ] ; then echo "u-boot files not found"; exit 1; fi
if
[
!
-f
"
${
UBOOT
}
/MLO"
]
||
[
!
-f
"
${
UBOOT
}
/u-boot.img"
]
;
then
echo
"u-boot files not found"
;
exit
1
;
fi
if
[
!
-f
$IMAGE
]
;
then
echo
"rootfs image
$IMAGE
not found."
;
exit
1
;
fi
lsblk
$DISK
#if [[ $? != 0 ]] ; then echo Failed; exit 1; fi
echo
"Installing to
$DISK
, make sure all partitions are unmounted"
read
-p
"Are you sure you want to continue? <y/N> "
prompt
if
!
[[
$prompt
=
~
[
yY]
(
es
)
*
]]
;
then
echo
"Exiting.."
;
exit
1
;
fi
#exit 0
if
[[
$DISK
==
/dev/mmcblk
*
]]
;
then
PART
=
${
DISK
}
p1
else
PART
=
${
DISK
}
1
fi
echo
"Clearing partition table"
dd
if
=
/dev/zero
of
=
${
DISK
}
bs
=
1M
count
=
10
if
[[
$?
!=
0
]]
;
then
echo
Partitioning failed.
;
exit
1
;
fi
echo
"Installing U-Boot"
dd
if
=
"
$UBOOT
/MLO"
of
=
${
DISK
}
count
=
1
seek
=
1
bs
=
128k
dd
if
=
"
$UBOOT
/u-boot.img"
of
=
${
DISK
}
count
=
2
seek
=
1
bs
=
384k
echo
"Creating partition"
SFVER
=
$(
sfdisk
-v
|
awk
'{print $4}'
)
echo
Found sfdisk version:
${
SFVER
}
if
version_gt
$SFVER
2.26.0
;
then
echo
"> 2.26.0"
sfdisk
${
DISK
}
<<-
__EOF__
1M,,0x83,*
__EOF__
else
echo
"< 2.26.0"
sfdisk
--in-order
--Linux
--unit
M
${
DISK
}
<<-
__EOF__
1,,0x83,*
__EOF__
fi
if
[[
$?
!=
0
]]
;
then
echo
Partitioning failed.
;
exit
1
;
fi
echo
"Formatting partition"
mkfs.ext4
-O
^64bit
${
PART
}
-L
rootfs
if
[[
$?
!=
0
]]
;
then
echo
Formatting failed.
;
exit
1
;
fi
mkdir
rootfs
mount
${
PART
}
./rootfs
if
[[
$?
!=
0
]]
;
then
echo
Mounting
${
PART
}
failed.
;
exit
1
;
fi
echo
"Installing rootfs"
if
hash
bar 2>/dev/null
;
then
bar
$IMAGE
|
tar
--numeric-owner
-xzf
-
-C
rootfs
else
echo
Install
"bar"
for
progress bar
tar
--numeric-owner
-xzf
$IMAGE
-C
rootfs
fi
if
[[
$?
!=
0
]]
;
then
echo
Extracting
$IMAGE
failed.
;
umount
${
PART
}
;
exit
1
;
fi
echo
"Syncing"
sync
umount rootfs
rm
rootfs
-rf
echo
"Done"
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