feat: switch to /usr layout and add dynamic dependency detection
All checks were successful
Build and Release Zed Editor / check-version (push) Successful in 3s
Build and Release Zed Editor / build-and-release (push) Successful in 1m21s

- Move binaries to /usr/bin and /usr/libexec for system integration
- Add find-deps.sh script to detect required system packages from .so
  files
- Update Makefile to generate Depends field dynamically using apt-file
- Add list-deps target to Makefile for dependency analysis
- Update README with new usage, features, and instructions
- Update CI workflow to install apt-file and update its database
This commit is contained in:
2025-10-14 11:46:28 +02:00
parent 260cff501a
commit 0dba8ae99a
6 changed files with 370 additions and 144 deletions

115
Makefile
View File

@@ -1,4 +1,4 @@
.PHONY: all clean download extract deb help
.PHONY: all clean download extract deb help list-deps
# Variables
GITHUB_REPO = zed-industries/zed
@@ -8,6 +8,7 @@ BUILD_DIR = build
EXTRACT_DIR = $(BUILD_DIR)/extracted
DEB_DIR = $(BUILD_DIR)/deb
CONTROL_DIR = $(DEB_DIR)/DEBIAN
FIND_DEPS_SCRIPT = ./find-deps.sh
# Determine the latest stable version
VERSION := $(shell curl -s https://api.github.com/repos/$(GITHUB_REPO)/releases/latest | jq -r '.tag_name' | sed 's/^v//')
@@ -20,15 +21,16 @@ DEB_FILE = $(BUILD_DIR)/$(PACKAGE_NAME)_$(VERSION)_amd64.deb
all: deb
help:
@echo "Makefile to create a .deb package for Zed Editor"
@echo "Makefile to create a .deb package for Zed Editor (using /usr layout)"
@echo ""
@echo "Available targets:"
@echo " all - Build the .deb package (default target)"
@echo " download - Download the archive from GitHub"
@echo " extract - Extract the archive"
@echo " deb - Create the .deb package"
@echo " clean - Clean up temporary files"
@echo " help - Display this help"
@echo " all - Build the .deb package (default target)"
@echo " download - Download the archive from GitHub"
@echo " extract - Extract the archive"
@echo " deb - Create the .deb package"
@echo " list-deps - List dynamic library dependencies"
@echo " clean - Clean up temporary files"
@echo " help - Display this help"
@echo ""
@echo "Detected version: $(VERSION)"
@@ -55,75 +57,76 @@ $(EXTRACT_DIR)/.extracted: $(BUILD_DIR)/$(ARCHIVE_NAME)
@touch $@
@echo "Extraction complete"
# List dependencies dynamically
list-deps: $(EXTRACT_DIR)/.extracted
@echo "Analyzing library dependencies..."
@chmod +x $(FIND_DEPS_SCRIPT)
@$(FIND_DEPS_SCRIPT) $(EXTRACT_DIR)/zed.app/lib
# Create the .deb package
deb: $(DEB_FILE)
$(DEB_FILE): $(EXTRACT_DIR)/.extracted
@echo "Building .deb package..."
@echo "Building .deb package with /usr layout..."
@mkdir -p $(CONTROL_DIR)
@mkdir -p $(DEB_DIR)/opt/zed
@mkdir -p $(DEB_DIR)/usr/bin
@mkdir -p $(DEB_DIR)/usr/libexec
@mkdir -p $(DEB_DIR)/usr/share/applications
@mkdir -p $(DEB_DIR)/usr/share/icons/hicolor/512x512/apps
@mkdir -p $(DEB_DIR)/usr/share/icons/hicolor/1024x1024/apps
@mkdir -p $(DEB_DIR)/usr/share/doc/zed-editor
# Copy application files
@echo "Copying files..."
@cp -r $(EXTRACT_DIR)/zed.app/* $(DEB_DIR)/opt/zed/
# Create symbolic link for the binary
@ln -sf /opt/zed/bin/zed $(DEB_DIR)/usr/bin/zed
# Copy application files (excluding bundled libraries)
@echo "Copying binaries..."
@cp $(EXTRACT_DIR)/zed.app/bin/zed $(DEB_DIR)/usr/bin/
@cp $(EXTRACT_DIR)/zed.app/libexec/zed-editor $(DEB_DIR)/usr/libexec/
# Copy desktop file and icons
@echo "Copying desktop files and icons..."
@cp $(EXTRACT_DIR)/zed.app/share/applications/zed.desktop $(DEB_DIR)/usr/share/applications/
@sed -i '/^\[Desktop Entry\]/a StartupWMClass=dev.zed.Zed' $(DEB_DIR)/usr/share/applications/zed.desktop
@cp $(EXTRACT_DIR)/zed.app/share/icons/hicolor/512x512/apps/zed.png $(DEB_DIR)/usr/share/icons/hicolor/512x512/apps/
@cp $(EXTRACT_DIR)/zed.app/share/icons/hicolor/1024x1024/apps/zed.png $(DEB_DIR)/usr/share/icons/hicolor/1024x1024/apps/
# Create control file
@echo "Package: $(PACKAGE_NAME)" > $(CONTROL_DIR)/control
@echo "Version: $(VERSION)" >> $(CONTROL_DIR)/control
@echo "Section: editors" >> $(CONTROL_DIR)/control
@echo "Priority: optional" >> $(CONTROL_DIR)/control
@echo "Architecture: amd64" >> $(CONTROL_DIR)/control
@echo "Maintainer: Zed Packager <packager@local>" >> $(CONTROL_DIR)/control
@echo "Description: Zed - A high-performance, multiplayer code editor" >> $(CONTROL_DIR)/control
@echo " Zed is a next-generation code editor designed for" >> $(CONTROL_DIR)/control
@echo " high-performance collaboration with humans and AI." >> $(CONTROL_DIR)/control
@echo "Homepage: https://zed.dev" >> $(CONTROL_DIR)/control
# Copy licenses
@cp $(EXTRACT_DIR)/zed.app/licenses.md $(DEB_DIR)/usr/share/doc/zed-editor/
# Create postinst script to update icon cache
@echo "#!/bin/sh" > $(CONTROL_DIR)/postinst
@echo "set -e" >> $(CONTROL_DIR)/postinst
@echo "if [ \"\$$1\" = \"configure\" ] || [ \"\$$1\" = \"abort-upgrade\" ] || [ \"\$$1\" = \"abort-deconfigure\" ] || [ \"\$$1\" = \"abort-remove\" ]; then" >> $(CONTROL_DIR)/postinst
@echo " if command -v gtk-update-icon-cache >/dev/null 2>&1; then" >> $(CONTROL_DIR)/postinst
@echo " gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor || true" >> $(CONTROL_DIR)/postinst
@echo " fi" >> $(CONTROL_DIR)/postinst
@echo " if command -v update-desktop-database >/dev/null 2>&1; then" >> $(CONTROL_DIR)/postinst
@echo " update-desktop-database -q /usr/share/applications || true" >> $(CONTROL_DIR)/postinst
@echo " fi" >> $(CONTROL_DIR)/postinst
@echo "fi" >> $(CONTROL_DIR)/postinst
@echo "exit 0" >> $(CONTROL_DIR)/postinst
# Create control file with library dependencies
@echo "Creating control file with dependencies..."
@chmod +x $(FIND_DEPS_SCRIPT)
@echo "Detecting library dependencies..."
@DEPS=$$($(FIND_DEPS_SCRIPT) --quiet --format makefile $(EXTRACT_DIR)/zed.app/lib); \
echo "Package: $(PACKAGE_NAME)" > $(CONTROL_DIR)/control; \
echo "Version: $(VERSION)" >> $(CONTROL_DIR)/control; \
echo "Section: editors" >> $(CONTROL_DIR)/control; \
echo "Priority: optional" >> $(CONTROL_DIR)/control; \
echo "Architecture: amd64" >> $(CONTROL_DIR)/control; \
if [ -n "$$DEPS" ]; then \
echo "Depends: $$DEPS" >> $(CONTROL_DIR)/control; \
echo " Detected dependencies: $$DEPS"; \
else \
echo "Depends: libc6" >> $(CONTROL_DIR)/control; \
echo " Warning: Could not detect dependencies, using minimal set"; \
fi; \
echo "Maintainer: Zed Packager <packager@local>" >> $(CONTROL_DIR)/control; \
echo "Description: Zed - A high-performance, multiplayer code editor" >> $(CONTROL_DIR)/control; \
echo " Zed is a next-generation code editor designed for" >> $(CONTROL_DIR)/control; \
echo " high-performance collaboration with humans and AI." >> $(CONTROL_DIR)/control; \
echo " ." >> $(CONTROL_DIR)/control; \
echo " This package uses system libraries instead of bundled ones." >> $(CONTROL_DIR)/control; \
echo "Homepage: https://zed.dev" >> $(CONTROL_DIR)/control
# Create postrm script to update icon cache on removal
@echo "#!/bin/sh" > $(CONTROL_DIR)/postrm
@echo "set -e" >> $(CONTROL_DIR)/postrm
@echo "if [ \"\$$1\" = \"remove\" ] || [ \"\$$1\" = \"purge\" ]; then" >> $(CONTROL_DIR)/postrm
@echo " if command -v gtk-update-icon-cache >/dev/null 2>&1; then" >> $(CONTROL_DIR)/postrm
@echo " gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor || true" >> $(CONTROL_DIR)/postrm
@echo " fi" >> $(CONTROL_DIR)/postrm
@echo " if command -v update-desktop-database >/dev/null 2>&1; then" >> $(CONTROL_DIR)/postrm
@echo " update-desktop-database -q /usr/share/applications || true" >> $(CONTROL_DIR)/postrm
@echo " fi" >> $(CONTROL_DIR)/postrm
@echo "fi" >> $(CONTROL_DIR)/postrm
@echo "exit 0" >> $(CONTROL_DIR)/postrm
# Copy maintainer scripts
@echo "Creating maintainer scripts..."
@cp postinst $(CONTROL_DIR)/postinst
@cp postrm $(CONTROL_DIR)/postrm
# Set permissions
@chmod 755 $(DEB_DIR)/opt/zed/bin/zed
@chmod 755 $(DEB_DIR)/opt/zed/libexec/zed-editor
@echo "Setting permissions..."
@chmod 755 $(DEB_DIR)/usr/bin/zed
@chmod 755 $(DEB_DIR)/usr/libexec/zed-editor
@chmod 755 $(CONTROL_DIR)/postinst
@chmod 755 $(CONTROL_DIR)/postrm
@find $(DEB_DIR)/opt/zed/lib -type f -name "*.so*" -exec chmod 644 {} \;
# Build the .deb package
@echo "Creating .deb package..."
@@ -131,7 +134,11 @@ $(DEB_FILE): $(EXTRACT_DIR)/.extracted
@echo ""
@echo "✓ Package successfully created: $(DEB_FILE)"
@echo ""
@echo "Dependencies were automatically detected from bundled libraries."
@echo "Run 'make list-deps' to see the full dependency analysis."
@echo ""
@echo "To install: sudo dpkg -i $(DEB_FILE)"
@echo "If dependencies are missing: sudo apt-get install -f"
# Clean up
clean: