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

Commands in post_install.cmake don't work #3

Open
LordOfTheRats opened this issue Nov 18, 2020 · 0 comments
Open

Commands in post_install.cmake don't work #3

LordOfTheRats opened this issue Nov 18, 2020 · 0 comments

Comments

@LordOfTheRats
Copy link

Creation of example CA fails, because DESTDIR is undefined in post_install.cmake.

Install the project...                                                                                                                                                                                                                         
-- Install configuration: ""                                                                                                                                                                                                                   
-- Installing: /home/rvoegeli/tmp/secureboard/libsecureboard/.build/libsecureboard/share/libsecureboard/ca/client-root-ca.pem                                                                                                                  
-- Installing: /home/rvoegeli/tmp/secureboard/libsecureboard/.build/libsecureboard/share/libsecureboard/ca/bob.pem                                                                                                                             
-- Installing: /home/rvoegeli/tmp/secureboard/libsecureboard/.build/libsecureboard/share/libsecureboard/ca/alice.pem                                                                                                                           
-- Installing: /home/rvoegeli/tmp/secureboard/libsecureboard/.build/libsecureboard/share/libsecureboard/priv-keys/bob-key.pem                                                                                                                  
-- Installing: /home/rvoegeli/tmp/secureboard/libsecureboard/.build/libsecureboard/share/libsecureboard/priv-keys/alice-key.pem                                                                                                                
running mkdir -p /share/libsecureboard/example-user-device-ca  2>&1                                                                                                                                                                            
mkdir: das Verzeichnis »/share“ kann nicht angelegt werden: Keine Berechtigung                                                                                                                                                                 
running /home/rvoegeli/tmp/secureboard/libsecureboard/.build/../script/mk_cert.sh -g -v -r /share/libsecureboard/example-user-device-ca/example-root-ca -d /share/libsecureboard/example-user-device-ca/example-dev-01 -c device-01  2>&1      
Generating an EC private key                                                                                                                                                                                                                   
writing new private key to '/share/libsecureboard/example-user-device-ca/example-root-ca-key.pem'                                                                                                                                              
req: Can't open "/share/libsecureboard/example-user-device-ca/example-root-ca-key.pem" for writing, No such file or directory                                                                                                                  
running /home/rvoegeli/tmp/secureboard/libsecureboard/.build/../script/mk_cert.sh -v -r /share/libsecureboard/example-user-device-ca/example-root-ca -d /share/libsecureboard/example-user-device-ca/example-dev-02 -c device-02  2>&1         
Generating an EC private key                                                                                                                                                                                                                   
writing new private key to '/share/libsecureboard/example-user-device-ca/example-dev-02-key.pem'                                                                                                                                               
req: Can't open "/share/libsecureboard/example-user-device-ca/example-dev-02-key.pem" for writing, No such file or directory                                                                                                                   
running /home/rvoegeli/tmp/secureboard/libsecureboard/.build/../script/mk_cert.sh -v -r /share/libsecureboard/example-user-device-ca/example-root-ca -d /share/libsecureboard/example-user-device-ca/example-dev-03 -c device-03  2>&1         
Generating an EC private key                                                                                                                                                                                                                   
writing new private key to '/share/libsecureboard/example-user-device-ca/example-dev-03-key.pem'                                                                                                                                               
req: Can't open "/share/libsecureboard/example-user-device-ca/example-dev-03-key.pem" for writing, No such file or directory                                                                                                                   
running ln -fs /share/libsecureboard/example-user-device-ca/example-root-ca.pem /share/libsecureboard/ca  2>&1
ln: Die symbolische Verknüpfung '/share/libsecureboard/ca' konnte nicht angelegt werden: Datei oder Verzeichnis nicht gefunden
rehash CA

DESTDIR is never defined in CMakeLists.txt and the install(SCRIPT ...) command does not forward variables anyway.

DESTDIR can be defined in release.sh as parameter to cmake. There is also a little trick to get the variable into the post_install.cmake script.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d856293..a96a93b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,8 @@ install(FILES ca/client-cert/bob.pem DESTINATION share/libsecureboard/ca)
 install(FILES ca/client-cert/alice.pem DESTINATION share/libsecureboard/ca)
 install(FILES ca/client-cert/keys/bob-key.pem DESTINATION share/libsecureboard/priv-keys)
 install(FILES ca/client-cert/keys/alice-key.pem DESTINATION share/libsecureboard/priv-keys)
+
+install(CODE "set(DESTDIR \"${DESTDIR}\")")
 install(SCRIPT "post_install.cmake")

 add_subdirectory(src)
diff --git a/release.sh b/release.sh
index 15390ee..43eb6ce 100755
--- a/release.sh
+++ b/release.sh
@@ -31,7 +31,7 @@ if [ $BUILDDOC == 1 ]; then
     $DIR/builddoc.sh -o $OUTPUT_DIRECTORY/doc
 fi
 mkdir -p $OUTPUT_DIRECTORY
-cd $OUTPUT_DIRECTORY && cmake $DIR -DCMAKE_INSTALL_PREFIX=
+cd $OUTPUT_DIRECTORY && cmake $DIR -DCMAKE_INSTALL_PREFIX= -DDESTDIR=$OUTPUT_DIRECTORY/libsecureboard
 make -k -C $OUTPUT_DIRECTORY
 make -C $OUTPUT_DIRECTORY DESTDIR=$OUTPUT_DIRECTORY/libsecureboard install
 cd $OUTPUT_DIRECTORY && tar --transform "s/^libsecureboard/libsecureboard-$VERSION/" -czvf libsecureboard-$VERSION$HASH.tar.gz libsecureboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant