Compare commits

...

45 Commits

Author SHA1 Message Date
24a76c4c16 Update .github/release-nest-v3
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 38s
2024-10-02 19:42:50 +02:00
35bb9f9090 Update main.sh 2024-10-02 19:42:42 +02:00
a0fb2c1e61 Update debian/changelog 2024-10-02 19:42:27 +02:00
1b9b5b7791 Swap upgrade to use dist-upgrade instead 2024-10-02 19:41:43 +02:00
39a8dbef28 Update .github/release-canary-v3
All checks were successful
PikaOS Package Build & Release (Canary) (amd64-v3) / build (push) Successful in 27s
2024-08-03 12:19:34 +02:00
4324c37e6b Update main.sh 2024-08-03 12:19:09 +02:00
8f0b5e9274 Update debian/source/format 2024-08-03 12:18:43 +02:00
6985591449 Update .github/release-canary-v3
Some checks failed
PikaOS Package Build & Release (Canary) (amd64-v3) / build (push) Has been cancelled
2024-08-03 12:17:57 +02:00
270ba8431e Update debian/source/format 2024-08-03 12:17:45 +02:00
f7bc43bbb2 Update .github/release-canary-v3
Some checks failed
PikaOS Package Build & Release (Canary) (amd64-v3) / build (push) Failing after 51s
2024-08-03 12:13:55 +02:00
00deaf9acf Update debian/changelog 2024-08-03 12:13:34 +02:00
0d043841d1 Update ubuntu/commands.go 2024-08-03 12:12:56 +02:00
Ward from fusion-voyager-3
00c57adeef port to pika os 4
Some checks failed
PikaOS Package Build Only (Canary) (amd64-v3) / build (push) Successful in 18s
PikaOS Package Build Only (amd64-v3) / build (push) Failing after 1s
PikaOS Package Build & Release (Canary) (amd64-v3) / build (push) Successful in 18s
PikaOS Package Build & Release (amd64-v3) / build (push) Failing after 1s
2024-07-29 01:56:30 +03:00
e426df4f85
Update control 2024-04-11 17:17:02 +01:00
f4f63105e9
Update changelog 2024-04-11 17:16:08 +01:00
59467404d9
Update command_test.go 2024-04-11 17:15:20 +01:00
f3c3c143f0
Update commands.go 2024-04-11 17:08:42 +01:00
Ward Nakchbandi (Cosmic Fusion)
739fce6893
2023-10-06 20:27:48 +03:00
38278216a3
Update release.sh 2023-09-06 22:20:31 +01:00
559fc1c0a1
Update release.yml 2023-09-06 22:20:20 +01:00
e94469c5e4
Update release.sh 2023-08-30 20:45:35 +01:00
2ef0ef6d82
Merge pull request #4 from PikaOS-Linux/auto-init-apx2
add auto init for apx v2
2023-08-22 18:03:18 +01:00
d6ac3c47c6 changelog 2023-08-22 17:59:47 +01:00
1a467b9684 Clean up logic and dedup it around the init 2023-08-22 17:57:19 +01:00
Ward Nakchbandi (Cosmic Fusion)
c8711cf1fa push golang regex with broken if statement 2023-08-22 19:29:58 +03:00
Ward Nakchbandi (Cosmic Fusion)
c1b7279d31 Add some of ferreo requests 2023-08-22 17:35:23 +03:00
189119dc8c
Update release.yml 2023-08-19 16:34:36 +01:00
Ward Nakchbandi (Cosmic Fusion)
6e36f96357 add auto init for apx v2 2023-08-17 19:08:12 +03:00
Ward Nakchbandi (Cosmic Fusion)
6b4a8b1e77 revert accidental push 2023-08-17 19:04:46 +03:00
Ward Nakchbandi (Cosmic Fusion)
879bbd9523 add auto init for apx v2 2023-08-17 18:56:21 +03:00
Ward Nakchbandi (Cosmic Fusion)
0ca6c73408
2023-08-14 16:23:22 +03:00
Ward Nakchbandi (Cosmic Fusion)
30be849b8e
Update changelog 2023-07-13 23:22:05 +03:00
Ward Nakchbandi (Cosmic Fusion)
dfda225a93
Update control 2023-07-13 23:21:54 +03:00
Ward Nakchbandi (Cosmic Fusion)
ca251470f8
fix depends 2023-07-13 23:17:30 +03:00
Ward Nakchbandi (Cosmic Fusion)
482501eb3e
Update Makefile 2023-07-13 22:50:26 +03:00
Ward Nakchbandi (Cosmic Fusion)
f07dbbe7f3
Update control 2023-07-13 22:47:28 +03:00
Ward Nakchbandi (Cosmic Fusion)
66e92a6baa
fix depends 2023-07-13 22:06:52 +03:00
Ward Nakchbandi (Cosmic Fusion)
88acf2f20c
port to apx v2 2023-07-13 22:06:19 +03:00
ae5f48354f
Update release.yml 2023-06-23 14:21:22 +01:00
c7ab6427b8
Update release.yml 2023-06-16 18:38:51 +01:00
2b34848feb
Update main.sh 2023-06-16 18:38:34 +01:00
cf44a51cf3 Fix the dumb 2023-06-05 20:13:53 +01:00
98f41ec031 Major refactor, add updates command with json output flag 2023-06-05 19:37:41 +01:00
Ward Nakchbandi (Cosmic Fusion)
123386c27b
Update changelog 2023-05-24 01:15:52 +03:00
d359209e6f Update to lunar 2023-04-24 19:34:51 +01:00
30 changed files with 686 additions and 304 deletions

