build: cleanup build process

This commit is contained in:
2026-02-20 01:40:15 +01:00
parent d80b9f387b
commit 5b4095677e
3 changed files with 92 additions and 30 deletions
+11 -17
View File
@@ -19,27 +19,22 @@ include $(PGXS)
# Custom targets # Custom targets
# Build development SQL from source files # Build versioned SQL file from source files
.PHONY: build .PHONY: build
build: build:
@echo "Building $(DEV_SQL) from source files..." @echo "Building release $(EXTVERSION) from source files..."
@./tools/build.sh @./tools/build.sh
# Create versioned release file from development file
.PHONY: release
release: build
@echo "Preparing release $(EXTVERSION)..."
@if [ ! -f $(DEV_SQL) ]; then \ @if [ ! -f $(DEV_SQL) ]; then \
echo "Error: $(DEV_SQL) not found"; \ echo "Error: Build failed"; \
exit 1; \ exit 1; \
fi fi
cp $(DEV_SQL) $(DATA) cp $(DEV_SQL) $(DATA)
@echo "Created $(DATA)" @echo "Created $(DATA)"
@echo "Ready to commit and tag with: git tag v$(EXTVERSION)" @echo "Ready to install or tag: git tag v$(EXTVERSION)"
# Install extension in PostgreSQL (creates versioned file if needed) # Install extension in PostgreSQL (creates versioned file if needed)
.PHONY: install .PHONY: install
install: release install: build
@echo "Installing morbac_pg extension..." @echo "Installing morbac_pg extension..."
$(MAKE) -f Makefile install $(MAKE) -f Makefile install
@@ -67,18 +62,17 @@ help:
@echo "Development:" @echo "Development:"
@echo " Edit source files in src/ directory" @echo " Edit source files in src/ directory"
@echo "" @echo ""
@echo " make build - Build morbac_pg.sql from src/ files" @echo " make build - Build versioned morbac_pg--X.Y.Z.sql from src/"
@echo " make test - Build and test in temporary database" @echo " make test - Build and run test suite"
@echo " make release - Build and create versioned file" @echo " make install - Build and install extension to PostgreSQL"
@echo " make install - Build, release, and install extension"
@echo " make uninstall - Uninstall extension from PostgreSQL" @echo " make uninstall - Uninstall extension from PostgreSQL"
@echo " make help - Show this help" @echo " make help - Show this help"
@echo "" @echo ""
@echo "Workflow:" @echo "Workflow:"
@echo " 1. Edit source files in src/ directory" @echo " 1. Edit source files in src/"
@echo " 2. make test (build and test your changes)" @echo " 2. make test (build and test changes)"
@echo " 3. Update version in morbac_pg.control" @echo " 3. Update version in morbac_pg.control"
@echo " 4. make release (builds and creates morbac_pg--X.Y.Z.sql)" @echo " 4. make build (builds versioned SQL)"
@echo " 5. git tag vX.Y.Z && git push --tags" @echo " 5. git tag vX.Y.Z && git push --tags"
@echo "" @echo ""
@echo "" @echo ""
+54 -12
View File
@@ -22,10 +22,13 @@ A PostgreSQL extension implementing the Multi-OrBAC access control model - enabl
- Audit logging for security-critical operations - Audit logging for security-critical operations
- Row-level security integration - Row-level security integration
## Installation
### Prerequisites ### Prerequisites
- PostgreSQL 12 or higher - PostgreSQL 12 or higher
- `pgcrypto` extension (included with PostgreSQL) - `pgcrypto` extension (included with PostgreSQL)
- Development tools: `make`, `bash`
### Quick Install ### Quick Install
@@ -34,16 +37,30 @@ A PostgreSQL extension implementing the Multi-OrBAC access control model - enabl
git clone https://github.com/yourusername/morbac_pg.git git clone https://github.com/yourusername/morbac_pg.git
cd morbac_pg cd morbac_pg
# Install extension # Build and install extension
sudo make install make build # Build versioned file from src/
sudo make install # Install to PostgreSQL
# Enable in your database # Enable in your database
psql -d mydb -c "CREATE EXTENSION morbac_pg;" psql -d mydb -c "CREATE EXTENSION morbac_pg;"
``` ```
### Alternative: Using install script
```bash
# Build first
make build
# Run installer
sudo ./tools/install.sh
```
### Manual Install ### Manual Install
```bash ```bash
# Build versioned file from source
make build # Concatenates src/ files into morbac_pg--1.0.0.sql
# Copy files to PostgreSQL extension directory # Copy files to PostgreSQL extension directory
sudo cp morbac_pg.control $(pg_config --sharedir)/extension/ sudo cp morbac_pg.control $(pg_config --sharedir)/extension/
sudo cp morbac_pg--1.0.0.sql $(pg_config --sharedir)/extension/ sudo cp morbac_pg--1.0.0.sql $(pg_config --sharedir)/extension/
@@ -147,22 +164,35 @@ ORDER BY timestamp DESC
LIMIT 10; LIMIT 10;
``` ```
## Testing ## Development & Testing
```bash ```bash
make test # Run test suite in dedicated database # Development workflow
make test-db DB=mydb # Run on existing database # 1. Edit source files in src/ directory
make cleanup # Remove test database # 2. Build and test
make build # Build versioned morbac_pg--X.Y.Z.sql from src/
make test # Build and run test suite
# Manual testing
make build
createdb morbac_test
psql -d morbac_test -f morbac_pg.sql
# ... test manually ...
dropdb morbac_test
``` ```
See [src/README.md](src/README.md) for source code organization.
## Documentation ## Documentation
- [DOCUMENTATION.md](docs/DOCUMENTATION.md) - Architecture, API reference, integration guides - [DOCUMENTATION.md](docs/DOCUMENTATION.md) - Architecture, API reference, integration guides
- [PERFORMANCE.md](docs/PERFORMANCE.md) - Performance optimization and caching guide - [PERFORMANCE.md](docs/PERFORMANCE.md) - Performance optimization and caching guide
- [ADMIN_GUIDE.md](docs/ADMIN_GUIDE.md) - Organization administrator setup and delegation - [ADMIN_GUIDE.md](docs/ADMIN_GUIDE.md) - Organization administrator setup and delegation
- [DEVELOPMENT.md](docs/DEVELOPMENT.md) - Development workflow and version management
- [SECURITY.md](docs/SECURITY.md) - Security policy - [SECURITY.md](docs/SECURITY.md) - Security policy
- [CONTRIBUTING.md](docs/CONTRIBUTING.md) - Contribution guidelines - [CONTRIBUTING.md](docs/CONTRIBUTING.md) - Contribution guidelines
- [test_morbac.sql](test_morbac.sql) - Test scenarios and examples - [src/README.md](src/README.md) - Source code organization
- [tests/README.md](tests/README.md) - Test structure and setup
- [CHANGELOG.md](CHANGELOG.md) - Version history - [CHANGELOG.md](CHANGELOG.md) - Version history
## Architecture ## Architecture
@@ -186,21 +216,33 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
## Contributing ## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines.
```bash ```bash
git clone https://github.com/yourusername/morbac_pg.git git clone https://github.com/yourusername/morbac_pg.git
cd morbac_pg cd morbac_pg
make install
make test # Edit source files in src/
vim src/authorization.sql
# Build and test your changes
make test # Run test suite
# When ready to release
# 1. Update version in morbac_pg.control
# 2. Build versioned file
make build # Creates morbac_pg--X.Y.Z.sql
# 3. Tag in git
git tag v1.0.1
git push --tags
``` ```
## Support ## Support
- Read the [documentation](DOCUMENTATION.md) - Read the [documentation](docs/DOCUMENTATION.md)
- Report bugs via [GitHub Issues](https://github.com/yourusername/morbac_pg/issues) - Report bugs via [GitHub Issues](https://github.com/yourusername/morbac_pg/issues)
- Ask questions in [Discussions](https://github.com/yourusername/morbac_pg/discussions) - Ask questions in [Discussions](https://github.com/yourusername/morbac_pg/discussions)
- Security issues: see [SECURITY.md](SECURITY.md) - Security issues: see [SECURITY.md](docs/SECURITY.md)
## Comparison with Traditional RBAC ## Comparison with Traditional RBAC
+27 -1
View File
@@ -39,10 +39,36 @@ if [ ! -d "$EXTDIR" ]; then
exit 1 exit 1
fi fi
# Detect version from control file
CONTROL_FILE="morbac_pg.control"
if [ ! -f "$CONTROL_FILE" ]; then
echo "Error: $CONTROL_FILE not found"
echo "Please run this script from the morbac_pg directory"
exit 1
fi
VERSION=$(grep "default_version" "$CONTROL_FILE" | sed "s/default_version = '\(.*\)'/\1/")
if [ -z "$VERSION" ]; then
echo "Error: Could not detect version from $CONTROL_FILE"
exit 1
fi
SQL_FILE="morbac_pg--${VERSION}.sql"
echo "Detected version: $VERSION"
echo ""
# Check if versioned SQL file exists
if [ ! -f "$SQL_FILE" ]; then
echo "Error: $SQL_FILE not found"
echo "Please run 'make build' first to create the versioned SQL file"
exit 1
fi
# Copy extension files # Copy extension files
echo "Installing extension files..." echo "Installing extension files..."
cp -v morbac_pg.control "$EXTDIR/" cp -v morbac_pg.control "$EXTDIR/"
cp -v morbac_pg--1.0.0.sql "$EXTDIR/" cp -v "$SQL_FILE" "$EXTDIR/"
echo "" echo ""
echo "==================================" echo "=================================="