Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
Signed-off-by: leleliu008 <[email protected]>
  • Loading branch information
leleliu008 committed Dec 20, 2023
1 parent b17eff9 commit 6530c97
Show file tree
Hide file tree
Showing 29 changed files with 246 additions and 230 deletions.
203 changes: 85 additions & 118 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,155 +47,89 @@ jobs:
needs: check
if: needs.check.outputs.if-has-new-commit == 'yes'

runs-on: macos-12

steps:
- uses: leleliu008/github-actions-vagrant@main
with:
mem: 8192
box: generic/netbsd9
run: |
export HOME=/home/vagrant
run sudo sed -i 's/#ETCCERTSDIR=/ETCCERTSDIR=/' /usr/pkg/etc/ca-certificates-dir.conf
run sudo update-ca-certificates
unset ETCCERTSDIR
ETCCERTSDIR=$(sed -n '/^ETCCERTSDIR=/p' /usr/pkg/etc/ca-certificates-dir.conf | sed 's|ETCCERTSDIR=\(.*\)|\1|')
if [ -n "$ETCCERTSDIR" ] ; then
export SSL_CERT_FILE="$ETCCERTSDIR/ca-certificates.crt"
fi
run sudo pkgin -y update
run sudo pkgin -y install llvm
runs-on: ubuntu-latest

run curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
run chmod a+x ppkg
run ./ppkg setup
run ./ppkg update
strategy:
fail-fast: false
matrix:
# https://ftp.netbsd.org/pub/NetBSD/
target-version: ['9.1', '9.2', '9.3']

~/.uppm/installed/gsed/bin/gsed -i "/git-url/a git-sha: ${{ needs.check.outputs.git-sha }}" ~/.ppkg/repos.d/offical-core/formula/uppm.yml
steps:
- run: curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
- run: chmod a+x ppkg
- run: ./ppkg setup
- run: ./ppkg update

run ./ppkg install uppm --link-type=static-only --install-lib=static
run ./ppkg pack uppm
- run: |
~/.uppm/installed/gsed/bin/gsed -i "/git-url/a git-sha: ${{ needs.check.outputs.git-sha }}" ~/.ppkg/repos.d/offical-core/formula/uppm.yml
- run: scp -i $VAGRANT_CWD/.vagrant/machines/default/virtualbox/private_key -o StrictHostKeyChecking=no -r -P 2222 [email protected]:/home/vagrant/.ppkg/packed/uppm-*-netbsd-amd64.tar.xz .
- run: ./ppkg install netbsd-${{ matrix.target-version }}-amd64/uppm --link-type=static-full
- run: ./ppkg pack netbsd-${{ matrix.target-version }}-amd64/uppm

- uses: actions/upload-artifact@v3
with:
name: uppm---netbsd-amd64-tar-xz
path: uppm-*-netbsd-amd64.tar.xz
name: uppm---netbsd-${{ matrix.target-version }}-amd64-tar-xz
path: uppm-*-netbsd-${{ matrix.target-version }}-amd64.tar.xz


openbsd-amd64:
needs: [check, netbsd-amd64]
if: needs.check.outputs.if-has-new-commit == 'yes'

runs-on: macos-12
runs-on: ubuntu-latest

env:
VAGRANT_LOG: info
# https://www.vagrantup.com/docs/other/debugging
strategy:
fail-fast: false
matrix:
# https://cdn.openbsd.org/pub/OpenBSD/
target-version: ['7.2', '7.3', '7.4']

steps:
- run: |
echo 'set -e' > shell.sh
export -p | grep 'GITHUB_' >> shell.sh
cat >> shell.sh <<'EOF'
run() {
printf "\033[0;35m==>\033[0m \033[0;32m%b\n\033[0m" "$*"
eval "$*"
}
run sudo pkg_add curl gtar-- gcc%11
run sudo ln -s /usr/local/bin/gtar /usr/bin/tar
export HOME=/home/vagrant
export LD_LIBRARY_PATH=/usr/local/lib
run cd /home/vagrant/${{ github.repository }}
run curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
run chmod a+x ppkg
run ./ppkg setup
run ./ppkg update
~/.uppm/installed/gsed/bin/gsed -i "/git-url/a git-sha: ${{ needs.check.outputs.git-sha }}" ~/.ppkg/repos.d/offical-core/formula/uppm.yml
run ./ppkg install uppm --link-type=static-only --install-lib=static
run ./ppkg pack uppm -o .
ls uppm-*-openbsd-amd64.tar.xz > name.txt
run curl -LO https://raw.githubusercontent.com/emikulic/darkhttpd/master/darkhttpd.c
run cc -o darkhttpd darkhttpd.c
run ./darkhttpd . --port 8080 &
EOF
cat shell.sh
- run: curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
- run: chmod a+x ppkg
- run: ./ppkg setup
- run: ./ppkg update