1
.github/build-canary-v3 vendored Normal file
View File

@ -0,0 +1 @@
1

1
.github/build-nest-v3 vendored Normal file
View File

@ -0,0 +1 @@
1

1
.github/release-canary-v3 vendored Normal file
View File

@ -0,0 +1 @@
1

1
.github/release-nest-v3 vendored Normal file
View File

@ -0,0 +1 @@
2

40
.github/workflows/build-canaryv3.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: PikaOS Package Build Only (Canary) (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/build-canary-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:canaryv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh

40
.github/workflows/build-nestv3.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: PikaOS Package Build Only (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/build-nest-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:nestv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh

View File

@ -1,28 +0,0 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...

43
.github/workflows/release-canaryv3.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: PikaOS Package Build & Release (Canary) (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/release-canary-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:canaryv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh
- name: Release Package
run: ./release.sh

43
.github/workflows/release-nestv3.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: PikaOS Package Build & Release (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/release-nest-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:nestv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh
- name: Release Package
run: ./release.sh

View File

@ -1,40 +0,0 @@
name: PikaOS Package Release
on:
workflow_dispatch
jobs:
build:
runs-on: self-hosted
container:
image: ubuntu:22.10
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install needed packages
run: apt update && apt install software-properties-common sudo git bc gpg gpg-agent bison build-essential ccache cpio fakeroot flex git kmod libelf-dev libncurses5-dev libssl-dev lz4 qtbase5-dev rsync schedtool wget zstd tar reprepro dpkg-sig devscripts -y
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Build Package
run: ./main.sh
- name: Release Package
run: ./release.sh

View File

@ -3,5 +3,5 @@ all:
install:
mkdir -p $(DESTDIR)/usr/bin/
go build -ldflags="-s -w" -o $(DESTDIR)/usr/bin/pikman
GOAMD=v3 go build -ldflags="-s -w" -o $(DESTDIR)/usr/bin/pikman -buildvcs=false
chmod 755 $(DESTDIR)/usr/bin/pikman

View File

@ -4,7 +4,7 @@
pikman [global options] command [command options] [arguments...]
## VERSION:
v1.23.2.17.0
v1.23.6.5.2
## COMMANDS:
@ -24,6 +24,7 @@ v1.23.2.17.0
- **unexport** - Unexport/Remove a program's desktop entry
- **update** - Update the list of available packages
- **upgrade** - Upgrade the system by installing/upgrading available packages
- **upgrades** - List the available upgrades
- **help, h** - Shows a list of commands or help for one command
## GLOBAL OPTIONS:

View File

@ -2,20 +2,24 @@ package alpine
var PackageManager = "apx"
var ContainerSubsystem = "pikman-alpine"
var ApxSubsystem = "alpine"
var Commands = map[string]string{
"autoremove": "--apk autoremove",
"clean": "--apk clean",
"export": "--apk export",
"init": "--apk init",
"install": "--apk install",
"list": "--apk list",
"log": "--apk log",
"purge": "--apk purge",
"run": "--apk run",
"remove": "--apk remove",
"enter": "--apk enter",
"search": "--apk search",
"show": "--apk show",
"update": "--apk update",
"upgrade": "--apk upgrade",
"autoremove": "pikman-alpine autoremove",
"clean": "pikman-alpine clean",
"export": "pikman-alpine export",
"init": "subsystems new -n pikman-alpine -s alpine",
"install": "pikman-alpine install",
"list": "pikman-alpine list",
"purge": "pikman-alpine purge",
"run": "pikman-alpine run",
"remove": "pikman-alpine remove",
"enter": "pikman-alpine enter",
"search": "pikman-alpine search",
"show": "pikman-alpine show",
"update": "pikman-alpine update",
"upgrade": "pikman-alpine upgrade",
"unexport": "pikman-alpine unexport",
}

View File

@ -2,20 +2,24 @@ package arch
var PackageManager = "apx"
var ContainerSubsystem = "pikman-arch-linux"
var ApxSubsystem = "arch-linux"
var Commands = map[string]string{
"autoremove": "--aur autoremove",
"clean": "--aur clean",
"export": "--aur export",
"init": "--aur init",
"install": "--aur install",
"list": "--aur list",
"log": "--aur log",
"purge": "--aur purge",
"run": "--aur run",
"remove": "--aur remove",
"enter": "--aur enter",
"search": "--aur search",
"show": "--aur show",
"update": "--aur update",
"upgrade": "--aur upgrade",
"autoremove": "pikman-arch-linux autoremove",
"clean": "pikman-arch-linux clean",
"export": "pikman-arch-linux export",
"init": "subsystems new -n pikman-arch-linux -s arch-linux",
"install": "pikman-arch-linux install",
"list": "pikman-arch-linux list",
"purge": "pikman-arch-linux purge",
"run": "pikman-arch-linux run",
"remove": "pikman-arch-linux remove",
"enter": "pikman-arch-linux enter",
"search": "pikman-arch-linux search",
"show": "pikman-arch-linux show",
"update": "pikman-arch-linux update",
"upgrade": "pikman-arch-linux upgrade",
"unexport": "pikman-arch-linux unexport",
}

178
command/command.go Normal file
View File

@ -0,0 +1,178 @@
package command
import (
"encoding/json"
"fmt"
"os"
"os/exec"
"strings"
"pikman/alpine"
"pikman/arch"
"pikman/fedora"
"pikman/flatpak"
"pikman/types"
"pikman/ubuntu"
"pikman/updates"
"github.com/urfave/cli/v2"
)
var commandsMap = map[types.OSType]map[string]string{
types.Ubuntu: ubuntu.Commands,
types.Arch: arch.Commands,
types.Fedora: fedora.Commands,
types.Alpine: alpine.Commands,
types.Flatpak: flatpak.Commands,
}
var packageManagerMap = map[types.OSType]string{
types.Ubuntu: ubuntu.PackageManager,
types.Arch: arch.PackageManager,
types.Fedora: fedora.PackageManager,
types.Alpine: alpine.PackageManager,
types.Flatpak: flatpak.PackageManager,
}
var containerSubsystemMap = map[types.OSType]string{
types.Arch: arch.ContainerSubsystem,
types.Fedora: fedora.ContainerSubsystem,
types.Alpine: alpine.ContainerSubsystem,
}
func (c *Command) ContainerSubsystem() string {
return containerSubsystemMap[c.OsType]
}
var apxSubsystemMap = map[types.OSType]string{
types.Arch: arch.ApxSubsystem,
types.Fedora: fedora.ApxSubsystem,
types.Alpine: alpine.ApxSubsystem,
}
func (c *Command) ApxSubsystem() string {
return apxSubsystemMap[c.OsType]
}
type Command struct {
Command string
OsType types.OSType
ContainerName string
PackageName []string
IsUpgradable bool
IsInstalled bool
IsJSON bool
}
func (c *Command) Process(cCtx *cli.Context) error {
c.Command = cCtx.Command.FullName()
c.PackageName = cCtx.Args().Slice()
return c.processCommand()
}
func (c *Command) processCommand() error {
if (c.OsType == types.Ubuntu || c.OsType == types.Flatpak) && c.Command == "upgrades" {
return c.runUpgrades()
}
var err error
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.Command != "init" {
err = c.initContainer()
if err != nil {
return err
}
}
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.ContainerName != "" {
c.PackageName = append([]string{"--name " + c.ContainerName}, c.PackageName...)
}
if c.OsType == types.Ubuntu && c.IsUpgradable {
c.PackageName = append([]string{"--upgradable"}, c.PackageName...)
}
if c.OsType == types.Ubuntu && c.IsInstalled {
c.PackageName = append([]string{"--installed"}, c.PackageName...)
}
commandToExecute, err := c.getCommand()
if err != nil {
return err
}
cmd := exec.Command("/bin/sh", "-c", commandToExecute)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err = cmd.Run()
if err != nil {
return err
}
return nil
}
func (c *Command) getCommand() (string, error) {
commandMap := commandsMap[c.OsType]
cmd, ok := commandMap[c.Command]
if ok {
return fmt.Sprintf("%s %s %s", packageManagerMap[c.OsType], cmd, strings.Join(c.PackageName, " ")), nil
}
return "", fmt.Errorf("%s: is not a valid command for this distro", c.Command)
}
func (c *Command) runUpgrades() error {
if c.OsType == types.Ubuntu {
return updates.GetUbuntuUpdates(c.IsJSON)
}
return updates.GetFlatpakUpdates(c.IsJSON)
}
func (c *Command) initContainer() error {
contName := c.ContainerName
if contName == "" {
contName = c.ContainerSubsystem()
}
cmd := exec.Command("/bin/bash", "-c", "apx subsystems list -j")
outb, err := cmd.Output()
if err != nil {
return err
}
var out []apxSubs
err = json.Unmarshal(outb, &out)
if err != nil {
return err
}
isMatch := false
for _, sub := range out {
if sub.Name == contName {
isMatch = true
break
}
}
if !isMatch {
fmt.Println("Warning: Subsystem hasn't been pre-initialized, initializing...")
cmd_exec := exec.Command("/bin/bash", "-c", "apx subsystems new -n "+contName+" -s "+c.ApxSubsystem())
cmd_exec.Stdout = os.Stdout
cmd_exec.Stdin = os.Stdin
cmd_exec.Stderr = os.Stderr
if err := cmd_exec.Run(); err != nil {
fmt.Println("Apx Error: ", err)
return err
}
}
return nil
}
type apxSubs struct {
Name string `json:"name"`
}

View File

@ -1,8 +1,9 @@
package loader
package command
import (
"pikman/types"
"testing"
"pikman/types"
)
func Test_getCommand(t *testing.T) {
@ -34,7 +35,7 @@ func Test_getCommand(t *testing.T) {
osType: types.Arch,
packageName: []string{"testPackage"},
},
want: "apx --aur install testPackage",
want: "apx pikman-arch-linux install testPackage",
wantErr: false,
},
{
@ -44,7 +45,7 @@ func Test_getCommand(t *testing.T) {
osType: types.Arch,
packageName: []string{"--name testName", "testPackage"},
},
want: "apx --aur install --name testName testPackage",
want: "apx pikman-arch-linux install --name testName testPackage",
wantErr: false,
},
{
@ -60,7 +61,12 @@ func Test_getCommand(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getCommand(tt.args.command, tt.args.osType, tt.args.packageName)
command := &Command{
Command: tt.args.command,
OsType: tt.args.osType,
PackageName: tt.args.packageName,
}
got, err := command.getCommand()
if (err != nil) != tt.wantErr {
t.Errorf("getCommand() error = %v, wantErr %v", err, tt.wantErr)
return

57
debian/changelog vendored
View File

@ -1,3 +1,60 @@
pikman (1.25.3.0.1-101pika1) pika; urgency=low
* Update to upgrade
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.2.0.1-101pika1) pika; urgency=low
* Nala is gone
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.1.0.1-101pika1) pika; urgency=low
* Update to PikaOS 4
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.1.0.1-100pika1) pikauwu; urgency=low
* Nala is back
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.0.0.3-100pika1) pikauwu; urgency=low
* Update to PikaOS 3
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.0.0.3-99pika2.lunar) lunar; urgency=low
* APX container init if needed
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.24.0.0.3-99pika2.lunar) lunar; urgency=low
* Nala -> apt until nala-rs is out
* Fix bug in upgrades
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.23.6.5.1-99pika2.lunar) lunar; urgency=low
* Add upgrades with --json flag
* Big refactor, code is nicer now
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.23.2.17.1-99pika2.lunar) lunar; urgency=low
* Update.
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.23.2.17.1-99pika2) kinetic; urgency=low
* Update.

