-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add storage of current system config at /var/host/FMO-OS via device-sku systemd - Add registration-agent-laptop-binary and registration-agent-laptop-local to build registration-agent-laptop from a local binary or source code - Add fmo-ota package that allows: + System config modification + Update new system version from upstream repository with git tag/commit + Ability to choose whether keep the current registration-agent-laptop or build new from given source code Signed-off-by: Anh Huy Bui <[email protected]>
- Loading branch information
1 parent
30243fc
commit 4b30321
Showing
8 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"vim" | ||
"tcpdump" | ||
"gpsd" | ||
"fmo-ota" | ||
]; # systemPackages | ||
|
||
launchers = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
(final: _prev: { | ||
fmo-ota = final.writeShellScriptBin "fmo-ota" '' | ||
function usage() { | ||
echo "Usage: $0 [-t <version-tag>/-c <commit-hash>] [-r <absolute-path-to-registration-agent-folder]"; exit 1; | ||
} | ||
while getopts ":c:t:r:s:" o; do | ||
case "''${o}" in | ||
c) | ||
COMMIT=''${OPTARG} | ||
;; | ||
t) | ||
TAGS=''${OPTARG} | ||
;; | ||
r) | ||
REGISTRATION_AGENT=$(realpath ''${OPTARG}) | ||
;; | ||
s) | ||
HASH=" ''${OPTARG//\//\\/}" | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
LOCAL_SOURCE=/var/host | ||
if [ -z "''${COMMIT}" ] && [ -z "''${TAGS}" ]; then | ||
if [ ! -d $LOCAL_SOURCE/FMO-OS ]; then | ||
echo "Cannot find current system config" | ||
exit 1 | ||
fi | ||
cd $LOCAL_SOURCE/FMO-OS/ | ||
if [ -z "''${REGISTRATION_AGENT}" ]; then | ||
rm -rf ./modules/packages/registration-agent/RA-local | ||
cp -R $(registration-agent-laptop -o) ./modules/packages/registration-agent/RA-binary | ||
else | ||
if [ ! -d "''${REGISTRATION_AGENT}" ]; then | ||
echo "Registration Agent path not found" | ||
exit 1 | ||
fi | ||
rm -rf ./modules/packages/registration-agent/RA-binary | ||
mkdir -p ./modules/packages/registration-agent/RA-local | ||
cp -R ''${REGISTRATION_AGENT}/* ./modules/packages/registration-agent/RA-local | ||
if [ ! -z "''${HASH}" ]; then | ||
sed -i "11s/.*/$HASH/" ./modules/packages/registration-agent/registration-agent-laptop-local.nix | ||
fi | ||
fi | ||
git init | ||
git add * | ||
sudo nixos-rebuild switch --flake .#fmo-os-x86_64-debug --accept-flake-config | ||
if [ $? -eq 0 ]; then | ||
echo "System update successfully" | ||
else | ||
echo "System update failed" | ||
fi | ||
else | ||
cd /tmp/ | ||
git clone https://github.com/tiiuae/FMO-OS.git | ||
cd FMO-OS/ | ||
if [ ! -z "''${TAGS}" ]; then | ||
git checkout tags/''${TAGS} | ||
if [ $? -eq 0 ]; then | ||
echo "Tag: ''${TAGS} found" | ||
else | ||
echo "Tag: ''${TAGS} not found" | ||
fi | ||
else | ||
if [ ! -z "''${COMMIT}" ]; then | ||
git checkout ''${COMMIT} | ||
if [ $? -eq 0 ]; then | ||
echo "Commit: ''${TAGS} found" | ||
else | ||
echo "Commit: ''${TAGS} not found" | ||
fi | ||
fi | ||
fi | ||
if [ -z "''${REGISTRATION_AGENT}" ]; then | ||
rm -rf ./modules/packages/registration-agent/RA-local | ||
cp -R $(registration-agent-laptop -o) ./modules/packages/registration-agent/RA-binary | ||
else | ||
if [ ! -d "''${REGISTRATION_AGENT}" ]; then | ||
echo "Registration Agent path not found" | ||
exit 1 | ||
fi | ||
rm -rf ./modules/packages/registration-agent/RA-binary | ||
mkdir -p ./modules/packages/registration-agent/RA-local | ||
cp -R ''${REGISTRATION_AGENT}/* ./modules/packages/registration-agent/RA-local | ||
rm -rf ./modules/packages/registration-agent/RA-local/.git | ||
if [ ! -z "''${HASH}" ]; then | ||
sed -i "11s/.*/$HASH/" ./modules/packages/registration-agent/registration-agent-laptop-local.nix | ||
fi | ||
fi | ||
git config --global --add safe.directory $(realpath .) | ||
git add * | ||
sudo nixos-rebuild switch --flake .#fmo-os-x86_64-debug --accept-flake-config | ||
if [ $? -eq 0 ]; then | ||
echo "System update successfully" | ||
rm -rf $LOCAL_SOURCE/FMO-OS | ||
mv /tmp/FMO-OS $LOCAL_SOURCE | ||
else | ||
echo "System update failed" | ||
fi | ||
fi | ||
''; | ||
}) |
10 changes: 10 additions & 0 deletions
10
modules/packages/registration-agent/registration-agent-laptop-binary.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ pkgs, | ||
}: | ||
pkgs.buildPackages.runCommand "registrationAgentOrig" | ||
{ | ||
# for `nix run` | ||
meta.mainProgram = "registrationAgentOrig"; | ||
} '' | ||
mkdir -p $out/bin | ||
${pkgs.coreutils}/bin/cp -R ${./RA-binary} $out/bin/registration-agent-laptop-orig | ||
'' |
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
modules/packages/registration-agent/registration-agent-laptop-local.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
{pkgs,lib}: | ||
pkgs.buildGoModule { | ||
name = "registration-agent-laptop"; | ||
src = ./RA-local; | ||
tags = [ "prod" ]; | ||
patches = [./remove-test.patch]; | ||
vendorHash = '' | ||
sha256-18p7l1otlviZNlM0UlCgW/US5YckBYcY/OEJoJIsIM0= | ||
''; | ||
proxyVendor=true; | ||
postInstall = '' | ||
mv $out/bin/registration-agent-laptop $out/bin/registration-agent-laptop-orig | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters