Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,3 +32,8 @@ jobs:
if: runner.os == 'Linux'
shell: bash
run: bash -x make.sh build

- name: Build on Windows
if: runner.os == 'Windows'
shell: powershell
run: pwsh -File make.ps1 build
11 changes: 0 additions & 11 deletions make.deb.sh

This file was deleted.

98 changes: 98 additions & 0 deletions make.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env pwsh
##############################################################################################################

Function PrivClipper {
Return "
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
Options:
build Build program
"
}

Function PrivWget {
ForEach ($REPLY in $args) {
$params = @{
Uri = $REPLY
OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0]
}
Invoke-WebRequest @params | Out-Null
Return $params.OutFile
}
}

Function PrivMsiexec {
While ($Input.MoveNext()) {
$params = @{}
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
'msi' {
$params = @{
FilePath = 'msiexec'
ArgumentList = '/passive', '/package', $Input.Current
}
}
'exe' {
$params = @{
FilePath = $Input.Current
ArgumentList = '/SP-', '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'
}
}
}
Start-Process -PassThru -Wait @params
Remove-Item $Input.Current
}
}

Function PrivLazBuild {
$VAR = @{
Cmd = 'lazbuild'
Url = 'https://netix.dl.sourceforge.net/project/lazarus/Lazarus%20Windows%2064%20bits/Lazarus%203.6/lazarus-3.6-fpc-3.2.2-win64.exe?viasf=1'
Path = "C:\Lazarus"
}
If (-not (Get-Command $VAR.Cmd -ea 'continue')) {
PrivWget $VAR.Url | PrivMsiexec
$env:PATH+=";$($VAR.Path)"
Get-Command $VAR.Cmd
}
If ( Test-Path -Path 'use\components.txt' ) {
Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--init'
Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--remote'
Get-Content -Path 'use\components.txt' | ForEach-Object {
If (-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--verbose-pkgsearch', $_)) {
If (-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--add-package', $_)) {
If (-not (Test-Path -Path 'use\components.txt')) {
$OutFile = PrivWget "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
Remove-Item $OutFile
}
}
}
}
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--add-package-link', $_.Name
}
}
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object {
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--no-write-project', '--recursive', '--build-mode=release', $_.Name
}
}

Function PrivMain {
$ErrorActionPreference = 'stop'
Set-PSDebug -Strict -Trace 1
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
If ($args.count -gt 0) {
Switch ($args[0]) {
'build' {
PrivLazBuild
}
Default {
PrivClipper
}
}
} Else {
PrivClipper
}
}

##############################################################################################################
PrivMain @args
58 changes: 47 additions & 11 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,64 @@ Options:
EOF
)

function pub_build
function priv_lazbuild
(
git submodule update --init --recursive
find 'use' -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} \;
find 'src' -type 'f' -name '*.lpi' -exec lazbuild --recursive --build-mode=release {} \;
)

function priv_main
(
set -euo pipefail
if ! (which lazbuild); then
source '/etc/os-release'
case ${ID:?} in
debian | ubuntu)
sudo apt-get update
sudo apt-get install -y lazarus
;;
;;
esac
fi
if [[ -f 'use/components.txt' ]]; then
git submodule update --init --recursive
git submodule update --recursive --remote
while read -r; do
if ! (lazbuild --verbose-pkgsearch "${REPLY}"); then
if ! (lazbuild --add-package "${REPLY}"); then
if ! [[ -f "use/${REPLY}" ]]; then
declare -A VAR=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[out]=$(mktemp)
)
wget --output-document "${VAR[out]}" "${VAR[url]}" >/dev/null
unzip -o "${VAR[out]}" -d "use/${REPLY}"
rm --verbose "${VAR[out]}"
fi
fi
fi
done < 'use/components.txt'
find 'use' -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} +
fi
find 'src' -type 'f' -name '*.lpi' \
-exec lazbuild --no-write-project --recursive --no-write-project --build-mode=release {} + 1>&2
)


function priv_dpkg
(
# Linux shell script to create .deb package
# Go to the repository local folder. For example, cd /home/User/ShellRemoteBot
declare -r STAGING_DIR=./deb.staging
find "${STAGING_DIR}" -type d -exec chmod 0755 {} +
find "${STAGING_DIR}" -type f -exec chmod 0644 {} +
find "${STAGING_DIR}/usr/bin" -type f -exec chmod 0755 {} +
echo "Installed-Size: $(du -s ${STAGING_DIR} | awk '{print $1;}')" >>"${STAGING_DIR}/DEBIAN/control"
gzip -9 -n 'deb.staging/usr/share/doc/tgshd/changelog.Debian'
read -rp "Input package filename: "
dpkg-deb --root-owner-group --build "${STAGING_DIR}" "${REPLY}.deb"
)

function priv_main
(
set -euo pipefail
if ((${#})); then
case ${1} in
build) pub_build 1>&2 ;;
build) priv_lazbuild ;;
dpkg) priv_dpkg ;;
*) priv_clippit ;;
esac
else
priv_clippit
Expand Down
Empty file added use/components.txt
Empty file.