5
debian/control vendored
View File

@ -16,4 +16,9 @@ Depends: ${misc:Depends},
flatpak,
nala,
apx,
pika-apx-configs,
vanilla-apx-gui,
Conflicts: apx-subsystem-settings
Provides: apx-subsystem-settings
Replaces: apx-subsystem-settings
Description: One package manager to rule them all

View File

@ -1 +1 @@
3.0 (native)
3.0 (quilt)

View File

@ -1,4 +0,0 @@
Bug-Database: https://github.com/PikaOS-Linux/pikman/issues
Bug-Submit: https://github.com/PikaOS-Linux/pikman/issues/new
Repository: https://github.com/PikaOS-Linux/pikman.git
Repository-Browse: https://github.com/PikaOS-Linux/pikman

2
debian/watch vendored
View File

@ -1,2 +0,0 @@
version=4
https://github.com/PikaOS-Linux/pikman/tags (?:.*?/)?v?@ANY_VERSION@@ARCHIVE_EXT@

View File

@ -2,20 +2,24 @@ package fedora
var PackageManager = "apx"
var ContainerSubsystem = "pikman-fedora-workstation"
var ApxSubsystem = "fedora-workstation"
var Commands = map[string]string{
"autoremove": "--dnf autoremove",
"clean": "--dnf clean",
"export": "--dnf export",
"init": "--dnf init",
"install": "--dnf install",
"list": "--dnf list",
"log": "--dnf log",
"purge": "--dnf purge",
"run": "--dnf run",
"remove": "--dnf remove",
"enter": "--dnf enter",
"search": "--dnf search",
"show": "--dnf show",
"update": "--dnf update",
"upgrade": "--dnf upgrade",
"autoremove": "pikman-fedora-workstation autoremove",
"clean": "pikman-fedora-workstation clean",
"export": "pikman-fedora-workstation export",
"init": "subsystems new -n pikman-fedora-workstation -s fedora-workstation",
"install": "pikman-fedora-workstation install",
"list": "pikman-fedora-workstation list",
"purge": "pikman-fedora-workstation purge",
"run": "pikman-fedora-workstation run",
"remove": "pikman-fedora-workstation remove",
"enter": "pikman-fedora-workstation enter",
"search": "pikman-fedora-workstation search",
"show": "pikman-fedora-workstation show",
"update": "pikman-fedora-workstation update",
"upgrade": "pikman-fedora-workstation upgrade",
"unexport": "pikman-fedora-workstation unexport",
}