- run: |
tee Vagrantfile <<EOF
Vagrant.configure("2") do |config|
config.vm.box = "generic/openbsd7"
config.vm.provider "virtualbox" do |vb|
vb.memory = "8192"
end
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.synced_folder ".", "/home/vagrant/${{ github.repository }}", type: "rsync"
config.vm.provision "shell", path: "shell.sh"
end
EOF
- run: vagrant up --provider virtualbox --provision
~/.uppm/installed/gsed/bin/gsed -i "/git-url/a git-sha: ${{ needs.check.outputs.git-sha }}" ~/.ppkg/repos.d/offical-core/formula/uppm.yml
- run: curl -O http://localhost:8080/name.txt
- run: curl -O http://localhost:8080/$(cat name.txt)
- run: ./ppkg install openbsd-${{ matrix.target-version }}-amd64/uppm --link-type=static-most
- run: ./ppkg pack openbsd-${{ matrix.target-version }}-amd64/uppm

- uses: actions/upload-artifact@v3
with:
name: uppm---openbsd-amd64-tar-xz
path: uppm-*-openbsd-amd64.tar.xz

name: uppm---openbsd-${{ matrix.target-version }}-amd64-tar-xz
path: uppm-*-openbsd-${{ matrix.target-version }}-amd64.tar.xz

freebsd-amd64:
needs: [check, openbsd-amd64]
if: needs.check.outputs.if-has-new-commit == 'yes'

runs-on: macos-12

steps:
- uses: leleliu008/github-actions-vagrant@main
with:
mem: 8192
box: generic/freebsd13
run: |
export HOME=/home/vagrant
run pkg install -y gcc curl libnghttp2
runs-on: ubuntu-latest

run curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
run chmod a+x ppkg
run ./ppkg setup
run ./ppkg update
strategy:
fail-fast: false
matrix:
# https://archive.freebsd.org/old-releases/amd64/
target-version: ['13.0', '13.1', '13.2']

~/.uppm/installed/gsed/bin/gsed -i "/git-url/a git-sha: ${{ needs.check.outputs.git-sha }}" ~/.ppkg/repos.d/offical-core/formula/uppm.yml
steps:
- run: curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
- run: chmod a+x ppkg
- run: ./ppkg setup
- run: ./ppkg update

run ./ppkg install uppm --link-type=static-only --install-lib=static
run ./ppkg pack uppm
- run: |
~/.uppm/installed/gsed/bin/gsed -i "/git-url/a git-sha: ${{ needs.check.outputs.git-sha }}" ~/.ppkg/repos.d/offical-core/formula/uppm.yml
- run: scp -i $VAGRANT_CWD/.vagrant/machines/default/virtualbox/private_key -o StrictHostKeyChecking=no -r -P 2222 [email protected]:/home/vagrant/.ppkg/packed/uppm-*-freebsd-amd64.tar.xz .
- run: ./ppkg install freebsd-${{ matrix.target-version }}-amd64/uppm --link-type=static-full
- run: ./ppkg pack freebsd-${{ matrix.target-version }}-amd64/uppm

- uses: actions/upload-artifact@v3
with:
name: uppm---freebsd-amd64-tar-xz
path: uppm-*-freebsd-amd64.tar.xz
name: uppm---freebsd-${{ matrix.target-version }}-amd64-tar-xz
path: uppm-*-freebsd-${{ matrix.target-version }}-amd64.tar.xz


macos:
Expand Down Expand Up @@ -488,19 +422,52 @@ jobs:
steps:
- uses: actions/download-artifact@v3
with:
name: uppm---netbsd-amd64-tar-xz
name: uctags---netbsd-9.1-amd64-tar-xz
path: .

- uses: actions/download-artifact@v3
with:
name: uppm---openbsd-amd64-tar-xz
name: uctags---netbsd-9.2-amd64-tar-xz
path: .

- uses: actions/download-artifact@v3
with:
name: uppm---freebsd-amd64-tar-xz
name: uctags---netbsd-9.3-amd64-tar-xz
path: .


- uses: actions/download-artifact@v3
with:
name: uctags---openbsd-7.2-amd64-tar-xz
path: .

- uses: actions/download-artifact@v3
with:
name: uctags---openbsd-7.3-amd64-tar-xz
path: .

- uses: actions/download-artifact@v3
with:
name: uctags---openbsd-7.4-amd64-tar-xz
path: .


- uses: actions/download-artifact@v3
with:
name: uctags---freebsd-13.0-amd64-tar-xz
path: .

- uses: actions/download-artifact@v3
with:
name: uctags---freebsd-13.1-amd64-tar-xz
path: .

- uses: actions/download-artifact@v3
with:
name: uctags---freebsd-13.2-amd64-tar-xz
path: .


- uses: actions/download-artifact@v3
with:
name: uppm---macos10.15-x86_64-tar-xz
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,57 @@ Universal Prebuild Package Manager for Unix-like systems.

