return 0;
}
+static int pakfire_usrmove_symlink(struct pakfire* pakfire,
+ const char* src, const char* dst) {
+ char link[PATH_MAX];
+ char path[PATH_MAX];
+ int r;
+
+ // Compose the link path
+ r = pakfire_path(pakfire, link, "%s", src);
+ if (r)
+ return r;
+
+ // Exit if the link exists
+ if (pakfire_path_exists(link))
+ return 0;
+
+ // Compose the destination path
+ r = pakfire_path(pakfire, path, "%s", dst);
+ if (r)
+ return r;
+
+ // Make sure the destination exists
+ r = pakfire_mkdir(path, 755);
+ if (r)
+ return r;
+
+ // Create the symlink
+ r = symlink(dst, link);
+ if (r) {
+ DEBUG(pakfire, "Could not create symlink %s to %s: %m\n", dst, link);
+ return r;
+ }
+
+ DEBUG(pakfire, "Created symlink %s --> %s\n", link, dst);
+
+ return 0;
+}
+
+/*
+ This is an ugly helper function that helps us to make sure
+ that /bin, /sbin, /lib and /lib64 are symlinks to their
+ corresponding path in /usr.
+*/
+static int pakfire_usrmove(struct pakfire* pakfire) {
+ int r;
+
+ r = pakfire_usrmove_symlink(pakfire, "/bin", "usr/bin");
+ if (r)
+ return r;
+
+ r = pakfire_usrmove_symlink(pakfire, "/sbin", "usr/sbin");
+ if (r)
+ return r;
+
+ r = pakfire_usrmove_symlink(pakfire, "/lib", "usr/lib");
+ if (r)
+ return r;
+
+ r = pakfire_usrmove_symlink(pakfire, "/lib64", "usr/lib64");
+ if (r)
+ return r;
+
+ return r;
+}
+
static int pakfire_transaction_perform(struct pakfire_transaction* transaction) {
struct pakfire_repo* repo = NULL;
struct pakfire_db* db;
if (r)
goto ERROR;
+ // Make sure /usr-move is working
+ r = pakfire_usrmove(transaction->pakfire);
+ if (r)
+ goto ERROR;
+
// Execute all pre transaction actions
r = pakfire_transaction_run_steps(transaction, db, PAKFIRE_ACTION_PRETRANS);
if (r)