View File

@ -1,69 +0,0 @@
package loader
import (
"fmt"
"os"
"os/exec"
"pikman/alpine"
"pikman/arch"
"pikman/fedora"
"pikman/flatpak"
"pikman/types"
"pikman/ubuntu"
"strings"
)
var commandsMap = map[types.OSType]map[string]string{
types.Ubuntu: ubuntu.Commands,
types.Arch: arch.Commands,
types.Fedora: fedora.Commands,
types.Alpine: alpine.Commands,
types.Flatpak: flatpak.Commands,
}
var packageManagerMap = map[types.OSType]string{
types.Ubuntu: ubuntu.PackageManager,
types.Arch: arch.PackageManager,
types.Fedora: fedora.PackageManager,
types.Alpine: alpine.PackageManager,
types.Flatpak: flatpak.PackageManager,
}
func ProcessCommand(command string, osType types.OSType, containerName string, packageName []string, upgradableFlag bool, installedFlag bool) error {
var err error
if osType != types.Ubuntu && osType != types.Flatpak && containerName != "" {
packageName = append([]string{"--name " + containerName}, packageName...)
}
if osType == types.Ubuntu && upgradableFlag {
packageName = append([]string{"--upgradable"}, packageName...)
}
if osType == types.Ubuntu && installedFlag {
packageName = append([]string{"--installed"}, packageName...)
}
commandToExecute, err := getCommand(command, osType, packageName)
cmd := exec.Command("/bin/sh", "-c", commandToExecute)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err = cmd.Run()
if err != nil {
return err
}
return nil
}
func getCommand(command string, osType types.OSType, packageName []string) (string, error) {
commandMap := commandsMap[osType]
cmd, ok := commandMap[command]
if ok {
return fmt.Sprintf("%s %s %s", packageManagerMap[osType], cmd, strings.Join(packageName, " ")), nil
}
return "", fmt.Errorf("%s: is not a valid command for this distro", command)
}