- Please do NOT place your own files under `~/.uppm` directory, as `uppm` will change files under `~/.uppm` directory without notice.

## dependences
## Build from source dependencies

|dependency|required?|purpose|
|----|---------|-------|
|[cmake](https://cmake.org/)|required |for generating `build.ninja`|
|[ninja](https://ninja-build.org/)|required |for doing jobs that read from `build.ninja`|
|[pkg-config>=0.18](https://www.freedesktop.org/wiki/Software/pkg-config/)|required|for finding libraries.|
|[pkg-config>=0.18](https://www.freedesktop.org/wiki/Software/pkg-config/)|required|for finding libraries|
||||
|[jansson](https://github.com/akheron/jansson)|required|for parsing and creating JSON.|
|[libyaml](https://github.com/yaml/libyaml/)|required|for parsing formulas whose format is YAML.|
|[libyaml](https://github.com/yaml/libyaml/)|required|for parsing formula files whose format is YAML.|
|[libgit2](https://libgit2.org/)|required|for updating formula repositories.|
|[libcurl](https://curl.se/)|required|for http requesting support.|
|[openssl](https://www.openssl.org/)|required|for https requesting support and SHA-256 sum checking support.|
|[libarchive](https://www.libarchive.org/)|required|for uncompressing .zip and .tar.* files.|
|[zlib](https://www.zlib.net/)|required|for compressing and uncompressing.|
|[pcre2](https://www.pcre.org/)||for Regular Expressions support.<br>only required on OpenBSD.|
|[zlib](https://www.zlib.net/)|required|for compress and uncompress data.|
|[pcre2](https://www.pcre.org/)||for Regular Expressions support. only required on OpenBSD.|

## build and install uppm via [ppkg](https://github.com/leleliu008/ppkg)
### Build from source via [ppkg](https://github.com/leleliu008/ppkg)

```bash
ppkg install uppm
```

## build and install uppm via [xcpkg](https://github.com/leleliu008/xcpkg)
### Build from source via [xcpkg](https://github.com/leleliu008/xcpkg)

```bash
xcpkg install uppm
```

## build and install uppm using [vcpkg](https://github.com/microsoft/vcpkg)
### Build from source using [vcpkg](https://github.com/microsoft/vcpkg)

```bash
# install g++ curl zip unzip tar git

git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg install curl openssl libgit2 libarchive libyaml jansson
export VCPKG_ROOT="$PWD/vcpkg"
export PATH="$VCPKG_ROOT:$PATH"

cd -
vcpkg install curl openssl libgit2 libarchive libyaml jansson

git clone --depth=1 https://github.com/leleliu008/uppm
git clone --depth=1 --branch=c https://github.com/leleliu008/uppm
cd uppm

cmake -S . -B build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
cmake --build build.d
cmake --install build.d
```

## build and install uppm using your system's default package manager
## Build from source using your system's default package manager

**[Ubuntu](https://ubuntu.com/)**

Expand Down
7 changes: 4 additions & 3 deletions src/check.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdbool.h>

#include <limits.h>
#include <sys/stat.h>

#include "core/regex/regex.h"
Expand Down Expand Up @@ -73,10 +74,10 @@ int uppm_check_if_the_given_package_is_installed(const char * packageName) {
return ret;
}

char uppmHomeDIR[256] = {0};
char uppmHomeDIR[PATH_MAX];
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
ret = uppm_home_dir(uppmHomeDIR, PATH_MAX, &uppmHomeDIRLength);

if (ret != UPPM_OK) {
return ret;
Expand Down
11 changes: 6 additions & 5 deletions src/cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
#include <stdio.h>
#include <string.h>

#include <dirent.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/stat.h>

#include "uppm.h"

static int uppm_cleanup_downloads(bool verbose) {
char uppmHomeDIR[256] = {0};
char uppmHomeDIR[PATH_MAX];
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
int ret = uppm_home_dir(uppmHomeDIR, PATH_MAX, &uppmHomeDIRLength);

if (ret != UPPM_OK) {
return ret;
Expand Down Expand Up @@ -91,10 +92,10 @@ static int uppm_cleanup_downloads(bool verbose) {
}

static int uppm_cleanup_installed(bool verbose) {
char uppmHomeDIR[256] = {0};
char uppmHomeDIR[PATH_MAX];
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
int ret = uppm_home_dir(uppmHomeDIR, PATH_MAX, &uppmHomeDIRLength);

if (ret != UPPM_OK) {
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/core/exe.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int exe_lookup(const char * commandName, char ** pathP, size_t * pathLength) {
return 0;
}

int exe_lookup2(const char * commandName, char buf[], size_t * writtenSize, size_t maxSize) {
int exe_where(const char * commandName, char buf[], size_t * writtenSize, size_t maxSize) {
if (commandName == NULL) {
errno = EINVAL;
return -1;
Expand Down
Loading

0 comments on commit 6530c97

Please sign in to comment.