Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec92c93

Browse files
committed
deb
1 parent86d9c15 commitec92c93

File tree

3 files changed

+324
-69
lines changed

3 files changed

+324
-69
lines changed

‎.github/workflows/build-dsql.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ jobs:
7878
name:postgres-dsql-rpm-${{ matrix.os }}-${{ runner.arch }}
7979
path:"build/*.rpm"
8080

81+
-name:Upload DEB Artifact
82+
if:runner.os == 'Linux'
83+
uses:actions/upload-artifact@v4
84+
with:
85+
name:postgres-dsql-deb-${{ matrix.os }}-${{ runner.arch }}
86+
path:"build/*.deb"
87+
8188
-name:Release
8289
if:startsWith(github.ref, 'refs/tags/')
8390
uses:softprops/action-gh-release@v1
@@ -86,5 +93,6 @@ jobs:
8693
build/postgres-dsql.zip
8794
build/*.dmg
8895
build/*.rpm
96+
build/*.deb
8997
env:
9098
GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}

‎scripts/install.sh‎

Lines changed: 235 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,81 +10,248 @@ error_exit() {
1010
exit 1
1111
}
1212

13-
# Check if running on macOS
14-
if [["$OSTYPE"!="darwin"* ]];then
15-
error_exit"This script is only supported on macOS systems."
16-
fi
17-
18-
# Check if running on ARM architecture
19-
if [["$(uname -m)"!="arm64" ]];then
20-
error_exit"This script is only intended for ARM-based macOS (Apple Silicon) systems."
21-
fi
22-
23-
echo"PostgreSQL DSQL ARM macOS Installer"
24-
echo"==================================="
25-
26-
# Get latest release information using GitHub API
27-
echo"Fetching latest release information..."
28-
RELEASE_INFO=$(curl -s"https://api.github.com/repos/$REPO/releases/latest")
29-
if [[-z"$RELEASE_INFO"||"$RELEASE_INFO"==*"Not Found"* ]];then
30-
error_exit"Could not fetch release information. Check your internet connection."
31-
fi
32-
33-
# Extract download URL for the zip file
34-
DOWNLOAD_URL=$(echo"$RELEASE_INFO"| grep -o'"browser_download_url": *"[^"]*postgres-dsql.zip"'| cut -d'"' -f4)
35-
if [[-z"$DOWNLOAD_URL" ]];then
36-
error_exit"No postgres-dsql.zip found in the latest release."
37-
fi
38-
39-
TAG_NAME=$(echo"$RELEASE_INFO"| grep -o'"tag_name": *"[^"]*"'| cut -d'"' -f4)
40-
echo"Latest release found:$TAG_NAME"
41-
42-
# Create directories if they don't exist
43-
mkdir -p"$INSTALL_PATH/bin"
44-
mkdir -p"$INSTALL_PATH/lib"
45-
46-
# Download the release
47-
echo"Downloading release from$DOWNLOAD_URL..."
48-
TEMP_DIR=$(mktemp -d)
49-
curl -L"$DOWNLOAD_URL" -o"$TEMP_DIR/postgres-dsql.zip"
50-
51-
# Extract the release
52-
echo"Extracting files to$INSTALL_PATH..."
53-
unzip -o"$TEMP_DIR/postgres-dsql.zip" -d"$TEMP_DIR"
13+
# Function to detect OS
14+
detect_os() {
15+
if [["$OSTYPE"=="darwin"* ]];then
16+
echo"macos"
17+
elif [["$OSTYPE"=="linux-gnu"* ]];then
18+
echo"linux"
19+
else
20+
error_exit"Unsupported operating system:$OSTYPE"
21+
fi
22+
}
5423

55-
# Copy files to install location
56-
cp -r"$TEMP_DIR/postgres-dsql/bin/"*"$INSTALL_PATH/bin/"
57-
cp -r"$TEMP_DIR/postgres-dsql/lib/"*"$INSTALL_PATH/lib/"
24+
# Function to detect architecture
25+
detect_arch() {
26+
local arch=$(uname -m)
27+
case"$arch"in
28+
x86_64)
29+
echo"X64"
30+
;;
31+
aarch64|arm64)
32+
echo"ARM64"
33+
;;
34+
*)
35+
error_exit"Unsupported architecture:$arch"
36+
;;
37+
esac
38+
}
5839

59-
# Clean up temp files
60-
rm -rf"$TEMP_DIR"
40+
# Function to detect Linux distribution
41+
detect_linux_distro() {
42+
ifcommand -v apt-get>/dev/null2>&1;then
43+
echo"debian"
44+
elifcommand -v yum>/dev/null2>&1||command -v dnf>/dev/null2>&1;then
45+
echo"rhel"
46+
else
47+
echo"unknown"
48+
fi
49+
}
6150

62-
# Make the binary executable
63-
chmod +x"$INSTALL_PATH/bin/pdsql"
51+
# Function to install via package manager (Linux)
52+
install_via_package() {
53+
local os="$1"
54+
local arch="$2"
55+
local distro="$3"
56+
57+
echo"Attempting package manager installation..."
58+
59+
# Get latest release information
60+
echo"Fetching latest release information..."
61+
RELEASE_INFO=$(curl -s"https://api.github.com/repos/$REPO/releases/latest")
62+
if [[-z"$RELEASE_INFO"||"$RELEASE_INFO"==*"Not Found"* ]];then
63+
error_exit"Could not fetch release information. Check your internet connection."
64+
fi
65+
66+
TAG_NAME=$(echo"$RELEASE_INFO"| grep -o'"tag_name": *"[^"]*"'| cut -d'"' -f4)
67+
echo"Latest release found:$TAG_NAME"
68+
69+
# Determine package type and download URL
70+
local package_type=""
71+
local download_url=""
72+
local package_file=""
73+
74+
if [["$distro"=="debian" ]];then
75+
package_type="deb"
76+
# Convert arch format for DEB (X64 -> amd64, ARM64 -> arm64)
77+
local deb_arch=""
78+
if [["$arch"=="X64" ]];then
79+
deb_arch="amd64"
80+
elif [["$arch"=="ARM64" ]];then
81+
deb_arch="arm64"
82+
fi
83+
package_file="postgres-dsql_1.0.0-1_${deb_arch}.deb"
84+
elif [["$distro"=="rhel" ]];then
85+
package_type="rpm"
86+
# Convert arch format for RPM (X64 -> x86_64, ARM64 -> aarch64)
87+
local rpm_arch=""
88+
if [["$arch"=="X64" ]];then
89+
rpm_arch="x86_64"
90+
elif [["$arch"=="ARM64" ]];then
91+
rpm_arch="aarch64"
92+
fi
93+
package_file="postgres-dsql-1.0.0-1.${rpm_arch}.rpm"
94+
else
95+
echo"Unknown Linux distribution, falling back to ZIP installation..."
96+
return 1
97+
fi
98+
99+
# Find download URL for the package
100+
download_url=$(echo"$RELEASE_INFO"| grep -o"\"browser_download_url\": *\"[^\"]*${package_file}\""| cut -d'"' -f4)
101+
if [[-z"$download_url" ]];then
102+
echo"Package${package_file} not found in release, falling back to ZIP installation..."
103+
return 1
104+
fi
105+
106+
# Download and install package
107+
echo"Downloading${package_type} package..."
108+
TEMP_DIR=$(mktemp -d)
109+
local temp_package="$TEMP_DIR/$package_file"
110+
curl -L"$download_url" -o"$temp_package"
111+
112+
echo"Installing package (may require sudo password)..."
113+
if [["$package_type"=="deb" ]];then
114+
ifcommand -v apt>/dev/null2>&1;then
115+
sudo apt install -y"$temp_package"
116+
else
117+
sudo dpkg -i"$temp_package"
118+
# Fix dependencies if needed
119+
sudo apt-get install -f -y2>/dev/null||true
120+
fi
121+
elif [["$package_type"=="rpm" ]];then
122+
ifcommand -v dnf>/dev/null2>&1;then
123+
sudo dnf install -y"$temp_package"
124+
elifcommand -v yum>/dev/null2>&1;then
125+
sudo yum install -y"$temp_package"
126+
else
127+
sudo rpm -ivh"$temp_package"
128+
fi
129+
fi
130+
131+
# Clean up
132+
rm -rf"$TEMP_DIR"
133+
134+
echo"Package installation completed successfully!"
135+
echo"PostgreSQL DSQL (pdsql) is now available system-wide."
136+
return 0
137+
}
64138

65-
echo"Installation completed successfully!"
66-
echo"PostgreSQL DSQL (pdsql) installed to:$INSTALL_PATH/bin/pdsql"
139+
# Function to install via ZIP extraction
140+
install_via_zip() {
141+
local os="$1"
142+
local arch="$2"
143+
144+
echo"Installing via ZIP extraction..."
145+
146+
# Get latest release information
147+
echo"Fetching latest release information..."
148+
RELEASE_INFO=$(curl -s"https://api.github.com/repos/$REPO/releases/latest")
149+
if [[-z"$RELEASE_INFO"||"$RELEASE_INFO"==*"Not Found"* ]];then
150+
error_exit"Could not fetch release information. Check your internet connection."
151+
fi
152+
153+
TAG_NAME=$(echo"$RELEASE_INFO"| grep -o'"tag_name": *"[^"]*"'| cut -d'"' -f4)
154+
echo"Latest release found:$TAG_NAME"
155+
156+
# Find appropriate ZIP file
157+
local zip_pattern=""
158+
if [["$os"=="macos" ]];then
159+
zip_pattern="postgres-dsql-macos-latest-${arch}"
160+
elif [["$os"=="linux" ]];then
161+
zip_pattern="postgres-dsql-ubuntu-22.04-${arch}"
162+
fi
163+
164+
# Extract download URL for the zip file
165+
DOWNLOAD_URL=$(echo"$RELEASE_INFO"| grep -o"\"browser_download_url\": *\"[^\"]*${zip_pattern}[^\"]*\.zip\""| cut -d'"' -f4)
166+
if [[-z"$DOWNLOAD_URL" ]];then
167+
# Fallback to generic postgres-dsql.zip
168+
DOWNLOAD_URL=$(echo"$RELEASE_INFO"| grep -o'"browser_download_url": *"[^"]*postgres-dsql.zip"'| cut -d'"' -f4)
169+
if [[-z"$DOWNLOAD_URL" ]];then
170+
error_exit"No compatible ZIP file found in the latest release."
171+
fi
172+
fi
173+
174+
# Create directories if they don't exist
175+
mkdir -p"$INSTALL_PATH/bin"
176+
mkdir -p"$INSTALL_PATH/lib"
177+
178+
# Download the release
179+
echo"Downloading release from$DOWNLOAD_URL..."
180+
TEMP_DIR=$(mktemp -d)
181+
curl -L"$DOWNLOAD_URL" -o"$TEMP_DIR/postgres-dsql.zip"
182+
183+
# Extract the release
184+
echo"Extracting files to$INSTALL_PATH..."
185+
unzip -o"$TEMP_DIR/postgres-dsql.zip" -d"$TEMP_DIR"
186+
187+
# Copy files to install location
188+
cp -r"$TEMP_DIR/postgres-dsql/bin/"*"$INSTALL_PATH/bin/"
189+
cp -r"$TEMP_DIR/postgres-dsql/lib/"*"$INSTALL_PATH/lib/"
190+
191+
# Clean up temp files
192+
rm -rf"$TEMP_DIR"
193+
194+
# Make the binary executable
195+
chmod +x"$INSTALL_PATH/bin/pdsql"
196+
197+
echo"ZIP installation completed successfully!"
198+
echo"PostgreSQL DSQL (pdsql) installed to:$INSTALL_PATH/bin/pdsql"
199+
200+
# Check if installation path is in PATH
201+
if [[":$PATH:"!=*":$INSTALL_PATH/bin:"* ]];then
202+
echo""
203+
echo"NOTICE: Your PATH environment variable doesn't contain$INSTALL_PATH/bin"
204+
echo"To add it to your PATH, add the following line to your shell configuration file:"
205+
echo""
206+
echo" export PATH=\"$INSTALL_PATH/bin:\$PATH\""
207+
echo""
208+
echo"Shell configuration files:"
209+
echo" - Bash:$HOME/.bashrc or$HOME/.bash_profile"
210+
echo" - Zsh:$HOME/.zshrc"
211+
echo" - Fish:$HOME/.config/fish/config.fish"
212+
echo""
213+
echo"Then, reload your shell configuration or restart your terminal."
214+
fi
215+
}
67216

68-
# Check if installation path is in PATH
69-
if [[":$PATH:"!=*":$INSTALL_PATH/bin:"* ]];then
217+
# Main installation logic
218+
main() {
219+
echo"PostgreSQL DSQL Universal Installer"
220+
echo"==================================="
221+
222+
# Detect system information
223+
OS=$(detect_os)
224+
ARCH=$(detect_arch)
225+
226+
echo"Detected system:$OS$ARCH"
227+
228+
if [["$OS"=="linux" ]];then
229+
DISTRO=$(detect_linux_distro)
230+
echo"Detected Linux distribution type:$DISTRO"
231+
232+
# Try package manager installation first, fall back to ZIP if it fails
233+
if! install_via_package"$OS""$ARCH""$DISTRO";then
234+
echo"Package installation failed or unavailable, trying ZIP installation..."
235+
install_via_zip"$OS""$ARCH"
236+
fi
237+
else
238+
# macOS - use ZIP installation
239+
install_via_zip"$OS""$ARCH"
240+
fi
241+
70242
echo""
71-
echo"NOTICE: Your PATH environment variable doesn't contain$INSTALL_PATH/bin"
72-
echo"To add it to your PATH, add the following line to your$HOME/.bashrc or$HOME/.zshrc file:"
243+
echo"Installation completed! To verify, run:"
73244
echo""
74-
echo"export PATH=\"$INSTALL_PATH/bin:\$PATH\""
245+
echo"pdsql --version"
75246
echo""
76-
echo"Then, reload your shell configuration by running:"
247+
echo"For usage help, run:"
77248
echo""
78-
if [["$SHELL"==*"zsh"* ]];then
79-
echo" source$HOME/.zshrc"
80-
else
81-
echo" source$HOME/.bashrc"
82-
fi
83-
fi
249+
echo" pdsql --help"
250+
echo""
251+
echo"Example DSQL connection:"
252+
echo""
253+
echo" pdsql --host=your-dsql-endpoint.example.com --user=admin --dbname=postgres"
254+
}
84255

85-
echo""
86-
echo"To verify installation, run:"
87-
echo""
88-
echo" pdsql --version"
89-
echo""
90-
echo"If the command is not found, ensure your PATH is set correctly as described above."
256+
# Run main function
257+
main"$@"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp