summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in3
-rw-r--r--src/oh-fixperms.sh82
2 files changed, 84 insertions, 1 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 74063c2..e3f742a 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -41,7 +41,8 @@ sed_script = s&@@PACKAGE_NAME@@&$(package_name)&;\
SRCS = \
oh-installfiles.sh \
- oh-strip.sh
+ oh-strip.sh \
+ oh-fixperms.sh
OBJS = $(SRCS:.sh=)
distdir = ../$(package_name)-$(package_version)/src
diff --git a/src/oh-fixperms.sh b/src/oh-fixperms.sh
new file mode 100644
index 0000000..d7779aa
--- /dev/null
+++ b/src/oh-fixperms.sh
@@ -0,0 +1,82 @@
+#!@@SH@@
+#
+# opkhelper
+# src/oh-fixperms
+# Fix permissions and ownerships of data files.
+#
+# Copyright (C) 2012 Patrick "P. J." McDermott
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. '@@LIBOPKBUILD_1@@/load.sm'
+
+ob_use locale
+ob_use output
+
+main()
+{
+ dir='dest'
+
+ ob_set_locale_path '@@LOCALEDIR@@/%s/LC_MESSAGES/%s.ms'
+ ob_set_text_domain 'opkhelper'
+
+ while getopts 'd:' opt; do
+ case "${opt}" in
+ d)
+ dir="${OPTARG}"
+ ;;
+ ?)
+ ob_error "$(ob_get_msg 'bad_opt')"
+ exit 1
+ ;;
+ esac
+ done
+
+ # Ensure that everything is owned by UID 0 and GID 0.
+ ob_info "$(ob_get_msg 'chown')"
+ find "${dir}" \
+ -exec 'chown' '-h' '0:0' '{}' ';'
+
+ # Ensure that shared libraries, static libraries, and libtool archives have
+ # a rw-r--r-- mode.
+ ob_info "$(ob_get_msg 'chmod_lib')"
+ find "${dir}" -type f -a ! -perm 644 \
+ -a \( -name '*.so*' -o -name '*.a' -o -name '*.la' \) \
+ -exec 'chmod' '644' '{}' ';'
+
+ # Ensure that header files have a rw-r--r-- mode.
+ if [ -d "${dir}/usr/include" ]; then
+ ob_info "$(ob_get_msg 'chmod_include')"
+ find "${dir}/usr/include" -type f -a ! -perm 644 \
+ -exec 'chmod' '644' '{}' ';'
+ fi
+
+ # Ensure that manual pages have a rw-r--r-- mode.
+ if [ -d "${dir}/usr/share/man" ]; then
+ ob_info "$(ob_get_msg 'chmod_man')"
+ find "${dir}/usr/share/man" -type f -a ! -perm 644 \
+ -exec 'chmod' '644' '{}' ';'
+ fi
+
+ # Ensure that binary programs and service scripts have a rwxr-xr-x mode.
+ for bindir in /usr/sbin /usr/bin /sbin /bin /usr/games /etc/init.d; do
+ if [ -d "${dir}/${bindir}" ]; then
+ ob_info "$(ob_get_msg 'chmod_bin')" "${bindir}"
+ find "${dir}/${bindir}" -type f -a ! -perm 755 \
+ -exec 'chmod' '755' '{}' ';'
+ fi
+ done
+}
+
+main "${@}"