diff --git a/dist/share/b3view/meshes/penguin-lowpoly-poikilos.b3d b/dist/share/b3view/meshes/penguin-lowpoly-poikilos.b3d index 199c288..d7fff5f 100644 Binary files a/dist/share/b3view/meshes/penguin-lowpoly-poikilos.b3d and b/dist/share/b3view/meshes/penguin-lowpoly-poikilos.b3d differ diff --git a/dist/share/b3view/textures/penguin.png b/dist/share/b3view/textures/penguin.png index 50a1604..658c3dc 100644 Binary files a/dist/share/b3view/textures/penguin.png and b/dist/share/b3view/textures/penguin.png differ diff --git a/install.sh b/install.sh index 0b1feb2..d0d4207 100755 --- a/install.sh +++ b/install.sh @@ -17,7 +17,14 @@ fi # chmod +x install.sh echo echo -if [ -z "$PREFIX" ]; then PREFIX=/usr/local; fi +# if [ -z "$PREFIX" ]; then PREFIX=$HOME/.local; fi +if [ -z "$PREFIX" ]; then + PREFIX=/usr/local + if [ "@$USER" != "@root" ]; then + PREFIX="$HOME/.local" + echo "* The user is not root, so the prefix became \"$PREFIX\". Specify PREFIX in the environment to override automatically setting it." + fi +fi dest_bin_dir="$PREFIX/bin" dest_share_dir="$PREFIX/share" project_unix_name=b3view @@ -29,8 +36,24 @@ icon_name="b3view.png" icon_src_path="$DIST_DIR/icons/$icon_name" shortcut_name="org.poikilos.b3view.desktop" shortcut_src_path="$DIST_DIR/applications/$shortcut_name" -icons_root=$PREFIX/share/pixmaps -applications_path=$PREFIX/share/applications +icons_root=$dest_share_dir/pixmaps +applications_path=$dest_share_dir/applications +my_share_dir="$dest_share_dir/$project_unix_name" + +mkdir -p "$my_share_dir/meshes" +mkdir -p "$my_share_dir/textures" +for resource in b3view/textures/penguin.png b3view/meshes/penguin-lowpoly-poikilos.b3d +do + src="dist/share/$resource" + dst="$dest_share_dir/$resource" + cp "$src" "$dst" + if [ $? -ne 0 ]; then + echo "Error: 'cp \"$src\" \"$dst\"' failed." + exit 1 + else + echo "* installed \"$dst\"" + fi +done mimes_path="$DIST_DIR/share/mime/packages" USER_MIMETYPES_DB_PATH=$HOME/.local/share/mime @@ -127,9 +150,13 @@ fi if [ ! -d "$applications_path" ]; then mkdir -p "$applications_path" + if [ $? -ne 0 ]; then + echo "Error: 'mkdir -p \"$applications_path\"' failed." + exit 1 + fi fi -#if [ "@$PROFILE_ENABLE" = "@true" ]; then +# if [ "@$PROFILE_ENABLE" = "@true" ]; then # always rewrite, since PREFIX may differ echo "Rewriting $applications_path/$shortcut_name..." if [ -f "$shortcut_src_path" ]; then @@ -140,9 +167,9 @@ if [ -f "$shortcut_src_path" ]; then else echo "ERROR: No icon installed since missing '$shortcut_src_path'" fi -#else - #cp -f "$shortcut_src_path" "$applications_path/" -#fi +# else +# cp -f "$shortcut_src_path" "$applications_path/" +# fi if [ -f "$applications_path/$shortcut_name" ]; then echo "Successfully copied '$applications_path/$shortcut_name'" @@ -155,10 +182,10 @@ if [ ! -d "$MIMETYPES_DB_PATH/packages" ]; then mkdir "$MIMETYPES_DB_PATH/packages" fi update_mime_enable=false -#if [ ! -f "$mime_path" ]; then - #echo "ERROR: Stopped installing mime types since missing $mime_path" - #exit 1 -#fi +# if [ ! -f "$mime_path" ]; then +# echo "ERROR: Stopped installing mime types since missing $mime_path" +# exit 1 +# fi install_mime() { mime_name=$1 @@ -168,14 +195,31 @@ install_mime() { exit 1 fi try_dest="$MIMETYPES_DB_PATH/packages/$mime_name" - if diff -q $mime_path $try_dest; then - echo "(You already have an identical $try_dest)" + if [ ! -f "$mime_path" ]; then + echo "* There is no source mime type at \"$mime_path\" yet." + fi + DEST_OP= + if [ ! -f "$try_dest" ]; then + # echo "* There is no destination mime type at \"$try_dest\" yet." + DEST_OP=add else + if diff -q $mime_path $try_dest; then + echo "(You already have an identical $try_dest)" + else + DEST_OP=update + fi + fi + if [ ! -z "$DEST_OP" ]; then cp -f "$mime_path" "$MIMETYPES_DB_PATH/packages/" - if [ -f "$MIMETYPES_DB_PATH/packages/$mime_name" ]; then - echo "Successfully copied '$MIMETYPES_DB_PATH/packages/$mime_name'" - # rm -f "$MIMETYPES_DB_PATH/packages/$mime_name" - update_mime_enable=true + if [ $? -ne 0 ]; then + if [ -f "$MIMETYPES_DB_PATH/packages/$mime_name" ]; then + echo "WARNING: cp failed the existing '$MIMETYPES_DB_PATH/packages/$mime_name' will be used" + # rm -f "$MIMETYPES_DB_PATH/packages/$mime_name" + update_mime_enable=true + else + echo "Error: 'cp -f \"$mime_path\" \"$MIMETYPES_DB_PATH/packages/\"' failed." + exit 1 + fi fi fi } @@ -193,27 +237,32 @@ install_mime model-irrmesh.xml # file as "plain text file" if the xml file below is installed) mime_name=model-obj.xml mime_path="$mimes_path/$mime_name" -#if [ ! -f "$mime_path" ]; then - #echo "ERROR: Stopped installing mime types since missing $mime_path" - #exit 1 -#fi +# if [ ! -f "$mime_path" ]; then +# echo "ERROR: Stopped installing mime types since missing $mime_path" +# exit 1 +# fi try_dest="$MIMETYPES_DB_PATH/packages/$mime_name" -#if diff -q $mime_path $try_dest; then - #echo "* (You already have an identical $try_dest)" -#else - #cp -f "$mime_path" "$MIMETYPES_DB_PATH/packages/" +# if diff -q $mime_path $try_dest; then +# echo "* (You already have an identical $try_dest)" +# else + # cp -f "$mime_path" "$MIMETYPES_DB_PATH/packages/" if [ -f "$MIMETYPES_DB_PATH/packages/$mime_name" ]; then - # echo "* Successfully copied '$MIMETYPES_DB_PATH/packages/$mime_name'" - echo "* Removing '$MIMETYPES_DB_PATH/packages/$mime_name' (overlaps with system usually)" - rm -f "$MIMETYPES_DB_PATH/packages/$mime_name" - update_mime_enable=true + # echo "* Successfully copied '$MIMETYPES_DB_PATH/packages/$mime_name'" + echo "* Removing '$MIMETYPES_DB_PATH/packages/$mime_name' (overlaps with system usually)" + rm -f "$MIMETYPES_DB_PATH/packages/$mime_name" + update_mime_enable=true fi -#fi +# fi if [ "@$update_mime_enable" = "@true" ]; then echo "Updating mime type database '$MIMETYPES_DB_PATH'..." update-mime-database "$MIMETYPES_DB_PATH" # must contain packages + if [ $? -ne 0 ]; then + echo "Error: 'update-mime-database \"$MIMETYPES_DB_PATH\"' failed." + exit 1 + fi + fi echo "Done." diff --git a/projects/textures/penguin.png b/projects/textures/penguin.png deleted file mode 100644 index 50a1604..0000000 Binary files a/projects/textures/penguin.png and /dev/null differ diff --git a/projects/textures/penguin.xcf b/projects/textures/penguin.xcf index 97a3441..a256d04 100644 Binary files a/projects/textures/penguin.xcf and b/projects/textures/penguin.xcf differ diff --git a/update-dist.sh b/update-dist.sh index 1dddc0e..92dbc0a 100755 --- a/update-dist.sh +++ b/update-dist.sh @@ -1,12 +1,27 @@ #!/bin/sh -src=projects/textures/penguin.png -dst=../../dist/share/b3view/textures/penguin.png -if [ ! -f "$src" ]; then - echo "* There is nothing to do because there is no \"$src\". See the xcf file there instead. To use this script, export it to png where there is no png then run this script." - exit 0 -fi -if [ ! -f "$dst" ]; then - echo "Error: There is no \"$dst\" to update, so for safety nothing will be done." - exit 1 -fi -cp "$src" "$dst" + +update_file(){ + src="$1" + dst="$2" + op="cp" + if [ ! -z "$3" ]; then + op=mv + fi + if [ ! -f "$src" ]; then + echo "* There is nothing to do because there is no \"$src\". See the project file there instead. To use this script, export it to png where there is no png then run this script." + return 0 + fi + if [ ! -f "$dst" ]; then + echo "Error: There is no \"$dst\" to update, so for safety nothing will be done." + return 1 + fi + $op "$src" "$dst" + if [ $? -eq 0 ]; then + echo "* updated \"$dst\"" + else + echo "Error: '$op \"$src\" \"$dst\"' failed." + fi +} + +update_file projects/textures/penguin.png dist/share/b3view/textures/penguin.png +update_file projects/meshes/penguin-lowpoly-poikilos.b3d dist/share/b3view/meshes/penguin-lowpoly-poikilos.b3d mv