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

ostree: move admindir to /etc/alternatives.admindir #134

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions alternatives.8
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ A directory, by default
containing
.BR alternatives '
state information.
/etc/.alternatives.state on OSTree-based systems.
.TP
link group
A set of related symlinks, intended to be updated as a group.
Expand Down Expand Up @@ -416,6 +417,7 @@ option.
.TP
.I /var/lib/alternatives/
The default administration directory.
/etc/.alternatives.admindir on OSTree-based systems.
Can be overridden by the
.B --admindir
option.
Expand Down
30 changes: 30 additions & 0 deletions alternatives.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,32 @@ static int listServices(const char *altDir, const char *stateDir, int flags) {
return 0;
}

int dirExists(const char *path) {
struct stat stats;
stat(path, &stats);

if (S_ISDIR(stats.st_mode))
return 1;

return 0;
}

int canUseAlternativeAdminDir() {
if (dirExists("/var/lib/alternatives")) {
return 0;
}

if (fileExists("/run/ostree-booted")) {
return 1;
}

if (isLink("/ostree")) {
return 1;
}

return 0;
}

int main(int argc, const char **argv) {
const char **nextArg;
char *end;
Expand All @@ -1304,6 +1330,10 @@ int main(int argc, const char **argv) {
struct stat sb;
struct linkSet newSet = {NULL, NULL, NULL};

if (canUseAlternativeAdminDir()) {
stateDir = "/etc/alternatives.admindir";
}

setlocale(LC_ALL, "");
bindtextdomain("chkconfig", "/usr/share/locale");
textdomain("chkconfig");
Expand Down
5 changes: 2 additions & 3 deletions chkconfig.spec
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/chkconfig.d
%{_sysconfdir}/chkconfig.d
%{_sysconfdir}/init.d
%{_sysconfdir}/rc.d
%{_sysconfdir}/rc.d/init.d
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this. If you also need some changes in chkconfig packaging, please create a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Builds won't pass otherwise. OK to break it out into a separate commit?

Copy link
Member

Choose a reason for hiding this comment

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

We should figure out what is wrong here, /etc/rc.d/init.d/ is the proper dir for initscripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already %dir /etc/rc.d so it complains about init.d being listed redundantly

%{_sysconfdir}/rc[0-6].d
%{_sysconfdir}/rc.d/rc[0-6].d
%{_mandir}/*/chkconfig*
%{_prefix}/lib/systemd/systemd-sysv-install

Expand All @@ -95,11 +93,12 @@ mkdir -p $RPM_BUILD_ROOT/etc/chkconfig.d
%files -n alternatives
%license COPYING
%dir /etc/alternatives
%dir /etc/alternatives.admindir
%ghost /var/lib/alternatives
vrothberg marked this conversation as resolved.
Show resolved Hide resolved
%{_sbindir}/update-alternatives
%{_sbindir}/alternatives
%{_mandir}/*/update-alternatives*
%{_mandir}/*/alternatives*
%dir /var/lib/alternatives
vrothberg marked this conversation as resolved.
Show resolved Hide resolved

%changelog
* Fri Jun 21 2024 Jan Macku <[email protected]> - 1.28-1
Expand Down
Loading