Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional buildscripts #370

Merged
merged 18 commits into from Jan 14, 2024
Merged

Add optional buildscripts #370

merged 18 commits into from Jan 14, 2024

Conversation

ghost
Copy link

@ghost ghost commented Jan 5, 2024

Implements #367

@ghost
Copy link
Author

ghost commented Jan 5, 2024

NOTE : THIS IS STILL UNFINISHED

EDIT : THIS IS NOW MOSTLY FINISHED

EDIT2 : THIS IS NOW 99.9% FINISHED

It works perfectly fine when run using chmod +x make-pkgs.sh && ./make-pkgs.sh --ibus --fedora --develop --toolbox
But there are still alot of unfixed issues and edgecases
EDIT : MOST HAVE BEEN IRONED OUT

Notably :

  • missing debian buildscript
  • bugs out with error fatal: destination path 'OpenBangla-Keyboard' already exists and is not an empty directory. on subsequent runs.

@ghost
Copy link
Author

ghost commented Jan 5, 2024

* bugs out with error `fatal: destination path 'OpenBangla-Keyboard' already exists and is not an empty directory.` on subsequent runs.

On that note, the fatal error occurs somewhere near line 11 of make-fedora.sh on subsequent runs
I can't seem to find why it occurs, as the check should result in either entering the directory and doing a git pull or git cloning OBK if the directory doesnt exist, if anyone can help it would be appreciated.

EDIT : I think it has something to do with the git pull command expecting an empty directory or something similar, I am not experienced in dealing with git, so I can't fix the error in this case

EDIT2 : Fixed the bug, it now works fine

@mominul
Copy link
Member

mominul commented Jan 6, 2024

@ahmubashshir can you take a look?

@larina3315 Have you checked the scripts with shellcheck?

@ghost
Copy link
Author

ghost commented Jan 6, 2024

@ahmubashshir can you take a look?

@larina3315 Have you checked the scripts with shellcheck?

Just checked, some suggestions showed up, I will update my scripts accordingly.
I wanted to make a prototype/PoC ASAP, there are some things that can be improved, I will continue working on them

@ghost
Copy link
Author

ghost commented Jan 6, 2024

Script is finished

  • Added documentation for most variables and what they do
  • Added documentation on how to add support for other distros
  • ensured there are no more shellcheck errors/recommendations remaining
  • Confirmed script works as described in the docs with proper behaviour by running
    chmod +x make-pkgs.sh && ./make-pkgs.sh --ibus --fcitx --debian 11 --fedora 37 --toolbox --develop
    chmod +x make-pkgs.sh && ./make-pkgs.sh --ibus --fcitx --debian 11 --fedora 37 --develop
    chmod +x make-pkgs.sh && ./make-pkgs.sh --clean
    chmod +x make-pkgs.sh && ./make-pkgs.sh --help
    chmod +x make-pkgs.sh && ./make-pkgs.sh --hello

@ahmubashshir
Copy link
Contributor

@larina3315 try amending the commits with meaningful messages.

https://www.conventionalcommits.org/en/v1.0.0/
https://github.com/joelparkerhenderson/git-commit-message/

larina3315 and others added 6 commits January 7, 2024 23:19
Initial commit of the script.
Refactor and Revise the script
Add Debian support
Misc. revisions to Fedora script for toolbox
--help switch for accessing help information
--clean switch for cleaning toolbox containers and ~/.obk-build/
Last commit before major changes
Add comments explaining what different variables do, how to add support for new distros.
Some misc revisions.
directory, besides the shell scripts
@ghost
Copy link
Author

ghost commented Jan 7, 2024

@larina3315 try amending the commits with meaningful messages.

https://www.conventionalcommits.org/en/v1.0.0/ https://github.com/joelparkerhenderson/git-commit-message/

I am extremely sorry, I am still inexperienced in working with git.
I have tried my best to squash related commits and give them better commit messages.
I would like to edit the commit messages of some more commits, but so far neither Github nor Github Desktop seems to have the option to edit the commit message of a commit that was already pushed.

As for reviewing the PR, I would suggest focusing on/after Some cleanup and restructuring
As it was a hefty restructure and reorganization of the entire thing, with the scripts being moved into their own folder

@mominul
Copy link
Member

mominul commented Jan 7, 2024

@larina3315 Okay the commits are good enough and I can squash them when merging this PR.

As you intend it to be a user-facing tool, there should be documentation about it. Can you add basic information about how should a user run it in the Readme.md file?

@ghost
Copy link
Author

ghost commented Jan 7, 2024

Can you add basic information about how should a user run it in the Readme.md file?

yes, I will add a readme.md file for it asap.

larina3315 added 2 commits January 8, 2024 02:18
Create a readme for the tool
Copy link
Contributor

@ahmubashshir ahmubashshir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work btw 👍🏽 I'll try to add other distro and architecture support on this...

