Change creation time of files (RPM) from download time to build time

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












I am going to create my own internal repository service via createrepo and want to provide an Java repository as well.



Downloading the JRE and JDK packages automatically and as described at Stack Overflow leaves me with files which have a timestamp from the time they were downloaded. The creation time of the files is set to the runtime of the download script.



For further processing I like to have the timestamps set to the build time of the RPM package (... so that I can query them via ls -al, ll, --full-time, etc.).



How to change creation time of files (RPM) from download time to build time automatically?







share|improve this question



























    up vote
    0
    down vote

    favorite












    I am going to create my own internal repository service via createrepo and want to provide an Java repository as well.



    Downloading the JRE and JDK packages automatically and as described at Stack Overflow leaves me with files which have a timestamp from the time they were downloaded. The creation time of the files is set to the runtime of the download script.



    For further processing I like to have the timestamps set to the build time of the RPM package (... so that I can query them via ls -al, ll, --full-time, etc.).



    How to change creation time of files (RPM) from download time to build time automatically?







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am going to create my own internal repository service via createrepo and want to provide an Java repository as well.



      Downloading the JRE and JDK packages automatically and as described at Stack Overflow leaves me with files which have a timestamp from the time they were downloaded. The creation time of the files is set to the runtime of the download script.



      For further processing I like to have the timestamps set to the build time of the RPM package (... so that I can query them via ls -al, ll, --full-time, etc.).



      How to change creation time of files (RPM) from download time to build time automatically?







      share|improve this question













      I am going to create my own internal repository service via createrepo and want to provide an Java repository as well.



      Downloading the JRE and JDK packages automatically and as described at Stack Overflow leaves me with files which have a timestamp from the time they were downloaded. The creation time of the files is set to the runtime of the download script.



      For further processing I like to have the timestamps set to the build time of the RPM package (... so that I can query them via ls -al, ll, --full-time, etc.).



      How to change creation time of files (RPM) from download time to build time automatically?









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 30 at 7:38
























      asked Jul 30 at 7:22









      U880D

      399314




      399314




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          After some research I've found that I can query the RPM build time via rpm -qip.



          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME


          The date command can reformat the given date and time string



          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP


          so that it could be later used with the touch command.



          touch -m -a -t $TIMESTAMP $FILENAME


          By iterating over all files within a specific directory it is possible to list all creation times of all packages contained and modify it automatically.



          #!/bin/bash

          for FILENAME in *.rpm; do

          echo $FILENAME

          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME

          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP

          touch -m -a -t $TIMESTAMP $FILENAME

          done





          share|improve this answer

















          • 1




            Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
            – Ignacio Vazquez-Abrams
            Jul 30 at 7:50











          • Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
            – U880D
            Jul 30 at 8:04











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459265%2fchange-creation-time-of-files-rpm-from-download-time-to-build-time%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          After some research I've found that I can query the RPM build time via rpm -qip.



          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME


          The date command can reformat the given date and time string



          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP


          so that it could be later used with the touch command.



          touch -m -a -t $TIMESTAMP $FILENAME


          By iterating over all files within a specific directory it is possible to list all creation times of all packages contained and modify it automatically.



          #!/bin/bash

          for FILENAME in *.rpm; do

          echo $FILENAME

          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME

          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP

          touch -m -a -t $TIMESTAMP $FILENAME

          done





          share|improve this answer

















          • 1




            Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
            – Ignacio Vazquez-Abrams
            Jul 30 at 7:50











          • Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
            – U880D
            Jul 30 at 8:04















          up vote
          1
          down vote













          After some research I've found that I can query the RPM build time via rpm -qip.



          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME


          The date command can reformat the given date and time string



          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP


          so that it could be later used with the touch command.



          touch -m -a -t $TIMESTAMP $FILENAME


          By iterating over all files within a specific directory it is possible to list all creation times of all packages contained and modify it automatically.



          #!/bin/bash

          for FILENAME in *.rpm; do

          echo $FILENAME

          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME

          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP

          touch -m -a -t $TIMESTAMP $FILENAME

          done





          share|improve this answer

















          • 1




            Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
            – Ignacio Vazquez-Abrams
            Jul 30 at 7:50











          • Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
            – U880D
            Jul 30 at 8:04













          up vote
          1
          down vote










          up vote
          1
          down vote









          After some research I've found that I can query the RPM build time via rpm -qip.



          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME


          The date command can reformat the given date and time string



          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP


          so that it could be later used with the touch command.



          touch -m -a -t $TIMESTAMP $FILENAME


          By iterating over all files within a specific directory it is possible to list all creation times of all packages contained and modify it automatically.



          #!/bin/bash

          for FILENAME in *.rpm; do

          echo $FILENAME

          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME

          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP

          touch -m -a -t $TIMESTAMP $FILENAME

          done





          share|improve this answer













          After some research I've found that I can query the RPM build time via rpm -qip.



          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME


          The date command can reformat the given date and time string



          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP


          so that it could be later used with the touch command.



          touch -m -a -t $TIMESTAMP $FILENAME


          By iterating over all files within a specific directory it is possible to list all creation times of all packages contained and modify it automatically.



          #!/bin/bash

          for FILENAME in *.rpm; do

          echo $FILENAME

          BUILDTIME=$(rpm -qip --nosignature $FILENAME | grep -i "Build Date : " | sed -e 's/Build Date : //g')
          echo $BUILDTIME

          TIMESTAMP=$(date --date="$BUILDTIME" "+%Y%m%d%H%M")
          echo $TIMESTAMP

          touch -m -a -t $TIMESTAMP $FILENAME

          done






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jul 30 at 7:29









          U880D

          399314




          399314







          • 1




            Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
            – Ignacio Vazquez-Abrams
            Jul 30 at 7:50











          • Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
            – U880D
            Jul 30 at 8:04













          • 1




            Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
            – Ignacio Vazquez-Abrams
            Jul 30 at 7:50











          • Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
            – U880D
            Jul 30 at 8:04








          1




          1




          Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
          – Ignacio Vazquez-Abrams
          Jul 30 at 7:50





          Or you can use rpm --qf ... to extract only the headers you care about: touch "$PACKAGE" -d"$(rpm -qp "$PACKAGE" --qf "%BUILDTIME:daten")"
          – Ignacio Vazquez-Abrams
          Jul 30 at 7:50













          Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
          – U880D
          Jul 30 at 8:04





          Just tested with rpm -qp "$FILENAME" --qf "%BUILDTIME:daten")" and found it more elegant. Thanks for the hint and +1.
          – U880D
          Jul 30 at 8:04













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459265%2fchange-creation-time-of-files-rpm-from-download-time-to-build-time%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)