mirror of
https://github.com/spitkov/ynspkg.git
synced 2025-01-18 04:24:39 +01:00
static linking
This commit is contained in:
parent
fd53ef08fb
commit
e19ba7ac5e
4 changed files with 99 additions and 198 deletions
39
.gitignore
vendored
39
.gitignore
vendored
|
@ -1,42 +1,5 @@
|
|||
# Build directories
|
||||
deps/
|
||||
build/
|
||||
cmake-build-*/
|
||||
|
||||
# IDE specific files
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Package manager specific
|
||||
/var/cache/yns/
|
||||
/var/lib/yns/
|
|
@ -1,38 +1,31 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project(yns VERSION 1.0)
|
||||
project(yns)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Find required packages
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||
|
||||
set(CURL_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/deps/install/include")
|
||||
set(CURL_LIBRARY "${CMAKE_SOURCE_DIR}/deps/install/lib/libcurl.a")
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# Add executable
|
||||
add_executable(yns
|
||||
src/main.cpp
|
||||
src/package_manager.cpp
|
||||
)
|
||||
src/package_manager.cpp)
|
||||
|
||||
# Include directories
|
||||
target_include_directories(yns PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CURL_INCLUDE_DIRS}
|
||||
)
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CURL_INCLUDE_DIR})
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(yns PRIVATE
|
||||
${CURL_LIBRARIES}
|
||||
nlohmann_json::nlohmann_json
|
||||
)
|
||||
|
||||
# Installation
|
||||
install(TARGETS yns DESTINATION bin)
|
||||
|
||||
# Create required directories during installation
|
||||
install(CODE "
|
||||
execute_process(
|
||||
COMMAND mkdir -p /var/cache/yns
|
||||
COMMAND mkdir -p /var/lib/yns
|
||||
)
|
||||
")
|
||||
${CURL_LIBRARY}
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
ZLIB::ZLIB
|
||||
-static
|
||||
-pthread)
|
||||
|
|
157
README.md
157
README.md
|
@ -1,150 +1,45 @@
|
|||
# YNS Package Manager
|
||||
|
||||
A lightweight package manager for Linux that uses a single repository source.
|
||||
Simple package manager for Linux. Uses JSON for package definitions.
|
||||
|
||||
## Dependencies
|
||||
## Build
|
||||
|
||||
- CMake (>= 3.10)
|
||||
- C++17 compiler
|
||||
- libcurl
|
||||
- nlohmann-json
|
||||
|
||||
On Ubuntu/Debian, you can install the dependencies with:
|
||||
Install dependencies:
|
||||
```bash
|
||||
sudo apt-get install build-essential cmake libcurl4-openssl-dev nlohmann-json3-dev
|
||||
sudo apt-get install build-essential cmake libssl-dev zlib1g-dev
|
||||
```
|
||||
|
||||
## Building
|
||||
We build our own curl to make a static binary that works everywhere without dependencies.
|
||||
|
||||
Build steps:
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
bash build_curl.sh
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
After building, you can install the package manager with:
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
This will:
|
||||
- Install the `yns` binary to `/usr/local/bin`
|
||||
- Create necessary directories:
|
||||
- `/var/cache/yns/` - For package cache
|
||||
- `/var/lib/yns/` - For installed package database
|
||||
|
||||
## Usage
|
||||
|
||||
### Update package cache
|
||||
```bash
|
||||
yns update
|
||||
yns update # Update package cache
|
||||
yns install <package> # Install package
|
||||
yns remove <package> # Remove package
|
||||
yns upgrade <package> # Upgrade package
|
||||
yns list # List packages
|
||||
yns debug # Show debug info
|
||||
yns interactive # Interactive mode
|
||||
```
|
||||
|
||||
### Install a package
|
||||
```bash
|
||||
yns install <package_name>
|
||||
```
|
||||
## Package Format
|
||||
|
||||
### Remove a package
|
||||
```bash
|
||||
yns remove <package_name>
|
||||
```
|
||||
|
||||
### Upgrade a package
|
||||
```bash
|
||||
yns upgrade <package_name>
|
||||
```
|
||||
|
||||
### List all packages
|
||||
```bash
|
||||
yns list
|
||||
```
|
||||
|
||||
### Interactive Mode
|
||||
```bash
|
||||
yns interactive
|
||||
```
|
||||
|
||||
Interactive mode provides a shell-like interface where you can execute multiple commands without the `yns` prefix. Available commands in interactive mode:
|
||||
|
||||
- `help` - Show available commands
|
||||
- `update` - Update package cache
|
||||
- `install <package>` - Install a package
|
||||
- `remove <package>` - Remove a package
|
||||
- `upgrade <package>` - Upgrade a package
|
||||
- `list` - List all packages
|
||||
- `clear` - Clear the screen
|
||||
- `exit` - Exit interactive mode
|
||||
|
||||
Example interactive session:
|
||||
```
|
||||
$ yns interactive
|
||||
YNS Package Manager Interactive Mode
|
||||
Type 'help' for available commands or 'exit' to quit
|
||||
yns> update
|
||||
[100%] Package cache updated successfully
|
||||
yns> list
|
||||
Available packages:
|
||||
==================
|
||||
calc [installed 1.1, update available 2.0]
|
||||
notepad [available 2.0]
|
||||
yns> install notepad
|
||||
[50%] Installing notepad@2.0
|
||||
notepad@2.0 installed successfully
|
||||
yns> exit
|
||||
Goodbye!
|
||||
```
|
||||
|
||||
## Color Coding
|
||||
|
||||
The package manager uses color-coded output for better visibility:
|
||||
|
||||
🔵 Blue:
|
||||
- Progress indicators (e.g., "[50%] Installing package...")
|
||||
- Available but not installed packages in `yns list`
|
||||
- Interactive mode prompt
|
||||
|
||||
🟢 Green:
|
||||
- Success messages
|
||||
- Installed packages that are up to date in `yns list`
|
||||
- Interactive mode welcome message
|
||||
|
||||
🟡 Yellow:
|
||||
- Installed packages with updates available in `yns list`
|
||||
|
||||
🔴 Red:
|
||||
- Error messages
|
||||
|
||||
Example `yns list` output:
|
||||
```
|
||||
Available packages:
|
||||
==================
|
||||
calc [installed 1.1, update available 2.0] # Yellow
|
||||
notepad [available 2.0] # Blue
|
||||
vim [installed 3.0] # Green
|
||||
```
|
||||
|
||||
## Repository Structure
|
||||
|
||||
The package manager uses a single repository source at:
|
||||
`https://raw.githubusercontent.com/spitkov/ynsrepo/refs/heads/main/repo.json`
|
||||
|
||||
The repository contains package information in JSON format, including:
|
||||
- Package name
|
||||
- Version
|
||||
- Installation script URL
|
||||
- Update script URL
|
||||
- Remove script URL
|
||||
|
||||
## Features
|
||||
|
||||
- Colored terminal output
|
||||
- Progress indicators
|
||||
- Automatic package cache management
|
||||
- Version tracking for installed packages
|
||||
- Secure script execution
|
||||
- Error handling and recovery
|
||||
- Interactive shell mode
|
||||
```json
|
||||
{
|
||||
"packages": {
|
||||
"package-name": {
|
||||
"version": "1.0.0",
|
||||
"description": "Package description",
|
||||
"install_script": "#!/bin/bash\n# Installation commands"
|
||||
}
|
||||
}
|
||||
}
|
50
build_curl.sh
Executable file
50
build_curl.sh
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
CURL_VERSION="8.6.0"
|
||||
BUILD_DIR="$(pwd)/deps"
|
||||
INSTALL_DIR="$(pwd)/deps/install"
|
||||
|
||||
# Create directories
|
||||
mkdir -p "$BUILD_DIR"
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
|
||||
# Download and extract curl
|
||||
cd "$BUILD_DIR"
|
||||
wget "https://curl.se/download/curl-${CURL_VERSION}.tar.gz"
|
||||
tar xf "curl-${CURL_VERSION}.tar.gz"
|
||||
cd "curl-${CURL_VERSION}"
|
||||
|
||||
# Configure with minimal features
|
||||
./configure \
|
||||
--prefix="$INSTALL_DIR" \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
--disable-ldap \
|
||||
--disable-ldaps \
|
||||
--disable-rtsp \
|
||||
--disable-dict \
|
||||
--disable-telnet \
|
||||
--disable-tftp \
|
||||
--disable-pop3 \
|
||||
--disable-imap \
|
||||
--disable-smtp \
|
||||
--disable-gopher \
|
||||
--disable-smb \
|
||||
--disable-mqtt \
|
||||
--without-librtmp \
|
||||
--without-libidn2 \
|
||||
--without-libpsl \
|
||||
--without-nghttp2 \
|
||||
--without-libssh2 \
|
||||
--without-zstd \
|
||||
--without-brotli \
|
||||
--without-gssapi \
|
||||
--with-openssl \
|
||||
CFLAGS="-fPIC"
|
||||
|
||||
# Build and install
|
||||
make -j$(nproc)
|
||||
make install
|
Loading…
Reference in a new issue