Skip to content

Commit

Permalink
try to make appimage generic
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Oct 22, 2024
1 parent daf9b84 commit 92e835e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
4 changes: 2 additions & 2 deletions oapi-cli.AppDir/AppRun → AppRun
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

for opt in "$@"; do
if [ "${opt}" == "--bash-completion" ]; then
cat "${APPDIR}/usr/bin/oapi-cli-completion.bash"
cat "${APPDIR}/usr/bin/____cli_name____-completion.bash"
exit 0
fi
done

export COGNAC_HELP_APPEND="$(echo -en '\t--bash-completion\tprint bash completion(appimage only)\n\t--appimage-help\t\tappimage helps')"

LD_LIBRARY_PATH=${APPDIR}/usr/lib/ "${APPDIR}/usr/bin/oapi-cli" "$@"
LD_LIBRARY_PATH=${APPDIR}/usr/lib/ "${APPDIR}/usr/bin/____cli_name____" "$@"
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ $(CLI_NAME)-completion.bash: bin/line_check osc-api.json call_list arguments-lis
config.sh:
echo "alias json-search=$(JSON_SEARCH)" > config.sh
echo $(SED_ALIAS) >> config.sh
echo "export CLI_NAME=$(CLI_NAME)" >> config.sh

arguments-list.json: osc-api.json
$(JSON_SEARCH) -s Request osc-api.json | $(JSON_SEARCH) -K properties \
Expand Down
File renamed without changes
4 changes: 2 additions & 2 deletions oapi-cli.AppDir/oapi-cli.desktop → cli.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Name=oapi-cli
Exec=oapi-cli
Name=____cli_name____
Exec=____cli_name____
Comment=CLI-of Outscale Granting Net Accessible Calls
Categories=Development;Network;
Terminal=true
Expand Down
2 changes: 1 addition & 1 deletion cognac_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ EOF
done < function.${lang}
done
else
sed "s/____call_list____/${CALL_LIST}/g;s/____piped_call_list____/${PIPED_CALL_LIST}/;s/____api_version____/${API_VERSION}/g;s/____sdk_version____/${SDK_VERSION}/g;s/____cli_version____/$(cat cli-version)/g" <<< "$line";
sed "s/____call_list____/${CALL_LIST}/g;s/____piped_call_list____/${PIPED_CALL_LIST}/;s/____api_version____/${API_VERSION}/g;s/____sdk_version____/${SDK_VERSION}/g;s/____cli_version____/$(cat cli-version)/g;s/____cli_name____/${CLI_NAME}/" <<< "$line";
fi
done < $1
}
Expand Down
13 changes: 7 additions & 6 deletions main_tpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

#define OAPI_CLI_VERSION "____cli_version____"

#define OAPI_CLI_UAGENT "oapi-cli/"OAPI_CLI_VERSION"; osc-sdk-c/"
#define OAPI_CLI_UAGENT "____cli_name____/"OAPI_CLI_VERSION"; osc-sdk-c/"

#define STRY(f, args...) \
do { \
Expand Down Expand Up @@ -295,9 +295,10 @@ int main(int ac, char **av)
} else if (!strcmp("--insecure", av[i])) {
flag |= OSC_INSECURE_MODE;
} else if (!strcmp("--version", av[i])) {
printf("oapi-cli version: %s\n"
printf("%s version: %s\n"
"osc-sdk-c version: %s\n"
"based on osc-api: %s\n",
program_name,
OAPI_CLI_VERSION,
osc_sdk_version_str(),
OSC_API_VERSION);
Expand Down Expand Up @@ -401,11 +402,11 @@ int main(int ac, char **av)
"\t --color try to colorize json if json-c support it\n"
"\t --config=PATH config file path\n"
"\t --file PATH use content of PATH as an agrument for a call, example:\n"
"\t\t\t\toapi-cli CreateCa --CaPem --file /$CA_DIR/cert.pem\n"
"\t\t\t\t____cli_name____ CreateCa --CaPem --file /$CA_DIR/cert.pem\n"
"\t --jsonstr-file PATH same as --file, except the content is surrounded by \"\n"
"\t\t\t\tand \" inside the file are escape with a \\, this option is useful for CreatePolicy\n"
"\t --set-var ID=VARIABLE_PATH Create an oapi-cli variable, that can be use with --var\n"
"\t\t\t\tExamples: ./oapi-cli ReadVms --Filters.TagValues[] VM_NAME --set-var id=Vms.0.VmId ReadVms --Filters.VmIds[] --var id\n"
"\t --set-var ID=VARIABLE_PATH Create an ____cli_name____ variable, that can be use with --var\n"
"\t\t\t\tExamples: ____cli_name____ ReadVms --Filters.TagValues[] VM_NAME --set-var id=Vms.0.VmId ReadVms --Filters.VmIds[] --var id\n"
"\t\t\t\twill find the vm with VM_NAME as it's tag, and read it again, but using it's VmId as filter this time\n"
"\t --var use variabble content created by --set-var\n"
"\t-h, --help [CallName] this, can be used with call name, example:\n\t\t\t\t%s --help ReadVms\n"
Expand All @@ -416,7 +417,7 @@ int main(int ac, char **av)
"\t --profile=PROFILE select profile\n"
"\t --raw-print doesn't format the output\n"
"\t --verbose curl backend is now verbose\n"
"\t --version oapi-cli version info\n%s%s",
"\t --version ____cli_name____ version info\n%s%s",
program_name, program_name, help_appent ? help_appent : "",
help_appent ? "\n" : "");
return 0;
Expand Down
8 changes: 4 additions & 4 deletions oapi-cli-completion-tpl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ _cognac()
esac
}

