build: changed build scripts
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
21ef3f7ef6
commit
672314ab6d
3 changed files with 43 additions and 11 deletions
39
build
Executable file
39
build
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
build_pkgr() {
|
||||||
|
cd pkgr
|
||||||
|
mkdir -p dist/root/{usr/bin,etc/pkgr}
|
||||||
|
echo -e "You can't use pkgr to update pkgr because the file will be in use while updating.\nuse bootpkg" > dist/root/etc/pkgr/YOU-CAN-NOT-USE-PKGR-TO-UPDATE-PKGR.txt
|
||||||
|
|
||||||
|
# for bin
|
||||||
|
cargo build -r
|
||||||
|
cp target/release/pkgr dist/root/usr/bin/pkgr
|
||||||
|
|
||||||
|
# for build
|
||||||
|
mkdir -p dist/pkgr
|
||||||
|
cp -r src/ Cargo.toml dist/pkgr
|
||||||
|
cp -r ../manifest dist/manifest
|
||||||
|
cp -r ../pkgfile dist/pkgfile
|
||||||
|
|
||||||
|
cd dist
|
||||||
|
python ../../pkg.py ../package.toml pkgr.pkg "*"
|
||||||
|
cd ../..
|
||||||
|
}
|
||||||
|
|
||||||
|
build_bootpkg() {
|
||||||
|
cd bootpkg
|
||||||
|
mkdir -p dist/root/usr/bin
|
||||||
|
|
||||||
|
cargo build -r
|
||||||
|
cp target/release/bootpkg dist/root/usr/bin/bootpkg
|
||||||
|
|
||||||
|
|
||||||
|
cd dist
|
||||||
|
python ../../pkg.py ../package.toml bootpkg.pkg "*"
|
||||||
|
cd ../..
|
||||||
|
}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
build_bootpkg
|
||||||
|
build_pkgr
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
mkdir -p dist/root/usr/bin/ dist/root/etc/pkgr
|
|
||||||
echo "\x00" > dist/root/etc/pkgr/YOU.CAN.NOT.UPDATE.PKGR.WITH.PKGR
|
|
||||||
cd pkgr
|
|
||||||
cargo build -r
|
|
||||||
cp target/release/pkgr ../dist/root/usr/bin/pkgr
|
|
||||||
cd ../dist
|
|
||||||
python ../pkg.py ../package.toml pkgr root
|
|
6
pkg.py
6
pkg.py
|
@ -1,3 +1,4 @@
|
||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
|
@ -6,7 +7,7 @@ import tarfile
|
||||||
def build_package(package_toml_path, output_path, directories_to_include):
|
def build_package(package_toml_path, output_path, directories_to_include):
|
||||||
data = read_package_toml(package_toml_path)
|
data = read_package_toml(package_toml_path)
|
||||||
header = build_header(data)
|
header = build_header(data)
|
||||||
pkg_path = output_path + ".pkg"
|
pkg_path = output_path
|
||||||
|
|
||||||
with open(pkg_path, mode='wb') as pkg:
|
with open(pkg_path, mode='wb') as pkg:
|
||||||
pkg.write(header)
|
pkg.write(header)
|
||||||
|
@ -45,6 +46,7 @@ def add_files_to_tar(pkgtar, directory, skip_target=False):
|
||||||
if skip_target and "target" in root:
|
if skip_target and "target" in root:
|
||||||
continue
|
continue
|
||||||
print(f"\33[2Kadd: {os.path.join(root, file)}", end="\r", flush=True)
|
print(f"\33[2Kadd: {os.path.join(root, file)}", end="\r", flush=True)
|
||||||
|
# print()
|
||||||
pkgtar.add(os.path.join(root, file))
|
pkgtar.add(os.path.join(root, file))
|
||||||
print("\33[2K", end="\r", flush=True)
|
print("\33[2K", end="\r", flush=True)
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
package_toml_path = sys.argv[1]
|
package_toml_path = sys.argv[1]
|
||||||
output_path = sys.argv[2]
|
output_path = sys.argv[2]
|
||||||
directories_to_include = sys.argv[3:] if len(sys.argv) > 3 else None
|
directories_to_include = glob.glob(sys.argv[3]) if len(sys.argv) == 4 else sys.argv[3:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pkg_path = build_package(package_toml_path, output_path, directories_to_include)
|
pkg_path = build_package(package_toml_path, output_path, directories_to_include)
|
||||||
|
|
Loading…
Reference in a new issue