-
Notifications
You must be signed in to change notification settings - Fork 9
Шаг сборки инсталлятора Inno Setup в GA #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
4deb4b9
2e5908d
155d2b0
e1e35dd
b454943
b3d33df
dd5ecf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,36 @@ jobs: | |
| - name: Build ovm.exe | ||
| run: oscript -make src/cmd/ovm.os ovm.exe | ||
|
|
||
| - name: Upload ovm.exe to release assets | ||
| - name: Extract version from packagedef | ||
| id: get_version | ||
| run: | | ||
| VERSION=$(grep -oP '\.Версия\("\K[^"]+' packagedef || true) | ||
| if [ -z "$VERSION" ]; then | ||
| echo "Error: failed to extract version from packagedef." | ||
| exit 1 | ||
| fi | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Extracted version: $VERSION" | ||
|
|
||
| - name: Create dist directory | ||
| run: | | ||
| mkdir -p dist | ||
| chmod 777 dist | ||
|
|
||
| - name: Build Windows installer with Inno Setup | ||
| run: | | ||
EvilBeaver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if [ ! -f "ovm.exe" ]; then | ||
| echo "Error: ovm.exe not found in workspace root. Ensure the 'Build ovm.exe' step completed successfully." | ||
| exit 1 | ||
| fi | ||
| docker run --rm -i -v "$GITHUB_WORKSPACE:/work" -w /work amake/innosetup \ | ||
| /DMyAppVersion="${{ steps.get_version.outputs.version }}" \ | ||
| install/ovm.iss | ||
|
|
||
| - name: Upload release assets | ||
| uses: AButler/upload-release-assets@v2.0.2 | ||
| with: | ||
| files: ovm.exe | ||
| files: | | ||
| ovm.exe | ||
| dist/ovm-setup.exe | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
Comment on lines
+56
to
62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: The latest release is v3.0 (released Nov 20, 2023). [1][2] Sources: 🌐 Web query:
💡 Result: Here’s a concise migration checklist from v2.0.2 → v3.0 for AButler/upload-release-assets, with sources.
References
If you’d like, I can produce a one-line replacement snippet for your workflow and a small test workflow that uploads to a draft release. Обновите версию GitHub Action на v3.0. Версия 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,234 @@ | ||||||
| ; Inno Setup script for OVM (OneScript Version Manager) | ||||||
| ; Installs ovm.exe to %LOCALAPPDATA%\ovm and adds it to user PATH | ||||||
|
|
||||||
| #define MyAppName "OneScript Version Manager" | ||||||
| ; MyAppVersion is passed from GitHub Actions via /D flag, extracting from packagedef | ||||||
| ; Default value is used for local builds | ||||||
| #ifndef MyAppVersion | ||||||
| #define MyAppVersion "1.0.0" | ||||||
| #endif | ||||||
| #define MyAppPublisher "oscript-library" | ||||||
| #define MyAppURL "https://github.com/oscript-library/ovm" | ||||||
| #define MyAppExeName "ovm.exe" | ||||||
|
|
||||||
| [Setup] | ||||||
| ; NOTE: The value of AppId uniquely identifies this application. | ||||||
| AppId={{8E5F4A2B-9C3D-4F1E-A6B8-2D7C9E4F1A3B} | ||||||
|
Comment on lines
+14
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Критично: Возможный фикс AppId={{8E5F4A2B-9C3D-4F1E-A6B8-2D7C9E4F1A3B}
+; ожидание: литерал "{GUID}" => экранирование "{" и "}" удвоением
+; AppId={{8E5F4A2B-9C3D-4F1E-A6B8-2D7C9E4F1A3B}}
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это частый паттерн использования appId и экранирования appId. Не ошибка There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query: 💡 Result: Short answer: In [Setup] AppId braces must be doubled in the script because single { } starts an Inno constant. Use {{GUID}} (and }} for the close) or generate the doubled-braces string via the preprocessor. Example:
Notes: Pascal Script and registry code expect the single-brace form (e.g. "{GUID}"), so only the [Setup] directive needs doubled braces in the script. (stackoverflow.com) Citations: 🌐 Web query: 💡 Result: Short answer: In [Setup] directives (like AppId) Inno Setup treats "{" as the start of a constant, so you must double the opening brace to get a literal "{". The closing brace does not need doubling. Therefore to get an AppId value of {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} write it in the script as: AppId={{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} (That produces a single leading "{" and a single trailing "}" at runtime.) [1][2] References:
@EvilBeaver, вы абсолютно правы, приношу извинения за ошибочный комментарий! Согласно документации Inno Setup, в секции Спасибо за разъяснение! ✏️ Learnings added
|
||||||
| AppName={#MyAppName} | ||||||
| AppVersion={#MyAppVersion} | ||||||
| AppPublisher={#MyAppPublisher} | ||||||
| AppPublisherURL={#MyAppURL} | ||||||
| AppSupportURL={#MyAppURL} | ||||||
| AppUpdatesURL={#MyAppURL} | ||||||
| DefaultDirName={localappdata}\ovm | ||||||
| DisableProgramGroupPage=yes | ||||||
| OutputDir=..\dist | ||||||
| OutputBaseFilename=ovm-setup | ||||||
| Compression=lzma | ||||||
| SolidCompression=yes | ||||||
| ; Per-user installation (no admin rights required) | ||||||
| PrivilegesRequired=lowest | ||||||
| PrivilegesRequiredOverridesAllowed=commandline | ||||||
| ; Notify Windows about environment changes | ||||||
| ChangesEnvironment=yes | ||||||
| ArchitecturesInstallIn64BitMode=x64 | ||||||
| UninstallDisplayIcon={app}\{#MyAppExeName} | ||||||
|
|
||||||
| [Languages] | ||||||
| Name: "english"; MessagesFile: "compiler:Default.isl" | ||||||
| Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl" | ||||||
|
|
||||||
| [Files] | ||||||
| Source: "..\ovm.exe"; DestDir: "{app}"; Flags: ignoreversion | ||||||
|
||||||
| Source: "..\ovm.exe"; DestDir: "{app}"; Flags: ignoreversion | |
| Source: "{#SourcePath}\..\ovm.exe"; DestDir: "{app}"; Flags: ignoreversion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавьте проверку лимита длины PATH и обработку ошибок для пользователя.
В функции AddToPath отсутствуют следующие важные проверки:
-
Лимит длины PATH: Windows ограничивает размер переменных окружения (2047 символов в старых версиях, до 32767 в Windows 10+). Добавление пути без проверки может привести к молчаливому сбою или усечению.
-
Условие гонки (TOCTOU): Между чтением PATH (строка 105) и записью (строка 122) другой процесс может изменить PATH, и эти изменения будут потеряны.
-
Отсутствие обратной связи с пользователем: Если запись в реестр не удалась (строки 127-128), пользователь увидит только сообщение в логе, но не получит видимого предупреждения.
💡 Рекомендации по улучшению
Добавьте проверку длины PATH перед записью:
// В функции AddToPath, перед строкой 122:
const
MAX_PATH_LENGTH = 2047; // Консервативный лимит для совместимости
// После строки 119 (перед записью):
if Length(NewPath) > MAX_PATH_LENGTH then
begin
Log('Ошибка: превышен лимит длины PATH (' + IntToStr(Length(NewPath)) + ' символов)');
MsgBox('Не удалось добавить путь в PATH: превышен лимит длины переменной окружения.' + #13#10 +
'Пожалуйста, добавьте путь вручную: ' + NormalizedPath,
mbError, MB_OK);
exit;
end;Добавьте видимое предупреждение при ошибке записи (замените строки 127-128):
else
begin
Log('Ошибка при добавлении в PATH: ' + NormalizedPath);
MsgBox('Не удалось автоматически добавить путь в PATH.' + #13#10 +
'Пожалуйста, добавьте путь вручную: ' + NormalizedPath,
mbError, MB_OK);
end;🤖 Prompt for AI Agents
In @install/ovm.iss around lines 85 - 129, In AddToPath: enforce a conservative
PATH length limit and surface errors to the user, and mitigate the TOCTOU race
between RegQueryStringValue and RegWriteStringValue by re-reading and merging
PATH just before write; specifically, add a constant (e.g., MAX_PATH_LENGTH =
2047), after computing NewPath re-read the current PATH via RegQueryStringValue
(use EnvironmentKey and 'Path'), merge NormalizedPath into the freshly read
value only if not present, then check Length(NewPath) > MAX_PATH_LENGTH and if
so Log the length and show MsgBox explaining the failure and exit; after
RegWriteStringValue fails, replace the silent Log with a MsgBox informing the
user to add NormalizedPath manually (keep using PathExistsInEnv, NormalizePath,
RegQueryStringValue, and RegWriteStringValue to locate code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это приемлемый риск
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EvilBeaver, понял, принял к сведению вашу оценку. Спасибо за ответ!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавьте обработку ошибок с обратной связью для пользователя.
Функция RemoveFromPath имеет те же проблемы, что и AddToPath:
-
Условие гонки (TOCTOU): PATH может быть изменён между чтением (строка 150) и записью (строка 198).
-
Отсутствие видимой обратной связи: При ошибке обновления PATH (строка 207) пользователь не получает предупреждения.
Хорошо реализовано: Ручная сборка строки (строки 187-195) корректно избегает проблемы с добавлением кавычек функцией TStringList.DelimitedText.
💡 Рекомендация по улучшению
Добавьте видимое предупреждение при ошибке (замените строку 207):
else
begin
Log('Ошибка при обновлении PATH');
MsgBox('Не удалось автоматически удалить путь из PATH.' + #13#10 +
'При необходимости удалите путь вручную: ' + NormalizedPath,
mbError, MB_OK);
end;
Uh oh!
There was an error while loading. Please reload this page.