diff --git a/.gitignore b/.gitignore index 65ddc507..fc946e73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin obj valgrind.log +__pycache__ diff --git a/.tito/custom/fixed_submodule_aware_builder.py b/.tito/custom/fixed_submodule_aware_builder.py new file mode 100644 index 00000000..9e5bea46 --- /dev/null +++ b/.tito/custom/fixed_submodule_aware_builder.py @@ -0,0 +1,115 @@ +import os + +from tito.builder import SubmoduleAwareBuilder as BuggySubmoduleAwareBuilder +from tito.common import ( + chdir, + debug, + run_command, + create_tgz, + get_commit_timestamp, +) +from tito.tar import TarFixer + + +class SubmoduleAwareBuilder(BuggySubmoduleAwareBuilder): + def run_git_archive(self, relative_git_dir, prefix, commit, dest_tar, subdir=None): + # command to generate a git-archive + git_archive_cmd = "git archive --format=tar --prefix=%s/ %s:%s --output=%s" % ( + prefix, + commit, + relative_git_dir, + dest_tar, + ) + + if subdir is None: + return run_command(git_archive_cmd) + + with chdir(subdir): + run_command(git_archive_cmd) + + # Run git-archive separately if --debug was specified. + # This allows us to detect failure early. + # On git < 1.7.4-rc0, `git archive ... commit:./` fails! + debug( + "git-archive fails if relative dir is not in git tree", + "%s > /dev/null" % git_archive_cmd, + ) + + def create_tgz(self, git_root, prefix, commit, relative_dir, dest_tgz): + """ + Create a .tar.gz from a projects source in git. + And include submodules + """ + + git_root_abspath = os.path.abspath(git_root) + gitmodules_path = os.path.join(git_root_abspath, ".gitmodules") + + # if .gitmodules does not exist, just call the existing create_tgz function + # as there is nothing to see here. + if not os.path.exists(gitmodules_path): + return create_tgz(git_root, prefix, commit, relative_dir, dest_tgz) + + os.chdir(git_root_abspath) + timestamp = get_commit_timestamp(commit) + + # Accommodate standalone projects with specfile in root of git repo: + relative_git_dir = "%s" % relative_dir + if relative_git_dir in ["/", "./"]: + relative_git_dir = "" + + basename = os.path.splitext(dest_tgz)[0] + initial_tar = "%s.initial" % basename + + # We need to tar up the following: + # 1. the current repo + self.run_git_archive(relative_git_dir, prefix, commit, initial_tar, None) + + # 2. all of the submodules + # then combine those into a single archive. + submodules_cmd = "git submodule--helper list" + submodules_output = run_command(submodules_cmd) + + # split submodules output on newline + # then on tab, and the directory is the last entry + submodules_list = [ + line.split("\t")[-1] for line in submodules_output.split("\n") + ] + + submodule_tar_files = [] + # We ignore the hash in the sub modules list as we'll have to get the correct one + # from the commit id in commit + for submodule in submodules_list: + # to find the submodule shars: + # git rev-parse :./ + rev_parse_cmd = "git rev-parse %s:./%s" % (commit, submodule) + submodule_commit = run_command(rev_parse_cmd) + submodule_tar_file = "%s.%s" % (initial_tar, submodule.replace("/", "_")) + # prefix should be / + submodule_prefix = "%s/%s" % (prefix, submodule) + + self.run_git_archive( + relative_git_dir, + submodule_prefix, + submodule_commit, + submodule_tar_file, + submodule, + ) + submodule_tar_files.append(submodule_tar_file) + + # we need to append all of the submodule tar files onto the initial + # Tar can concatenate only 2 archives at a time + for tar_file in submodule_tar_files: + run_command("tar -Af %s %s" % (initial_tar, tar_file)) + + fixed_tar = "%s.tar" % basename + fixed_tar_fh = open(fixed_tar, "wb") + try: + tarfixer = TarFixer( + open(initial_tar, "rb"), fixed_tar_fh, timestamp, commit + ) + tarfixer.fix() + finally: + fixed_tar_fh.close() + + # It's a pity we can't use Python's gzip, but it doesn't offer an equivalent of -n + return run_command("gzip -n -c < %s > %s" % (fixed_tar, dest_tgz)) diff --git a/.tito/packages/.readme b/.tito/packages/.readme new file mode 100644 index 00000000..b9411e2d --- /dev/null +++ b/.tito/packages/.readme @@ -0,0 +1,3 @@ +the .tito/packages directory contains metadata files +named after their packages. Each file has the latest tagged +version and the project's relative directory. diff --git a/.tito/packages/ly b/.tito/packages/ly new file mode 100644 index 00000000..525e8e9e --- /dev/null +++ b/.tito/packages/ly @@ -0,0 +1 @@ +0.5.3 ./ diff --git a/.tito/tito.props b/.tito/tito.props new file mode 100644 index 00000000..48895626 --- /dev/null +++ b/.tito/tito.props @@ -0,0 +1,7 @@ +[buildconfig] +builder = fixed_submodule_aware_builder.SubmoduleAwareBuilder +tagger = tito.tagger.VersionTagger +changelog_do_not_remove_cherrypick = 0 +changelog_format = %s (%ae) +lib_dir = .tito/custom +tag_format = "v{version}" diff --git a/ly.spec b/ly.spec new file mode 100644 index 00000000..7747ff74 --- /dev/null +++ b/ly.spec @@ -0,0 +1,85 @@ +Name: ly +Version: 0.5.3 +Release: 5%{?dist} +Summary: a TUI display manager + +License: WTFPL +URL: https://github.com/fairyglade/ly.git +Source0: %{name}-%{version}.tar.gz + +BuildRequires: make automake +BuildRequires: gcc gcc-c++ +BuildRequires: kernel-devel pam-devel +BuildRequires: libxcb-devel +BuildRequires: systemd-rpm-macros +BuildRequires: gawk + +Requires(post): policycoreutils-python-utils +Requires(postun): policycoreutils-python-utils +%systemd_requires + +%description +Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD. + +%prep +%autosetup + + +%build +%make_build +mv -f res/config.ini config.ini_orig +awk '{print} +/#save_file/{print "save_file = %{_sharedstatedir}/%{name}/save"} +/#wayland_specifier/{print "wayland_specifier = true"} +' config.ini_orig > res/config.ini + + +%install +%make_install installsystemd +install -m 755 -d %{buildroot}%{_sharedstatedir}/%{name} + +%check + + +%files +%license license.md +%doc readme.md +%config(noreplace) %{_sysconfdir}/ly +%config %{_sysconfdir}/pam.d/* +%{_unitdir}/* +%{_bindir}/* +%{_sharedstatedir}/%{name} + + +%post +%systemd_post %{name}.service +semanage fcontext --add --ftype f --type xdm_exec_t '%{_bindir}/ly' 2>/dev/null || : +semanage fcontext --add --ftype a --type xdm_var_lib_t '%{_sharedstatedir}/%{name}(/.*)?' 2>/dev/null || : +restorecon -R %{_bindir}/ly %{_sharedstatedir}/%{name} || : + +%preun +%systemd_preun %{name}.service + +%postun +if [ $1 -eq 0 ];then +semanage fcontext --delete --ftype f --type xdm_exe_t '%{_bindir}/ly' 2>/dev/null || : +semanage fcontext --delete --ftype a --type xdm_var_lib_t '%{_sharedstatedir}/%{name}(/.*)?' 2>/dev/null || : +fi + +%changelog +* Wed Oct 05 2022 Jerzy Drożdż - 0.5.3-5 +- Added patches from PR #446 + +* Sun Oct 02 2022 Jerzy Drożdż - 0.5.3-4 +- Fixed postun script + +* Fri Sep 30 2022 Jerzy Drożdż - 0.5.3-3 +- Added wayland_specifier = true + +* Fri Sep 30 2022 Jerzy Drożdż - 0.5.3-2 +- Added setting SELinux contexts +- Added configuration option for state files +- Configuration directory and pam service set to \%config + +* Thu Sep 29 2022 Jerzy Drożdż - 0.5.3-1 +- Initial build diff --git a/src/login.c b/src/login.c index 7788d499..80c54a80 100644 --- a/src/login.c +++ b/src/login.c @@ -618,8 +618,11 @@ void auth( char vt[5]; snprintf(vt, 5, "vt%d", config.tty); - // set env + // set env (this clears the environment) env_init(pwd); + // Re-add XDG environment variables from lines 508,509 + env_xdg_session(desktop->display_server[desktop->cur]); + env_xdg(tty_id, desktop->list_simple[desktop->cur]); if (dgn_catch()) {