diff --git a/.gitignore b/.gitignore index a8ec735..ef6f94e 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ \ No newline at end of file +*.a \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f392d9..5182feb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") -# Add executable -add_executable(yns +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(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 - ) -") \ No newline at end of file +target_link_libraries(yns PRIVATE + ${CURL_LIBRARY} + OpenSSL::SSL + OpenSSL::Crypto + ZLIB::ZLIB + -static + -pthread) diff --git a/README.md b/README.md index b6eee9b..9541e0b 100644 --- a/README.md +++ b/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 # Install package +yns remove # Remove package +yns upgrade # Upgrade package +yns list # List packages +yns debug # Show debug info +yns interactive # Interactive mode ``` -### Install a package -```bash -yns install -``` +## Package Format -### Remove a package -```bash -yns remove -``` - -### Upgrade a package -```bash -yns upgrade -``` - -### 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 ` - Install a package -- `remove ` - Remove a package -- `upgrade ` - 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 \ No newline at end of file +```json +{ + "packages": { + "package-name": { + "version": "1.0.0", + "description": "Package description", + "install_script": "#!/bin/bash\n# Installation commands" + } + } +} \ No newline at end of file diff --git a/build_curl.sh b/build_curl.sh new file mode 100755 index 0000000..1527938 --- /dev/null +++ b/build_curl.sh @@ -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 \ No newline at end of file