complete -F _cognac oapi-cli
complete -F _cognac oapi-cli-x86_64.AppImage
complete -F _cognac ____cli_name____
complete -F _cognac ____cli_name____-x86_64.AppImage

# thoses one are for debug
complete -F _cognac ./oapi-cli
complete -F _cognac ./oapi-cli-x86_64.AppImage
complete -F _cognac ./____cli_name____
complete -F _cognac ./____cli_name____-x86_64.AppImage
24 changes: 14 additions & 10 deletions oapi-cli.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ appimagetool-x86_64.AppImage:
wget https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage

oapi-cli-x86_64.AppImage: oapi-cli appimagetool-x86_64.AppImage
mkdir -p oapi-cli.AppDir/usr/
install -D $$(curl-config --ca) oapi-cli.AppDir/$$(curl-config --ca)
echo export CURL_CA_BUNDLE='$${APPDIR}'/$$(curl-config --ca) > oapi-cli.AppDir/import-ssl.sh
mkdir -p oapi-cli.AppDir/usr/bin/
mkdir -p oapi-cli.AppDir/usr/lib/
cp oapi-cli oapi-cli.AppDir/usr/bin/
cp oapi-cli-completion.bash oapi-cli.AppDir/usr/bin/
LD_LIBRARY_PATH="$(LD_LIB_PATH)" ./cp-lib.sh oapi-cli ./oapi-cli.AppDir/usr/lib/
./appimagetool-x86_64.AppImage $(APPIMAGETOOL_OPTION) oapi-cli.AppDir
$(CLI_NAME)-x86_64.AppImage: $(CLI_NAME) appimagetool-x86_64.AppImage
mkdir -p $(CLI_NAME).AppDir/
mkdir -p $(CLI_NAME).AppDir/usr/
install -D $$(curl-config --ca) $(CLI_NAME).AppDir/$$(curl-config --ca)
echo export CURL_CA_BUNDLE='$${APPDIR}'/$$(curl-config --ca) > $(CLI_NAME).AppDir/import-ssl.sh
mkdir -p $(CLI_NAME).AppDir/usr/bin/
mkdir -p $(CLI_NAME).AppDir/usr/lib/
cat cli.desktop | sed "s/____cli_name____/$(CLI_NAME)/" > $(CLI_NAME).AppDir/$(CLI_NAME).desktop
cat AppRun | sed "s/____cli_name____/$(CLI_NAME)/" > $(CLI_NAME).AppDir/AppRun
cp $(CLI_NAME) $(CLI_NAME).AppDir/usr/bin/
cp appimage-logo.png $(CLI_NAME).AppDir/
cp $(CLI_NAME)-completion.bash $(CLI_NAME).AppDir/usr/bin/
LD_LIBRARY_PATH="$(LD_LIB_PATH)" ./cp-lib.sh $(CLI_NAME) ./$(CLI_NAME).AppDir/usr/lib/
./appimagetool-x86_64.AppImage $(APPIMAGETOOL_OPTION) $(CLI_NAME).AppDir

0 comments on commit 92e835e

Please sign in to comment.