tools/make-pkgs/make-build.sh Outdated Show resolved Hide resolved
Comment on lines 38 to 55
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --ibus Compile IBus version"
echo " --fcitx Compile Fcitx version (Doesn't work for OBK2 and earlier)"
echo " --develop Compile from the develop branch"
echo " --fedora Compile for Fedora"
echo " --debian Compile for Debian"
echo " --toolbox Compile inside of a toolbox"
echo " --clean Clean \"$FILE_DIR_OBK\" directory and remove obk-toolbox-* containers"
echo " --help Display this help message"
echo " "
echo " -> NOTE: User needs to specify the --toolbox flag to compile for multiple distros at the same time."
echo " Otherwise, only one flag can be used at a time (e.g. --fedora and --debian can't be used together without --toolbox)"
echo " -> NOTE: When compiling inside of a toolbox, an additional <version> can be specified for the distro flags."
echo " (e.g. --fedora 37) This will generate packages for a specific version of a distro."
echo "Example: "
echo " $0 --ibus --fcitx --develop --fedora 37 --debian --toolbox"
echo " $0 --ibus --develop --debian"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using multiple echos, try using

cat <<EOF
...
EOF

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless absolutely mandatory, I would personally like to avoid the change, as using the echos make the script more readable and understandable compared to using cat <<EOF

For example, If you are on Debian and you want to generate `.rpm`s specifically for Fedora 37, you can do so.

## How to use
Copy this folder, make the make-pkgs.sh script executable by doing `chmod +x make-pkgs.sh`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larina3315 why do we need to copy this folder?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was writing this from the POV that if a user clones the OBK git repo with this tool in it, then the make-pkgs.sh file will reside in ./OpenBangla-Keyboard/tools/make-pkgs/ , so the user might want to copy the folder to some other conveinent location and run it from there.

It could be worded in a better way as a suggestion.

larina3315 and others added 2 commits January 12, 2024 12:49
Add toolbox-related changes.
Cleaned up the markdown.
Restructured Howto and Examples sections.
Add bash brackets
Fixed behaviour of --clean flag
@ghost
Copy link
Author

ghost commented Jan 12, 2024

I would like to ask for suggestion on whether stdout/stderr output of things like toolbox/dnf/apt etc should be

  • suppressed
  • silently logged to a file
  • be shown to the user (current behaviour)
  • be shown ONLY on faliure

@ahmubashshir
Copy link
Contributor

Let's keep current behavior as default and put others behind optiol… like --log-output=<file|always(default)|hide|on-error>

@ghost
Copy link
Author

ghost commented Jan 12, 2024

Let's keep current behavior as default and put others behind optiol… like --log-output=<file|always(default)|hide|on-error>

The user would be bombarded with random things happening on screen, as long as things are going fine why bother the user ?
I was thinking about making show on error the default

Although adding logging options can surely be done

@mominul
Copy link
Member

mominul commented Jan 12, 2024

I would like to ask for suggestion on whether stdout/stderr output of things like toolbox/dnf/apt etc should be

* suppressed

* silently logged to a file

* be shown to the user (current behaviour)

* be shown ONLY on faliure

verbose output should be behind a -v flag. But we can inform the user about the successes of the stages by outputting like Finished setting up dependencies, Successfully built package...etc.

@ghost
Copy link
Author

ghost commented Jan 12, 2024

I would like to ask for suggestion on whether stdout/stderr output of things like toolbox/dnf/apt etc should be

* suppressed

* silently logged to a file

* be shown to the user (current behaviour)

* be shown ONLY on faliure

verbose output should be behind a -v flag. But we can inform the user about the successes of the stages by outputting like Finished setting up dependencies, Successfully built package...etc.

I am currently looking into ways to introduce logging to bash scripts, although this change will take time as I will have to take a temporary hiatus due to academic reasons soon.

EDIT : Using set -x will log every command the shell tries to run

larina3315 added 2 commits January 13, 2024 03:27
move initial functions and vars into function.bash
-v must be first arg
./make-pkgs.sh -v --xyz
WARNING : CURRENTLY BROKEN
-v flag works correctly
@ghost
Copy link
Author

ghost commented Jan 12, 2024

There can be some more QoL enchancements, code cleanups and documentation effort, but I feel like make-pkgs has reached it's intended state, adding more features will take it out of it's original scope of being an enduser focused tool

distrobox/docker support can also be easily added should anyone want to do such a thing, toolbox is a wrapper around podman so it already has podman support

@ghost
Copy link
Author

ghost commented Jan 13, 2024

Due to limitations of bash, I sadly cannot suppress log output for toolbox/dnf/cpack/git etc
But the -v flag, when used as the first argument, will print and log every single line bash executes alongside stdout and stderr, this way if something does fail, we can just ask users to upload the *.log files

This is the best that could be done given the current circumstances, I had to put ALOT of ugly hacks to make it work.
Ideally, I would've just written a rust program but the point of this is to be as portable as possible ("one-click") without platform/distro-specific issues, thus I had to use bash.

@mominul
Copy link
Member

mominul commented Jan 13, 2024

@larina3315 I appreciate your effort on this, thanks! ❤️

@ahmubashshir Do you have any review comments to add? Otherwise, I'd like to merge it.

@ghost
Copy link
Author

ghost commented Jan 13, 2024

@larina3315 I appreciate your effort on this, thanks! ❤️

@ahmubashshir Do you have any review comments to add? Otherwise, I'd like to merge it.

I have to write some misc. documentation regarding adding distro support and variables, some slight behaviour has changed which need to be mentioned in the readme

EDIT : I have finished doing appropriate changes

@ahmubashshir
Copy link
Contributor

ahmubashshir commented Jan 14, 2024 via email

Copy link
Member

@mominul mominul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mominul mominul merged commit 7989cc0 into OpenBangla:master Jan 14, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants