Skip to content

Commit

Permalink
Removing binary blobs from the project (#51)
Browse files Browse the repository at this point in the history
* removing binary blobs from the project.
we now fetch the ectool from the gitlab artifacts and confirm the checksum.

* remove bin references from README.md

* extracting $TEMP_FOLDER from installEctool
  • Loading branch information
leopoldhub authored Jun 21, 2024
1 parent 1bc4f60 commit d6e6186
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,4 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

.temp
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ It is compatible with all kinds of 13" and 16" models, both AMD/Intel CPUs and w
## Dependancies

To communicate with the embedded controller the `ectool` is required.
You can either use the precompiled executable of `ectool` in this repo or
disable its installation (`--no-ectool`) and add your own by recompiling it from [this repo](https://gitlab.howett.net/DHowett/ectool) and putting it in `[dest-dir(/)]/bin`.
You can either let the script download it from the [gitlab repository](https://gitlab.howett.net/DHowett/ectool) artifacts,
or disable its installation (`--no-ectool`) and install your own.

You also need to disable secure boot of your device for `ectool` to work (more details about why [here](https://www.howett.net/posts/2021-12-framework-ec/#using-fw-ectool))

Expand All @@ -23,7 +23,7 @@ sudo ./install.sh
```

This bash script will to create and activate a service that runs this repo's main script, `fanctrl.py`.
It will copy `fanctrl.py` (to an executable file `fw-fanctrl`) and `./bin/ectool` to `[dest-dir(/)]/bin` and create a config file
It will copy `fanctrl.py` (to an executable file `fw-fanctrl`), download the ectool to `[dest-dir(/)]/bin` and create a config file
in `[dest-dir(/)][sysconf-dir(/etc)]/fw-fanctrl/config.json`

this script also includes options to:
Expand Down
Binary file removed bin/ectool
Binary file not shown.
File renamed without changes.
1 change: 1 addition & 0 deletions fetch/ectool/linux/gitlab_job_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
899
1 change: 1 addition & 0 deletions fetch/ectool/linux/hash.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ab94a1e9a33f592d5482dbfd4f42ad351ef91227ee3b3707333c0107d7f2b1b0
42 changes: 40 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ if [[ $? -ne 0 ]]; then
exit 1;
fi

TEMP_FOLDER='./.temp'
trap 'rm -rf $TEMP_FOLDER' EXIT

PREFIX_DIR="/usr"
DEST_DIR=""
SYSCONF_DIR="/etc"
Expand Down Expand Up @@ -123,10 +126,12 @@ function uninstall() {
function install() {
uninstall_legacy

rm -rf "$TEMP_FOLDER"
mkdir -p "$DEST_DIR$PREFIX_DIR/bin"
if [ "$SHOULD_INSTALL_ECTOOL" = true ]; then
cp "./bin/ectool" "$DEST_DIR$PREFIX_DIR/bin/ectool"
chmod +x "$DEST_DIR$PREFIX_DIR/bin/ectool"
mkdir "$TEMP_FOLDER"
installEctool "$TEMP_FOLDER" || (echo "an error occurred when installing ectool." && echo "please check your internet connection or consider installing it manually and using --no-ectool on the installation script." && exit 1)
rm -rf "$TEMP_FOLDER"
fi
mkdir -p "$DEST_DIR$SYSCONF_DIR/fw-fanctrl"
cp "./fanctrl.py" "$DEST_DIR$PREFIX_DIR/bin/fw-fanctrl"
Expand Down Expand Up @@ -175,6 +180,39 @@ function install() {
fi
}

function installEctool() {
workingDirectory=$1
echo "installing ectool"

ectoolDestPath="$DEST_DIR$PREFIX_DIR/bin/ectool"

ectoolJobId="$(cat './fetch/ectool/linux/gitlab_job_id')"
ectoolSha256Hash="$(cat './fetch/ectool/linux/hash.sha256')"

artifactsZipFile="$workingDirectory/artifact.zip"

echo "downloading artifact from gitlab"
curl -s -S -o "$artifactsZipFile" -L "https://gitlab.howett.net/DHowett/ectool/-/jobs/${ectoolJobId}/artifacts/download?file_type=archive" || (echo "failed to download the artifact." && return 1)
if [[ $? -ne 0 ]]; then return 1; fi

echo "checking artifact sha256 sum"
actualEctoolSha256Hash=$(sha256sum "$artifactsZipFile" | cut -d ' ' -f 1)
if [[ "$actualEctoolSha256Hash" != "$ectoolSha256Hash" ]]; then
echo "Incorrect sha256 sum for ectool gitlab artifact '$ectoolJobId' : '$ectoolSha256Hash' != '$actualEctoolSha256Hash'"
return 1
fi

echo "extracting artifact"
{
unzip -q -j "$artifactsZipFile" '_build/src/ectool' -d "$workingDirectory" &&
cp "$workingDirectory/ectool" "$ectoolDestPath" &&
chmod +x "$ectoolDestPath"
} || (echo "failed to extract the artifact to its designated location." && return 1)
if [[ $? -ne 0 ]]; then return 1; fi

echo "ectool installed"
}

if [ "$SHOULD_REMOVE" = true ]; then
uninstall
else
Expand Down

2 comments on commit d6e6186

@dracid
Copy link

@dracid dracid commented on d6e6186 Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, how is this script downloading an "artifact.zip"?
I cannot see any file like that on the repo: https://gitlab.howett.net/DHowett/ectool
thanks

@TamtamHero
Copy link
Owner

@TamtamHero TamtamHero commented on d6e6186 Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dracid
The repo has a CI page where each update produces build artifacts: https://gitlab.howett.net/DHowett/ectool/-/jobs
For instance: https://gitlab.howett.net/DHowett/ectool/-/jobs/905/artifacts/download

For some reason it's not visible from the repo page, don't know why.

Please sign in to comment.