From e8e111d3377641481a98696d2aab9347e7d692de Mon Sep 17 00:00:00 2001 From: Sense T Date: Fri, 28 Feb 2025 15:27:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=20h3c-inod?= =?UTF-8?q?e-client=EF=BC=8C=E8=BF=98=E6=9C=89=E4=B8=80=E7=82=B9=E5=B0=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 62 +++++++++++++++ flake.nix | 27 ++++--- h3c-inode-client/package.nix | 146 +++++++++++++++++++++++++++++++++++ treefmt.nix | 2 +- 4 files changed, 225 insertions(+), 12 deletions(-) create mode 100644 flake.lock create mode 100644 h3c-inode-client/package.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3455ce3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,62 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1740547748, + "narHash": "sha256-Ly2fBL1LscV+KyCqPRufUBuiw+zmWrlJzpWOWbahplg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3a05eebede89661660945da1f151959900903b6a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1735554305, + "narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1739829690, + "narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "3d0579f5cc93436052d94b73925b48973a104204", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 9bb2843..3da3354 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,4 @@ { - description = ""; - inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; treefmt-nix.url = "github:numtide/treefmt-nix"; @@ -22,6 +20,8 @@ libz atk ell + bash + coreutils glib cairo ncurses5 @@ -39,12 +39,11 @@ { formatter.${system} = treefmtEval.config.build.wrapper; devShell."${system}" = mkShell { - buildInputs = - with pkgs; - [ - tokei - ] - ++ packages-inode; + nativeBuildInputs = with pkgs; [ + tokei + nil + ]; + buildInputs = packages-inode; }; packages."${system}" = { @@ -54,13 +53,19 @@ in pkgs.buildFHSEnv { name = "inode-dev-shell"; - buildInputs = packages-inode; - targetPkgs = pkgs: with pkgs; [ ] ++ packages; + targetPkgs = pkgs: [ pkgs.makeWrapper ] ++ packages-inode; profile = '' export FHS=1 export PROMPT_COMMAND="echo -n '(FHS)'" ''; + + extraBuildCommands = '' + echo $PATH + # mount --bind $HOME/.config/iNode/ $out/iNodeClient/clientfiles + ''; }; + + h3c-inode-client = pkgs.callPackage ./h3c-inode-client/package.nix { }; }; }; -} \ No newline at end of file +} diff --git a/h3c-inode-client/package.nix b/h3c-inode-client/package.nix new file mode 100644 index 0000000..149ba0a --- /dev/null +++ b/h3c-inode-client/package.nix @@ -0,0 +1,146 @@ +{ + stdenv, + makeWrapper, + autoPatchelfHook, + + # denpendencies + libgcc, + libxcrypt-legacy, + libuuid, + libpng12, + libjpeg, + libudev0-shim, + libz, + atk, + bash, + coreutils, + ell, + glib, + cairo, + ncurses5, + pango, + gtk2, + gdk-pixbuf, + freetype, + fontconfig, + xorg, # libSM, libX11, libXxf86vm + ... +}: +let + install_dir = "/opt/iNodeClient"; + libraries = [ + libgcc + libxcrypt-legacy + libuuid + libpng12 + libjpeg + libudev0-shim + libz + atk + ell + bash + coreutils + glib + cairo + ncurses5 + pango + gtk2 + gdk-pixbuf + freetype + fontconfig + xorg.libSM + xorg.libX11 + xorg.libXxf86vm + ]; +in +stdenv.mkDerivation { + pname = "h3c-inode-client"; + version = "7.3.0"; + + src = fetchTarball { + url = "https://download.h3c.com/app/cn/download.do?id=7684846"; + sha256 = "0y92bia0xcm6d8al3vzkgglcqd63z09lkssvi9ihsz6m1kabwxyl"; + }; + + nativeBuildInputs = [ + autoPatchelfHook + makeWrapper + ]; + + buildInputs = libraries; + + installPhase = '' + # 安装应用文件 + mkdir -p $out${install_dir} + + for i in $(ls -a $src); do + if [ $i == "$src/clientfiles" ]; then + continue + fi + + cp -r $i $out${install_dir} + done + + for i in $(ls $out${install_dir}/*.ps); do + sed -i 's|#!/bin/sh|#!/usr/bin/env sh|' $i + chmod +x $i + done + + # 禁用 enablecards.ps (清空文件内容) + head -n1 $out${install_dir}/enablecards.ps | tee $out${install_dir}/enablecards.ps + + # 客户端配置目录 + rm -rf $out${install_dir}/clientfiles + ln -sf /var/lib/inode/clientfiles $out${install_dir}/ + ln -sf /var/lib/inode/Data $out${install_dir}/ + + mkdir -p $out/var/lib/inode/conf + mv $out${install_dir}/conf/iNode.conf $out/var/lib/inode/conf + rm $out${install_dir}/conf -rf + ln -sf /var/lib/inode/conf $out${install_dir}/ + + # 日志目录 + rm -rf $out${install_dir}/log + ln -sf /var/log/inode $out${install_dir}/log + + # 快捷方式 + mkdir -p $out/share/applications + cat $out${install_dir}/iNodeClient.desktop | sed "/^Exec=/s#@INSTALL_PATH/iNodeClient.sh#$out${install_dir}/.iNode/iNodeClient#" | sed "/^Icon=/s#@INSTALL_PATH#$out${install_dir}#" > $out/share/applications/iNodeClient.desktop + + # /etc 目录文件 + mkdir -p $out/etc/iNode + echo INSTALL_DIR=$out${install_dir} > $out/etc/iNode/inodesys.conf + + # 运行文件 + mkdir -p $out/bin + cat > $out/bin/h3c-inode-client < $out/bin/setup < $out/bin/AuthenMngService <