First commit
This commit is contained in:
commit
abcf3fdf2a
4 changed files with 220 additions and 0 deletions
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install --no-install-recommends -y libext2fs2 \
|
||||||
|
parted \
|
||||||
|
bash
|
||||||
|
|
||||||
|
COPY docker/entrypoint.sh /tmp
|
||||||
|
COPY src/ /tmp
|
||||||
|
WORKDIR /tmp
|
||||||
|
#CMD bash
|
||||||
|
CMD /tmp/entrypoint.sh
|
58
README.md
Normal file
58
README.md
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
MNT Reform Debian userland creation
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
This script built an userland "filesystem" for MNT Reform 2 laptop computer.
|
||||||
|
**Work in Progress**: for now there is some dependencies missing for compiling
|
||||||
|
xservser.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
make_image.sh -r <recipe> -k <kernel> -o <output> --repository <repo> -h
|
||||||
|
```
|
||||||
|
|
||||||
|
* `recipe`: recipe to write on the output image, default:`default`
|
||||||
|
* `kernel`: Linux kernel version to put on image disk, default:`5.11`
|
||||||
|
* `output`: output directory, default: `/output`
|
||||||
|
* `repo`: directory that contains all needed for building image disk
|
||||||
|
|
||||||
|
## The repository
|
||||||
|
|
||||||
|
The repositpry directory contains all needed to build your image disk :
|
||||||
|
|
||||||
|
* The kernel into a directory named with the version, eg `5.11` than contains
|
||||||
|
the kernel itself and dtb files, see [reform2_mkkernel][l_mkkern] git
|
||||||
|
repository
|
||||||
|
* The recipe directory that contains the userland filesystem, see
|
||||||
|
[reform2_mkuserland][l_mkusr] git repository
|
||||||
|
* the uboot binary, see [reform2_mkuboot][l_mkuboot] git repository
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
You can find a Dockerfile and an entrypoint script to help you create userland
|
||||||
|
filesystem.
|
||||||
|
|
||||||
|
First you need to build the container :
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://git.epha.se/ephase/reform_mkimage
|
||||||
|
cd reform_mkimage
|
||||||
|
docker build -t reform_make_image
|
||||||
|
[...]
|
||||||
|
```
|
||||||
|
|
||||||
|
And run it :
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -v /home/docker/output:/output --rm reform_make_image
|
||||||
|
```
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
|
||||||
|
This work is derivated from MNT script found [here][l_mnt_image] and licenced
|
||||||
|
under the GPLv3 Licence
|
||||||
|
|
||||||
|
[l_mnt_image]:https://source.mnt.re/reform/reform-system-image/
|
||||||
|
[l_mkusr]:https://git.epha.se/ephase/reform2_mkuserland
|
||||||
|
[l_mkkern]:https://git.epha.se/ephase/reform2_mkkernel
|
||||||
|
[l_mkuboot]:https://git.epha.se/ephase/reform2_mkuboot
|
11
docker/entrypoint.sh
Executable file
11
docker/entrypoint.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -z $RECIPE ]] && RECIPE="default"
|
||||||
|
[[ -z $KERNEL ]] && KERNEL="5.11"
|
||||||
|
[[ -z $OUTPUT ]] && OUTPUT="/output"
|
||||||
|
[[ -z $REPO ]] && REPO="/output"
|
||||||
|
|
||||||
|
if ! ./make_image.sh -r $RECIPE -k $KERNEL -o $OUTPUT --repository $REPO
|
||||||
|
then
|
||||||
|
printf "Error when create userland\n"
|
||||||
|
fi
|
139
src/make_image.sh
Executable file
139
src/make_image.sh
Executable file
|
@ -0,0 +1,139 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
repo="/output"
|
||||||
|
output="/tmp"
|
||||||
|
recipe="default"
|
||||||
|
kernel_version="5.11"
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
cat << EOF
|
||||||
|
|
||||||
|
Create image disk MNT Reform
|
||||||
|
---
|
||||||
|
This script create an ready to flash image disk for the MNT Reform 2 laptop
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
make_image.sh -o <output> -r <recipe> -m <mirror>
|
||||||
|
|
||||||
|
-o <output> : directory where put the image disk. Default: \tmp
|
||||||
|
|
||||||
|
-r <recipe> : userland recipe to get (see make_userland script), image disk
|
||||||
|
will be name with the recipe name. Default: default
|
||||||
|
|
||||||
|
-k <version> : kernel version to apply, Default 5.11
|
||||||
|
|
||||||
|
--repository : directory than contains all needed for building image disk
|
||||||
|
userland filesystem, kernel and uboot
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
}
|
||||||
|
function error {
|
||||||
|
>&2 printf "\e[31mE\e[0m %s\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function process_args {
|
||||||
|
while :; do
|
||||||
|
case $1 in
|
||||||
|
-h|-\?|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-r|--recipe)
|
||||||
|
recipe="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-o|--output)
|
||||||
|
output=$2
|
||||||
|
;;
|
||||||
|
-k|--kernel)
|
||||||
|
kernel_version="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--repository)
|
||||||
|
repo="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean {
|
||||||
|
if [[ ! -z "$tmp_dir" ]]
|
||||||
|
then
|
||||||
|
rm -rf $tmp_dir
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trap clean EXIT SIGINT ERR
|
||||||
|
process_args "$@"
|
||||||
|
|
||||||
|
tmp_dir=$(mktemp -d "/tmp/image_XXX")
|
||||||
|
|
||||||
|
printf "repo: %s\n" "$repo"
|
||||||
|
printf "tmp : %s\n" "$tmp_dir"
|
||||||
|
if [[ ! -d "$output" ]]
|
||||||
|
then
|
||||||
|
error "Output directory $output does not exist"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$repo" ]]
|
||||||
|
then
|
||||||
|
error "Repository directory $repo does not exist"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$repo/$recipe" ]]
|
||||||
|
then
|
||||||
|
error "recipe directory ${repo}/${recipe} not found"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "${repo}/${kernel_version}" ]]
|
||||||
|
then
|
||||||
|
error "kernel version $kernel_version not found"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir "${tmp_dir}/image" -p
|
||||||
|
|
||||||
|
# Copy stuff
|
||||||
|
cp --preserve=all -R "${repo}/${recipe}/"* "${tmp_dir}/image/" || {
|
||||||
|
error "Error on ${repo}/${recipe}/ copy"
|
||||||
|
exit 10
|
||||||
|
}
|
||||||
|
|
||||||
|
cp --preserve=all "${repo}/${kernel_version}/"* "${tmp_dir}/image/" || {
|
||||||
|
error "Error on ${repo}/${kernel_version}/ copy"
|
||||||
|
exit 11
|
||||||
|
}
|
||||||
|
|
||||||
|
cp "${tmp_dir}/image/imx8mq-mnt-reform2-single-display.dtb" "${tmp_dir}/image/imx8mq-mnt-reform2.dtb" || {
|
||||||
|
error "Can't create mx8mq-mnt-reform2.dtb"
|
||||||
|
exit 12
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create system
|
||||||
|
mke2fs -v -L 'MNTREFORM' -N 0 -O 64bit -E offset=4194304 -d "${tmp_dir}/image" -m 5 -r 1 -t ext4 "${output}/reform-${recipe}.img" 9000M || {
|
||||||
|
error "Error on mke2fs"
|
||||||
|
exit 20
|
||||||
|
}
|
||||||
|
|
||||||
|
parted -s "${output}/reform-${recipe}.img" "mklabel msdos" || {
|
||||||
|
error "Error when create partition label"
|
||||||
|
exit 30
|
||||||
|
}
|
||||||
|
|
||||||
|
parted -s "${output}/reform-${recipe}.img" "mkpart primary ext4 4MiB -1s" || {
|
||||||
|
error "Error on create primary partition"
|
||||||
|
exit 31
|
||||||
|
}
|
||||||
|
|
||||||
|
dd if="${repo}/flash.bin" of="${output}/reform-${recipe}.img" conv=notrunc bs=1k seek=33 || {
|
||||||
|
error "Error on flash uboot on image"
|
||||||
|
exit 40
|
||||||
|
}
|
||||||
|
#
|
||||||
|
#dd if=reform-system.img of=/dev/mmcblk0
|
Loading…
Add table
Add a link
Reference in a new issue