152
main.go
View File

@ -3,22 +3,27 @@ package main
import (
"log"
"os"
"pikman/loader"
"pikman/command"
"pikman/types"
"github.com/urfave/cli/v2"
)
func main() {
if os.Getuid() == 0 {
log.Fatalf("Error: Do not run pikman as root")
}
osType := types.Ubuntu
containerName := ""
upgradableFlag := false
installedFlag := false
cmd := &command.Command{
OsType: types.Ubuntu,
ContainerName: "",
IsUpgradable: false,
IsJSON: false,
IsInstalled: false,
PackageName: make([]string, 0),
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version",
Aliases: []string{"v"},
@ -28,7 +33,7 @@ func main() {
app := &cli.App{
Name: "pikman",
Usage: "One package manager to rule them all",
Version: "v1.23.2.17.0",
Version: "v1.23.6.5.2",
EnableBashCompletion: true,
Flags: []cli.Flag{
&cli.BoolFlag{
@ -37,7 +42,7 @@ func main() {
Usage: "Install Arch packages (including from the AUR)",
Action: func(cCtx *cli.Context, b bool) error {
if b {
osType = types.Arch
cmd.OsType = types.Arch
}
return nil
},
@ -48,7 +53,7 @@ func main() {
Usage: "Install Fedora packages",
Action: func(cCtx *cli.Context, b bool) error {
if b {
osType = types.Fedora
cmd.OsType = types.Fedora
}
return nil
},
@ -59,7 +64,7 @@ func main() {
Usage: "Install Alpine packages",
Action: func(cCtx *cli.Context, b bool) error {
if b {
osType = types.Alpine
cmd.OsType = types.Alpine
}
return nil
},
@ -70,7 +75,7 @@ func main() {
Usage: "Install Flatpak packages",
Action: func(cCtx *cli.Context, b bool) error {
if b {
osType = types.Flatpak
cmd.OsType = types.Flatpak
}
return nil
},
@ -78,53 +83,41 @@ func main() {
&cli.StringFlag{
Name: "name",
Usage: "Name of the managed container",
Destination: &containerName,
Destination: &cmd.ContainerName,
},
},
Commands: []*cli.Command{
{
Name: "autoremove",
Usage: "Remove all unused packages",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "autoremove",
Usage: "Remove all unused packages",
Action: cmd.Process,
},
{
Name: "clean",
Aliases: []string{"cl"},
Usage: "Clean the package manager cache",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Action: cmd.Process,
},
{
Name: "enter",
Usage: "Enter the container instance for select package manager",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "enter",
Usage: "Enter the container instance for select package manager",
Action: cmd.Process,
},
{
Name: "export",
Usage: "Export/Recreate a program's desktop entry from the container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "export",
Usage: "Export/Recreate a program's desktop entry from the container",
Action: cmd.Process,
},
{
Name: "init",
Usage: "Initialize a managed container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "init",
Usage: "Initialize a managed container",
Action: cmd.Process,
},
{
Name: "install",
Aliases: []string{"i"},
Usage: "Install the specified package(s)",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Action: cmd.Process,
},
{
Name: "list",
@ -134,83 +127,74 @@ func main() {
&cli.BoolFlag{
Name: "upgradable",
Usage: "Used by list to check upgradable packages",
Destination: &upgradableFlag,
Destination: &cmd.IsUpgradable,
},
&cli.BoolFlag{
Name: "installed",
Usage: "Used by list to check installed packages",
Destination: &installedFlag,
Destination: &cmd.IsInstalled,
},
},
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), upgradableFlag, installedFlag)
},
Action: cmd.Process,
},
{
Name: "log",
Usage: "Show package manager logs",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "log",
Usage: "Show package manager logs",
Action: cmd.Process,
},
{
Name: "purge",
Usage: "Fully purge a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "purge",
Usage: "Fully purge a package",
Action: cmd.Process,
},
{
Name: "run",
Usage: "Run a command inside a managed container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "run",
Usage: "Run a command inside a managed container",
Action: cmd.Process,
},
{
Name: "remove",
Aliases: []string{"r"},
Usage: "Remove an installed package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Action: cmd.Process,
},
{
Name: "search",
Aliases: []string{"s"},
Usage: "Search for a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Action: cmd.Process,
},
{
Name: "show",
Usage: "Show details for a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "show",
Usage: "Show details for a package",
Action: cmd.Process,
},
{
Name: "unexport",
Usage: "Unexport/Remove a program's desktop entry",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "unexport",
Usage: "Unexport/Remove a program's desktop entry",
Action: cmd.Process,
},
{
Name: "update",
Usage: "Update the list of available packages",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
Name: "update",
Usage: "Update the list of available packages",
Action: cmd.Process,
},
{
Name: "upgrade",
Usage: "Upgrade the system by installing/upgrading available packages",
Action: func(cCtx *cli.Context) error {
cCtx.Args().Tail()
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
Name: "upgrade",
Usage: "Upgrade the system by installing/upgrading available packages",
Action: cmd.Process,
},
{
Name: "upgrades",
Usage: "List the available upgrades",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "json",
Usage: "Output in JSON",
Destination: &cmd.IsJSON,
},
},
Action: cmd.Process,
},
},
}

23
main.sh
View File

@ -1,25 +1,26 @@
DEBIAN_FRONTEND=noninteractive
#! /bin/bash
set -e
VERSION="1.25.3.0.1"
source ./pika-build-config.sh
echo "$PIKA_BUILD_ARCH" > pika-build-arch
# Add dependent repositories
wget -q -O - https://ppa.pika-os.com/key.gpg | sudo apt-key add -
add-apt-repository https://ppa.pika-os.com
add-apt-repository ppa:pikaos/pika
add-apt-repository ppa:kubuntu-ppa/backports
# Clone Upstream
mkdir -p ./pikman
cp -rvf ./* ./pikman || echo
cp -rvf ./* ./pikman || true
cd ./pikman
# Get build deps
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
apt-get build-dep ./ -y
# Build package
dpkg-buildpackage
LOGNAME=root dh_make --createorig -y -l -p pikman_"$VERSION" || echo "dh-make: Ignoring Last Error"
dpkg-buildpackage --no-sign
# Move the debs to output
cd ../
mkdir -p ./output
mv ./*.deb ./output/

10
pika-build-config/amd64-v3.sh Executable file
View File

@ -0,0 +1,10 @@
#! /bin/bash
export PIKA_BUILD_ARCH="amd64-v3"
export DEBIAN_FRONTEND="noninteractive"
export DEB_BUILD_MAINT_OPTIONS="optimize=+lto -march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_CFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_CPPFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_CXXFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_LDFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_BUILD_OPTIONS="nocheck notest terse"
export DPKG_GENSYMBOLS_CHECK_LEVEL=0

5
pika-build-config/i386.sh Executable file
View File

@ -0,0 +1,5 @@
#! /bin/bash
export PIKA_BUILD_ARCH="i386"
export DEBIAN_FRONTEND="noninteractive"
export DEB_BUILD_OPTIONS="nocheck notest terse"
export DPKG_GENSYMBOLS_CHECK_LEVEL=0

View File

@ -1,11 +1,2 @@
# Sign the packages
dpkg-sig --sign builder ./output/*.deb
# Pull down existing ppa repo db files etc
rsync -azP --exclude '*.deb' ferreo@direct.pika-os.com:/srv/www/pikappa/ ./output/repo
# Add the new package to the repo
reprepro -V --basedir ./output/repo/ includedeb kinetic ./output/*.deb
# Push the updated ppa repo to the server
rsync -azP ./output/repo/ ferreo@direct.pika-os.com:/srv/www/pikappa/
# send debs to server
rsync -azP --include './' --include '*.deb' --exclude '*' ./output/ ferreo@direct.pika-os.com:/srv/www/cockatiel-incoming/

View File

@ -1,6 +1,6 @@
package ubuntu
var PackageManager = "sudo -S nala"
var PackageManager = "sudo -S apt"
var Commands = map[string]string{
"autoremove": "autoremove",
@ -12,5 +12,5 @@ var Commands = map[string]string{
"search": "search",
"show": "show",
"update": "update",
"upgrade": "upgrade",
"upgrade": "update && sudo -S apt dist-upgrade",
}

105
updates/updates.go Normal file
View File

@ -0,0 +1,105 @@
package updates
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"os/exec"
"regexp"
"strings"
)
func GetUbuntuUpdates(isJSON bool) error {
cmd := exec.Command("apt", "list", "--upgradable")
out, err := cmd.Output()
if err != nil {
return fmt.Errorf("running apt list: %s", err)
}
re := regexp.MustCompile(`^([^ ]+) ([^ ]+) ([^ ]+)( \[upgradable from: [^\[\]]*\])?`)
scanner := bufio.NewScanner(bytes.NewReader(out))
output := make([]aptPackage, 0)
for scanner.Scan() {
matches := re.FindAllStringSubmatch(scanner.Text(), -1)
if len(matches) == 0 {
continue
}
name := strings.Split(matches[0][1], "/")[0]
if isJSON {
pack := &aptPackage{
Name: name,
Version: matches[0][2],
Architecture: matches[0][3],
}
output = append(output, *pack)
} else {
println(name)
}
}
if isJSON {
jsonout, err := json.Marshal(output)
if err != nil {
return fmt.Errorf("formatting apt list output: %s", err)
}
println(string(jsonout))
}
return nil
}
func GetFlatpakUpdates(isJSON bool) error {
cmd := exec.Command("flatpak", "remote-ls", "--updates")
out, err := cmd.Output()
if err != nil {
return fmt.Errorf("running flatpak list: %s", err)
}
re := regexp.MustCompile(`(?-s)(\S+)`)
scanner := bufio.NewScanner(bytes.NewReader(out))
output := make([]flatPackage, 0)
for scanner.Scan() {
matches := re.FindAllString(scanner.Text(), -1)
if len(matches) == 0 {
continue
}
if isJSON {
pack := &flatPackage{
Name: matches[0],
ApplicationID: matches[1],
Branch: matches[2],
Arch: matches[3],
}
output = append(output, *pack)
} else {
println(matches[0])
}
}
if isJSON {
jsonout, err := json.Marshal(output)
if err != nil {
return fmt.Errorf("formatting apt list output: %s", err)
}
println(string(jsonout))
}
return nil
}
type aptPackage struct {
Name string
Version string
Architecture string
}
type flatPackage struct {
Name string
ApplicationID string
Branch string
Arch string
}