Skip to content

Commit 9e6df35

Browse files
authored
Merge pull request #2 from mkromis/2024-06_cleanup
2024-06_cleanup
2 parents d5044e6 + b7a09e0 commit 9e6df35

File tree

7 files changed

+74
-166
lines changed

7 files changed

+74
-166
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# PKGBUILDS
22

33
Learn, have fun and enjoy.
4+
5+
## Description
6+
7+
A build automation system using javascript for shell processing.
8+
And a place for me to store my pkgbuild, found and modified from the web.

build-packages.ts

+52-22
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
// https://google.github.io/zx/typescript
44

55
import 'node:fs'
6+
import ct from 'chalk-template'
67
import 'zx/globals';
78

89
// Change this to a directory of your choosing.
910
// Your repo name and path
1011
const root = path.resolve('.');
1112
const repo=path.resolve("../kitsune_repo/x86_64")
1213
console.log(`Root: ${root}`)
13-
console.log(`Destination: ${repo}`)
14+
console.log(`Dest: ${repo}`)
1415

1516
// Ideally there will be 2 options for compiling
1617
// 1. chroot" (Default)
@@ -20,13 +21,17 @@ console.log(`Destination: ${repo}`)
2021
// maybe in the future if needed.
2122
const dirs = ScanDirs()
2223
await BuildPackages(dirs)
24+
BuildDone()
2325

24-
// List of directories except the ones we don't want
26+
/**
27+
* List of directories except the ones we don't want
28+
* @returns list of directories
29+
*/
2530
function ScanDirs() : Array<string> {
2631
let result = new Array<string>()
2732
const skipFiles = ['.git', 'node_modules']
2833

29-
fs.readdirSync('.').forEach(file => {
34+
fs.readdirSync('.').forEach((file: string) => {
3035
// Skip invalid dirs,
3136
if (skipFiles.includes(file)) {return}
3237

@@ -41,12 +46,16 @@ function ScanDirs() : Array<string> {
4146
return result;
4247
}
4348

49+
/**
50+
* Builds each package given the array of directories
51+
* @param dirs directories as string to parse
52+
*/
4453
function BuildPackages(dirs: Array<string>) {
4554
// This is a list of dirs to process
4655
dirs.forEach( dir => {
4756
// We would do a check to see if we are needing a
4857
// chroot build or just a makepkg build.
49-
// Assuming just a chroot build for now.
58+
// Assuming just a makepkg build for now.
5059
MakepkgBuild(dir);
5160
})
5261
}
@@ -70,32 +79,50 @@ function BuildPackages(dirs: Array<string>) {
7079

7180
// cd /tmp/tempbuild/
7281

82+
/**
83+
* Tries to build package in a chroot environment
84+
* @param path Directory of package to build
85+
*/
7386
async function ChrootBuild(path: string) {
74-
await $`tput setaf 2`
75-
echo `#############################################################################################`
76-
echo `######### Let us build the package in CHROOT "${path}`
77-
echo `#############################################################################################`
78-
await $`tput sgr0`
87+
echo(ct`{green
88+
#############################################################################################
89+
######### Let us build the package in CHROOT
90+
######### {blue ${path}}
91+
#############################################################################################
92+
}`)
7993
//CHROOT=$HOME/Documents/chroot-data
8094
await $`arch-nspawn ${path}/root pacman -Syu`
8195
await $`makechrootpkg -c -r ${path}`
8296
}
8397

98+
/**
99+
* Basic directory build via makepkg
100+
* @param path Directory to build package
101+
*/
84102
async function MakepkgBuild(path: string) {
85-
await $`tput setaf 3`
86-
echo `#############################################################################################`
87-
echo `######### Let us build the package with MAKEPKG ${path}`
88-
echo `#############################################################################################`
89-
await $`tput sgr0`
103+
echo(ct`{yellow
104+
#############################################################################################
105+
######### Let us build the package with MAKEPKG
106+
######### {blue ${path}}
107+
#############################################################################################
108+
}`)
90109
cd (path)
91110
await $`makepkg -sc`
92111
MovePackages(path)
112+
cd (root)
93113
}
94114

115+
/**
116+
* Moves packages to destination folder
117+
* @param path Path of directory where packages exist
118+
*/
95119
async function MovePackages(path: string) {
96-
echo `#############################################################################################`
97-
echo `######### Moving created files to ${repo}`
98-
echo `#############################################################################################`
120+
echo(ct`{green
121+
#############################################################################################
122+
######### Moving created files to...
123+
######### {blue ${repo}}
124+
#############################################################################################
125+
}`)
99126
await $`mv ${path}/*pkg.tar.zst ${repo}`
100127
}
101128

@@ -114,10 +141,13 @@ async function MovePackages(path: string) {
114141
// rm $pwdpath/*.tar.gz
115142
// fi
116143

144+
/**
145+
* Done banner
146+
*/
117147
async function BuildDone() {
118-
await $`tput setaf 10`
119-
echo `#############################################################################################`
120-
echo `################### build done ######################`
121-
echo `#############################################################################################`
122-
await $`tput sgr0`
148+
echo(ct`{greenBright
149+
#############################################################################################
150+
################### build done ######################
151+
#############################################################################################
152+
}`)
123153
}

package-lock.json

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"author": "Mark Kromis",
1818
"license": "MIT",
1919
"dependencies": {
20+
"chalk-template": "^1.1.0",
2021
"zx": "^7.2.3"
2122
}
2223
}

setup-git-v5.sh

-79
This file was deleted.

setup-npm.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# DO NOT JUST RUN THIS. EXAMINE AND JUDGE. RUN AT YOUR OWN RISK.
23

34
# this will setup interperter see https://google.github.io/zx/cli

up.sh

-65
This file was deleted.

0 commit comments

Comments
 (0)