src/scripts/check-interpreters \
src/scripts/check-libraries \
src/scripts/check-rpaths \
- src/scripts/check-symlinks \
src/scripts/check-unsafe-files \
src/scripts/compress-man-pages \
src/scripts/find-prerequires \
"Removing libtool archives...", __pakfire_build_remove_libtool_archives);
}
+static int __pakfire_build_check_broken_symlinks(
+ struct pakfire* pakfire, struct pakfire_file* file, void* data) {
+ struct pakfire_filelist* broken = (struct pakfire_filelist*)data;
+ int r;
+
+ // Ignore anything that isn't a symlink
+ switch (pakfire_file_get_type(file)) {
+ case S_IFLNK:
+ if (!pakfire_file_symlink_target_exists(file)) {
+ r = pakfire_filelist_add(broken, file);
+ if (r)
+ return r;
+ }
+
+ break;
+
+ // Ignore anything that isn't a symlink
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int pakfire_build_post_check_broken_symlinks(
+ struct pakfire_build* build, struct pakfire_filelist* filelist) {
+ struct pakfire_filelist* broken = NULL;
+ int r;
+
+ // Create a new filelist
+ r = pakfire_filelist_create(&broken, build->pakfire);
+ if (r)
+ goto ERROR;
+
+ // Find any broken symlinks
+ r = pakfire_filelist_walk(filelist, __pakfire_build_check_broken_symlinks, broken);
+ if (r)
+ goto ERROR;
+
+ if (!pakfire_filelist_is_empty(broken)) {
+ INFO(build->pakfire, "Broken symlinks have been found:\n");
+
+ // Show all files
+ pakfire_filelist_dump(broken, 0);
+
+ // Check failed
+ r = 1;
+ }
+
+ERROR:
+ if (broken)
+ pakfire_filelist_unref(broken);
+
+ return r;
+}
+
static int pakfire_build_run_post_build_checks(struct pakfire_build* build) {
struct pakfire_filelist* filelist = NULL;
int r;
if (r)
goto ERROR;
+ // Check for any broken symlinks
+ r = pakfire_build_post_check_broken_symlinks(build, filelist);
+ if (r)
+ goto ERROR;
+
ERROR:
if (filelist)
pakfire_filelist_unref(filelist);
}
static const char* post_build_scripts[] = {
- "check-symlinks",
"check-unsafe-files",
"check-libraries",
"check-rpaths",
return r;
}
+int pakfire_file_symlink_target_exists(struct pakfire_file* file) {
+ // Fail if this got called for anything that isn't a symlink
+ if (!S_ISLNK(file->st.st_mode)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return pakfire_path_exists(file->abspath);
+}
+
/*
Classification
*/
int pakfire_file_remove(struct pakfire_file* file);
int pakfire_file_cleanup(struct pakfire_file* file);
+int pakfire_file_symlink_target_exists(struct pakfire_file* file);
+
int pakfire_file_classify(struct pakfire_file* file);
int pakfire_file_matches_class(struct pakfire_file* file, const int class);
+++ /dev/null
-#!/bin/bash
-###############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2021 Pakfire development team #
-# #
-# 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/>. #
-# #
-###############################################################################
-
-error() {
- echo "$@" >&2
-}
-
-main() {
- local buildroot="${1}"
- shift
-
- # Check if BUILDROOT exists
- if [ ! -d "${buildroot}" ]; then
- error "BUILDROOT does not exist"
- return 1
- fi
-
- local broken_links=()
-
- local file
- for file in $(find "${buildroot}" -type l); do
- if [ ! -e "${file}" ]; then
- broken_links+=( "${file}" )
- fi
- done
-
- if [ "${#broken_links[@]}" -gt 0 ]; then
- error "The following broken symlinks have been found:"
-
- local link
- for link in ${broken_links[@]}; do
- error " ${link/${buildroot}/} -> $(readlink "${link}")"
- done
-
- return 1
- fi
-
- return 0
-}
-
-main "$@" || exit $?